fix tokenizing bug
This commit is contained in:
parent
145cb3ae8c
commit
ce29b9f78c
1 changed files with 13 additions and 8 deletions
|
|
@ -287,7 +287,7 @@ proc colcom(p: var TParser, n: PNode) =
|
||||||
skipComment(p, n)
|
skipComment(p, n)
|
||||||
|
|
||||||
proc parseSymbol(p: var TParser, allowNil = false): PNode =
|
proc parseSymbol(p: var TParser, allowNil = false): PNode =
|
||||||
#| symbol = '`' (KEYW|IDENT|operator|'('|')'|'['|']'|'{'|'}'|'='|literal)+ '`'
|
#| symbol = '`' (KEYW|IDENT|literal|(operator|'('|')'|'['|']'|'{'|'}'|'=')+)+ '`'
|
||||||
#| | IDENT
|
#| | IDENT
|
||||||
case p.tok.tokType
|
case p.tok.tokType
|
||||||
of tkSymbol:
|
of tkSymbol:
|
||||||
|
|
@ -296,19 +296,24 @@ proc parseSymbol(p: var TParser, allowNil = false): PNode =
|
||||||
of tkAccent:
|
of tkAccent:
|
||||||
result = newNodeP(nkAccQuoted, p)
|
result = newNodeP(nkAccQuoted, p)
|
||||||
getTok(p)
|
getTok(p)
|
||||||
var accm = ""
|
|
||||||
while true:
|
while true:
|
||||||
case p.tok.tokType
|
case p.tok.tokType
|
||||||
of tkAccent:
|
of tkAccent:
|
||||||
if accm == "":
|
if result.len == 0:
|
||||||
parMessage(p, errIdentifierExpected, p.tok)
|
parMessage(p, errIdentifierExpected, p.tok)
|
||||||
break
|
break
|
||||||
of tkEof, tkInvalid, tkComment:
|
of tkOpr, tkDot, tkDotDot, tkEquals, tkParLe..tkParDotRi:
|
||||||
parMessage(p, errIdentifierExpected, p.tok)
|
var accm = ""
|
||||||
else:
|
while p.tok.tokType in {tkOpr, tkDot, tkDotDot, tkEquals,
|
||||||
accm.add(tokToStr(p.tok))
|
tkParLe..tkParDotRi}:
|
||||||
|
accm.add(tokToStr(p.tok))
|
||||||
|
getTok(p)
|
||||||
|
result.add(newIdentNodeP(getIdent(accm), p))
|
||||||
|
of tokKeywordLow..tokKeywordHigh, tkSymbol, tkIntLit..tkCharLit:
|
||||||
|
result.add(newIdentNodeP(getIdent(tokToStr(p.tok)), p))
|
||||||
getTok(p)
|
getTok(p)
|
||||||
result.add(newIdentNodeP(getIdent(accm), p))
|
else:
|
||||||
|
parMessage(p, errIdentifierExpected, p.tok)
|
||||||
eat(p, tkAccent)
|
eat(p, tkAccent)
|
||||||
else:
|
else:
|
||||||
if allowNil and p.tok.tokType == tkNil:
|
if allowNil and p.tok.tokType == tkNil:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue