changed handling of generalized string literals

This commit is contained in:
Araq 2011-02-07 00:11:11 +01:00
commit 134f24f579
10 changed files with 76 additions and 39 deletions

View file

@ -394,11 +394,27 @@ proc setBaseFlags(n: PNode, base: TNumericalBase) =
of base8: incl(n.flags, nfBase8)
of base16: incl(n.flags, nfBase16)
proc parseGStrLit(p: var TParser, a: PNode): PNode =
case p.tok.tokType
of tkGStrLit:
result = newNodeP(nkCallStrLit, p)
addSon(result, a)
addSon(result, newStrNodeP(nkRStrLit, p.tok.literal, p))
getTok(p)
of tkGTripleStrLit:
result = newNodeP(nkCallStrLit, p)
addSon(result, a)
addSon(result, newStrNodeP(nkTripleStrLit, p.tok.literal, p))
getTok(p)
else:
result = a
proc identOrLiteral(p: var TParser): PNode =
case p.tok.tokType
of tkSymbol:
result = newIdentNodeP(p.tok.ident, p)
getTok(p)
result = parseGStrLit(p, result)
of tkAccent:
result = accExpr(p) # literals
of tkIntLit:
@ -442,16 +458,6 @@ proc identOrLiteral(p: var TParser): PNode =
of tkTripleStrLit:
result = newStrNodeP(nkTripleStrLit, p.tok.literal, p)
getTok(p)
of tkCallRStrLit:
result = newNodeP(nkCallStrLit, p)
addSon(result, newIdentNodeP(p.tok.ident, p))
addSon(result, newStrNodeP(nkRStrLit, p.tok.literal, p))
getTok(p)
of tkCallTripleStrLit:
result = newNodeP(nkCallStrLit, p)
addSon(result, newIdentNodeP(p.tok.ident, p))
addSon(result, newStrNodeP(nkTripleStrLit, p.tok.literal, p))
getTok(p)
of tkCharLit:
result = newIntNodeP(nkCharLit, ord(p.tok.literal[0]), p)
getTok(p)
@ -509,6 +515,7 @@ proc primary(p: var TParser): PNode =
getTok(p) # skip '.'
optInd(p, result)
addSon(result, parseSymbol(p))
result = parseGStrLit(p, result)
of tkHat:
a = result
result = newNodeP(nkDerefExpr, p)