all repos — min @ d5a0977174c8fa31e454bfd966c07ae3244e373c

A small but practical concatenative programming language.

Raising error in case of invalid dictionary (ref: #47)
h3rald h3rald@h3rald.com
Sun, 26 Jan 2020 12:10:48 +0100
commit

d5a0977174c8fa31e454bfd966c07ae3244e373c

parent

5e69999ed1c83f71991c36ac748038c94ad37016

1 files changed, 5 insertions(+), 0 deletions(-)

jump to
M core/parser.nimcore/parser.nim

@@ -623,8 +623,11 @@ of tkBraceLe:

var scope = newScopeRef(nil) var val: MinValue discard getToken(p) + var c = 0 while p.token != tkBraceRi: + c = c+1 let v = p.parseMinValue(i) + echo(c mod 2) if val.isNil: val = v elif v.kind == minSymbol:

@@ -637,6 +640,8 @@ raiseInvalid("Invalid dictionary key: " & key)

else: raiseInvalid("Invalid dictionary key: " & $v) eat(p, tkBraceRi) + if c mod 2 != 0: + raiseInvalid("Invalid dictionary") result = MinValue(kind: minDictionary, scope: scope) of tkSymbol: result = MinValue(kind: minSymbol, symVal: p.a, column: p.getColumn, line: p.lineNumber, filename: p.filename)