From 11e9f1d854602aae7cb895cfb2f9fc5dd338e6f8 Mon Sep 17 00:00:00 2001 From: mryouse Date: Fri, 26 May 2023 02:27:02 +0000 Subject: start making errors a bit nicer --- vm.d | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'vm.d') diff --git a/vm.d b/vm.d index c14c746..dcacd28 100644 --- a/vm.d +++ b/vm.d @@ -9,6 +9,7 @@ import compiler; //import obj; import dbg; + enum InterpretResult { OK, COMPILE_ERROR, @@ -569,6 +570,13 @@ InterpretResult interpret(string source, VM vm) { Compiler compiler = new Compiler(ObjType.SCRIPT, &parser); Function func = compiler.compile(); + if (compiler.errors.length > 0) { + foreach (CompileError err ; compiler.errors) { + writefln("error: %s", printableCompilerError(err)); + } + return InterpretResult.COMPILE_ERROR; + } + // vm.globals[":int"] = makeTypeValue(":int"); // reset the frame count (why do i need to do this?) -- cgit v1.2.3