for statements support comma expressions
This commit is contained in:
parent
570f8b21e1
commit
97eaeb3aec
1 changed files with 4 additions and 2 deletions
|
|
@ -1583,6 +1583,8 @@ proc parseStandaloneStruct(p: var TParser, isUnion: bool): PNode =
|
||||||
backtrackContext(p)
|
backtrackContext(p)
|
||||||
result = declaration(p)
|
result = declaration(p)
|
||||||
|
|
||||||
|
proc embedStmts(sl, a: PNode)
|
||||||
|
|
||||||
proc parseFor(p: var TParser, result: PNode) =
|
proc parseFor(p: var TParser, result: PNode) =
|
||||||
# 'for' '(' expression_statement expression_statement expression? ')'
|
# 'for' '(' expression_statement expression_statement expression? ')'
|
||||||
# statement
|
# statement
|
||||||
|
|
@ -1590,7 +1592,7 @@ proc parseFor(p: var TParser, result: PNode) =
|
||||||
eat(p, pxParLe, result)
|
eat(p, pxParLe, result)
|
||||||
var initStmt = declarationOrStatement(p)
|
var initStmt = declarationOrStatement(p)
|
||||||
if initStmt.kind != nkEmpty:
|
if initStmt.kind != nkEmpty:
|
||||||
addSon(result, initStmt)
|
embedStmts(result, initStmt)
|
||||||
var w = newNodeP(nkWhileStmt, p)
|
var w = newNodeP(nkWhileStmt, p)
|
||||||
var condition = expressionStatement(p)
|
var condition = expressionStatement(p)
|
||||||
if condition.kind == nkEmpty: condition = newIdentNodeP("true", p)
|
if condition.kind == nkEmpty: condition = newIdentNodeP("true", p)
|
||||||
|
|
@ -1600,7 +1602,7 @@ proc parseFor(p: var TParser, result: PNode) =
|
||||||
var loopBody = nestedStatement(p)
|
var loopBody = nestedStatement(p)
|
||||||
if step.kind != nkEmpty:
|
if step.kind != nkEmpty:
|
||||||
loopBody = buildStmtList(loopBody)
|
loopBody = buildStmtList(loopBody)
|
||||||
addSon(loopBody, step)
|
embedStmts(loopBody, step)
|
||||||
addSon(w, loopBody)
|
addSon(w, loopBody)
|
||||||
addSon(result, w)
|
addSon(result, w)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue