all repos — min @ 0bd3332010dc1a440d799a14c20ef34146fc94b3

A small but practical concatenative programming language.

Fixing parsing errors.
h3rald h3rald@h3rald.com
Sun, 12 Nov 2023 12:17:10 +0100
commit

0bd3332010dc1a440d799a14c20ef34146fc94b3

parent

3a9603640011399a0a6b11d40910026be30156ae

2 files changed, 13 insertions(+), 8 deletions(-)

jump to
M minpkg/core/interpreter.nimminpkg/core/interpreter.nim

@@ -337,10 +337,11 @@ if i.trace.len == 0:

i.stackcopy = i.stack handleErrors(i) do: val = i.parser.parseMinValue(i) - if parseOnly: - q.qVal.add val - else: - i.push val + if not val.isNil: + if parseOnly: + q.qVal.add val + else: + i.push val if parseOnly: return q if i.stack.len > 0:
M minpkg/core/parser.nimminpkg/core/parser.nim

@@ -550,16 +550,18 @@ while true:

case my.buf[my.bufpos]: of ' ', '\t': add(my.a, my.buf[my.bufpos]) + result = tkSpace inc(my.bufpos) of '\c': add(my.a, my.buf[my.bufpos]) + result = tkSpace my.bufpos = lexbase.handleCR(my, my.bufpos) of '\L': add(my.a, my.buf[my.bufpos]) + result = tkSpace my.bufpos = lexbase.handleLF(my, my.bufpos) else: break - result = tkSpace of '-', '.': if my.bufpos+1 <= my.buf.len and my.buf[my.bufpos+1] in '0'..'9': parseNumber(my)

@@ -863,12 +865,14 @@ p.a = ""

p.currSym = result discard getToken(p) of tkLineComment, tkBlockComment, tkLineDocComment, tkBlockDocComment, tkSpace: - discard getToken(p) - result = p.parseMinValue(i) + eat(p, p.token) + result = nil #p.parseMinValue(i) + #discard getToken(p) else: let err = "Undefined or invalid value (" & $p.token & "): " & p.a raiseUndefined(p, err) - result.filename = p.filename + if not result.isNil: + result.filename = p.filename proc compileMinValue*(p: var MinParser, i: In, push = true, indent = ""): seq[string] = var op = indent