Raising error in case of invalid dictionary (ref: #47)
h3rald h3rald@h3rald.com
Sun, 26 Jan 2020 12:10:48 +0100
1 files changed,
5 insertions(+),
0 deletions(-)
jump to
M
core/parser.nim
→
core/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)