Fix for expression parsing, 'new' is a valid C symbol
This commit is contained in:
parent
5f905865be
commit
d9a61c13dd
1 changed files with 9 additions and 6 deletions
|
|
@ -1152,7 +1152,7 @@ proc startExpression(p : var TParser, tok : TToken) : PNode =
|
||||||
eat(p, pxParLe)
|
eat(p, pxParLe)
|
||||||
addSon(result, typeDesc(p))
|
addSon(result, typeDesc(p))
|
||||||
eat(p, pxParRi)
|
eat(p, pxParRi)
|
||||||
elif tok.s == "new" or tok.s == "delete" and pfCpp in p.options.flags:
|
elif (tok.s == "new" or tok.s == "delete") and pfCpp in p.options.flags:
|
||||||
var opr = tok.s
|
var opr = tok.s
|
||||||
result = newNodeP(nkCall, p)
|
result = newNodeP(nkCall, p)
|
||||||
if p.tok.xkind == pxBracketLe:
|
if p.tok.xkind == pxBracketLe:
|
||||||
|
|
@ -2096,9 +2096,12 @@ proc statement(p: var TParser): PNode =
|
||||||
assert result != nil
|
assert result != nil
|
||||||
|
|
||||||
proc parseUnit(p: var TParser): PNode =
|
proc parseUnit(p: var TParser): PNode =
|
||||||
|
try:
|
||||||
result = newNodeP(nkStmtList, p)
|
result = newNodeP(nkStmtList, p)
|
||||||
getTok(p) # read first token
|
getTok(p) # read first token
|
||||||
while p.tok.xkind != pxEof:
|
while p.tok.xkind != pxEof:
|
||||||
var s = statement(p)
|
var s = statement(p)
|
||||||
if s.kind != nkEmpty: embedStmts(result, s)
|
if s.kind != nkEmpty: embedStmts(result, s)
|
||||||
|
except:
|
||||||
|
parMessage(p, errGenerated, "Uncaught exception raised during parsing")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue