fixes #1286; object case transitions are now sound
This commit is contained in:
parent
247fa431de
commit
49e686ab4e
14 changed files with 123 additions and 166 deletions
|
|
@ -391,29 +391,27 @@ proc ignoreMsg*(c: CfgParser, e: CfgEvent): string {.rtl, extern: "npc$1".} =
|
|||
|
||||
proc getKeyValPair(c: var CfgParser, kind: CfgEventKind): CfgEvent =
|
||||
if c.tok.kind == tkSymbol:
|
||||
result = CfgEvent(kind: cfgKeyValuePair, key: c.tok.literal, value: "")
|
||||
result.kind = kind
|
||||
result.key = c.tok.literal
|
||||
result.value = ""
|
||||
rawGetTok(c, c.tok)
|
||||
if c.tok.kind in {tkEquals, tkColon}:
|
||||
rawGetTok(c, c.tok)
|
||||
if c.tok.kind == tkSymbol:
|
||||
result.value = c.tok.literal
|
||||
else:
|
||||
reset result
|
||||
result.kind = cfgError
|
||||
result.msg = errorStr(c, "symbol expected, but found: " & c.tok.literal)
|
||||
result = CfgEvent(kind: cfgError,
|
||||
msg: errorStr(c, "symbol expected, but found: " & c.tok.literal))
|
||||
rawGetTok(c, c.tok)
|
||||
else:
|
||||
result.kind = cfgError
|
||||
result.msg = errorStr(c, "symbol expected, but found: " & c.tok.literal)
|
||||
result = CfgEvent(kind: cfgError,
|
||||
msg: errorStr(c, "symbol expected, but found: " & c.tok.literal))
|
||||
rawGetTok(c, c.tok)
|
||||
|
||||
proc next*(c: var CfgParser): CfgEvent {.rtl, extern: "npc$1".} =
|
||||
## retrieves the first/next event. This controls the parser.
|
||||
case c.tok.kind
|
||||
of tkEof:
|
||||
result.kind = cfgEof
|
||||
result = CfgEvent(kind: cfgEof)
|
||||
of tkDashDash:
|
||||
rawGetTok(c, c.tok)
|
||||
result = getKeyValPair(c, cfgOption)
|
||||
|
|
@ -422,21 +420,19 @@ proc next*(c: var CfgParser): CfgEvent {.rtl, extern: "npc$1".} =
|
|||
of tkBracketLe:
|
||||
rawGetTok(c, c.tok)
|
||||
if c.tok.kind == tkSymbol:
|
||||
result.kind = cfgSectionStart
|
||||
result.section = c.tok.literal
|
||||
result = CfgEvent(kind: cfgSectionStart, section: c.tok.literal)
|
||||
else:
|
||||
result.kind = cfgError
|
||||
result.msg = errorStr(c, "symbol expected, but found: " & c.tok.literal)
|
||||
result = CfgEvent(kind: cfgError,
|
||||
msg: errorStr(c, "symbol expected, but found: " & c.tok.literal))
|
||||
rawGetTok(c, c.tok)
|
||||
if c.tok.kind == tkBracketRi:
|
||||
rawGetTok(c, c.tok)
|
||||
else:
|
||||
reset(result)
|
||||
result.kind = cfgError
|
||||
result.msg = errorStr(c, "']' expected, but found: " & c.tok.literal)
|
||||
result = CfgEvent(kind: cfgError,
|
||||
msg: errorStr(c, "']' expected, but found: " & c.tok.literal))
|
||||
of tkInvalid, tkEquals, tkColon, tkBracketRi:
|
||||
result.kind = cfgError
|
||||
result.msg = errorStr(c, "invalid token: " & c.tok.literal)
|
||||
result = CfgEvent(kind: cfgError,
|
||||
msg: errorStr(c, "invalid token: " & c.tok.literal))
|
||||
rawGetTok(c, c.tok)
|
||||
|
||||
# ---------------- Configuration file related operations ----------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue