fixes semicolon parsing issue
This commit is contained in:
parent
865a43050d
commit
b3ac785f95
3 changed files with 15 additions and 6 deletions
|
|
@ -1748,7 +1748,7 @@ proc complexOrSimpleStmt(p: var TParser): PNode =
|
||||||
|
|
||||||
proc parseStmt(p: var TParser): PNode =
|
proc parseStmt(p: var TParser): PNode =
|
||||||
#| stmt = (IND{>} complexOrSimpleStmt^+(IND{=} / ';') DED)
|
#| stmt = (IND{>} complexOrSimpleStmt^+(IND{=} / ';') DED)
|
||||||
#| / simpleStmt
|
#| / simpleStmt ^+ ';'
|
||||||
if p.tok.indent > p.currInd:
|
if p.tok.indent > p.currInd:
|
||||||
result = newNodeP(nkStmtList, p)
|
result = newNodeP(nkStmtList, p)
|
||||||
withInd(p):
|
withInd(p):
|
||||||
|
|
@ -1779,10 +1779,14 @@ proc parseStmt(p: var TParser): PNode =
|
||||||
parMessage(p, errComplexStmtRequiresInd)
|
parMessage(p, errComplexStmtRequiresInd)
|
||||||
result = ast.emptyNode
|
result = ast.emptyNode
|
||||||
else:
|
else:
|
||||||
if p.tok.indent >= 0: parMessage(p, errInvalidIndentation)
|
result = newNodeP(nkStmtList, p)
|
||||||
result = simpleStmt(p)
|
while true:
|
||||||
if result.kind == nkEmpty: parMessage(p, errExprExpected, p.tok)
|
if p.tok.indent >= 0: parMessage(p, errInvalidIndentation)
|
||||||
#while p.tok.tokType == tkSemicolon: getTok(p)
|
let a = simpleStmt(p)
|
||||||
|
if a.kind == nkEmpty: parMessage(p, errExprExpected, p.tok)
|
||||||
|
result.add(a)
|
||||||
|
if p.tok.tokType != tkSemicolon: break
|
||||||
|
getTok(p)
|
||||||
|
|
||||||
proc parseAll(p: var TParser): PNode =
|
proc parseAll(p: var TParser): PNode =
|
||||||
result = newNodeP(nkStmtList, p)
|
result = newNodeP(nkStmtList, p)
|
||||||
|
|
|
||||||
|
|
@ -186,4 +186,4 @@ complexOrSimpleStmt = (ifStmt | whenStmt | whileStmt
|
||||||
| bindStmt | mixinStmt)
|
| bindStmt | mixinStmt)
|
||||||
/ simpleStmt
|
/ simpleStmt
|
||||||
stmt = (IND{>} complexOrSimpleStmt^+(IND{=} / ';') DED)
|
stmt = (IND{>} complexOrSimpleStmt^+(IND{=} / ';') DED)
|
||||||
/ simpleStmt
|
/ simpleStmt ^+ ';'
|
||||||
|
|
|
||||||
|
|
@ -64,3 +64,8 @@ proc p2(a: int): int =
|
||||||
q()
|
q()
|
||||||
|
|
||||||
echo p(), " ", p2(2)
|
echo p(), " ", p2(2)
|
||||||
|
|
||||||
|
proc semiProblem() =
|
||||||
|
if false: echo "aye"; echo "indeed"
|
||||||
|
|
||||||
|
semiProblem()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue