all repos — min @ 888c0a0abe088aab1a8971607f7ff47d047c02c2

A small but practical concatenative programming language.

Started implemented stack trace support.
h3rald h3rald@h3rald.com
Sat, 15 Oct 2016 23:02:15 +0200
commit

888c0a0abe088aab1a8971607f7ff47d047c02c2

parent

2a8fca89b977629994e15993c1d72886836c606d

3 files changed, 11 insertions(+), 8 deletions(-)

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