all repos — min @ 926dc78ee81f182c4435dd6ebdd168beb3ceff8f

A small but practical concatenative programming language.

Now stopping the interpreter on error.
h3rald h3rald@h3rald.com
Thu, 13 Oct 2016 17:51:33 +0200
commit

926dc78ee81f182c4435dd6ebdd168beb3ceff8f

parent

9616781b776e00ddc7c55ac6a43ca78254fc3eb9

4 files changed, 7 insertions(+), 2 deletions(-)

jump to
M core/interpreter.nimcore/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.nimcore/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 minim.nimminim.nim

@@ -174,6 +174,7 @@ i.interpret()

except: stderr.writeLine getCurrentExceptionMsg() finally: + i.halt = false if i.stack.len > 0: let last = i.stack[i.stack.len - 1] let n = $i.stack.len
M tests/all.mintests/all.min

@@ -6,4 +6,4 @@ 'str load

'sys load 'time load 'fs load -'crypto load+'crypto load