Started implemented stack trace support.
h3rald h3rald@h3rald.com
Sat, 15 Oct 2016 23:02:15 +0200
3 files changed,
11 insertions(+),
8 deletions(-)
M
core/interpreter.nim
→
core/interpreter.nim
@@ -153,11 +153,14 @@ result.stack = i.copystack
result.scope = i.scope result.currSym = MinValue(column: 1, line: 1, kind: minSymbol, symVal: "") -proc error(i: MinInterpreter, message: string) = +proc error(i: In, message: string) = if i.currSym.filename.isNil or i.currSym.filename == "": - stderr.writeLine("`$1`: Error - $2" % [i.currSym.symVal, message]) + stderr.writeLine("`$1`: $2" % [i.currSym.symVal, message]) else: - stderr.writeLine("$1 [$2,$3] `$4`: Error - $5" % [i.currSym.filename, $i.currSym.line, $i.currSym.column, i.currSym.symVal, message]) + stderr.writeLine("$1 [$2,$3] `$4`: $5" % [i.currSym.filename, $i.currSym.line, $i.currSym.column, i.currSym.symVal, message]) + #if not i.currSym.parent.isNil: + # i.currSym = i.currSym.parent + # i.error("...") template execute(i: In, body: untyped) = let stack = i.copystack@@ -201,7 +204,7 @@ return
i.debug val if val.kind == minSymbol: if not i.evaluating: - #val.parent = i.currSym + val.parent = i.currSym i.currSym = val let symbol = val.symVal let sigil = "" & symbol[0]
M
core/parser.nim
→
core/parser.nim
@@ -55,11 +55,12 @@ state*: seq[MinParserState]
kind*: MinEventKind err*: MinParserError filename*: string - MinValue* = object + MinValue* = ref MinValueObject + MinValueObject* = object line*: int column*: int filename*: string - #parent*: MinValue + parent*: MinValue case kind*: MinKind of minInt: intVal*: BiggestInt of minFloat: floatVal*: BiggestFloat
M
tests/lang.min
→
tests/lang.min
@@ -7,7 +7,6 @@ "Total Symbols: " print! symbols size puts!
" Total Sigils: " print! sigils size puts! (debug? false ==) assert - (1 id 1 ==) assert (1 pop get-stack () ==) assert@@ -16,7 +15,7 @@ (1 dup get-stack (1 1) ==) assert
(3 2 (1 +) dip + 6 ==) assert - ((1) (2 swap append) sip concat (1 2 1) ==) assert + ((1) (2 swap append) sip concat (1 2 1 2) ==) assert (2 'a define (3 a + (5 'a define a) -> +) -> a + 12 ==) assert