Now stopping the interpreter on error.
h3rald h3rald@h3rald.com
Thu, 13 Oct 2016 17:51:33 +0200
4 files changed,
7 insertions(+),
2 deletions(-)
M
core/interpreter.nim
→
core/interpreter.nim
@@ -140,6 +140,7 @@ stack: st,
scope: scope, debugging: debugging, unsafe: false, + halt: false, currSym: MinValue(column: 1, line: 1, kind: minSymbol, symVal: "") ) return i@@ -165,9 +166,11 @@ body
except MinRuntimeError: i.stack = stack stderr.writeLine("$1 [$2,$3]: $4" % [i.filename, $i.currSym.line, $i.currSym.column, getCurrentExceptionMsg()]) + i.halt = true except: i.stack = stack i.error(getCurrentExceptionMsg()) + i.halt = true proc open*(i: In, stream:Stream, filename: string) = i.filename = filename@@ -251,7 +254,7 @@ raiseEmptyStack()
proc interpret*(i: In) {.gcsafe.}= var val: MinValue - while i.parser.token != tkEof: + while i.parser.token != tkEof and not i.halt: i.execute: val = i.parser.parseMinValue i.push val
M
core/parser.nim
→
core/parser.nim
@@ -97,6 +97,7 @@ filename*: string
debugging*: bool evaluating*: bool unsafe*: bool + halt*: bool MinParsingError* = ref object of ValueError MinUndefinedError* = ref object of ValueError MinEmptyStackError* = ref object of ValueError
M
tests/all.min
→
tests/all.min
@@ -6,4 +6,4 @@ 'str load
'sys load 'time load 'fs load -'crypto load+'crypto load