Fixed a bug with the 'do notation' consuming statements after it.

This commit is contained in:
Dominik Picheta 2013-01-20 12:47:25 +00:00
commit b9d75f8944
2 changed files with 25 additions and 12 deletions

View file

@ -494,12 +494,6 @@ proc primarySuffix(p: var TParser, r: PNode): PNode =
result = newNodeP(nkCall, p) result = newNodeP(nkCall, p)
addSon(result, a) addSon(result, a)
exprColonEqExprListAux(p, nkExprEqExpr, tkParRi, tkEquals, result) exprColonEqExprListAux(p, nkExprEqExpr, tkParRi, tkEquals, result)
parseDoBlocks(p, result)
of tkDo:
var a = result
result = newNodeP(nkCall, p)
addSon(result, a)
parseDoBlocks(p, result)
of tkDot: of tkDot:
result = dotExpr(p, result) result = dotExpr(p, result)
result = parseGStrLit(p, result) result = parseGStrLit(p, result)
@ -736,7 +730,7 @@ proc parseProcExpr(p: var TParser, isExpr: bool): PNode =
proc isExprStart(p: TParser): bool = proc isExprStart(p: TParser): bool =
case p.tok.tokType case p.tok.tokType
of tkSymbol, tkAccent, tkOpr, tkNot, tkNil, tkCast, tkIf, of tkSymbol, tkAccent, tkOpr, tkNot, tkNil, tkCast, tkIf,
tkProc, tkIterator, tkBind, tkProc, tkDo, tkIterator, tkBind,
tkParLe, tkBracketLe, tkCurlyLe, tkIntLit..tkCharLit, tkVar, tkRef, tkPtr, tkParLe, tkBracketLe, tkCurlyLe, tkIntLit..tkCharLit, tkVar, tkRef, tkPtr,
tkTuple, tkObject, tkType, tkWhen, tkCase, tkShared: tkTuple, tkObject, tkType, tkWhen, tkCase, tkShared:
result = true result = true
@ -832,6 +826,8 @@ proc primary(p: var TParser, mode: TPrimaryMode): PNode =
getTok(p) getTok(p)
optInd(p, result) optInd(p, result)
addSon(result, primary(p, pmNormal)) addSon(result, primary(p, pmNormal))
of tkDo:
result = parseDoBlock(p)
else: else:
result = identOrLiteral(p) result = identOrLiteral(p)
if mode != pmSkipSuffix: if mode != pmSkipSuffix:
@ -864,7 +860,7 @@ proc parseExprStmt(p: var TParser): PNode =
optInd(p, a) optInd(p, a)
if p.tok.tokType == tkDo: if p.tok.tokType == tkDo:
parseDoBlocks(p, call) parseDoBlocks(p, call)
return return call
result = if call.sonsLen <= 1: a result = if call.sonsLen <= 1: a
else: call else: call
if p.tok.tokType == tkColon: if p.tok.tokType == tkColon:

17
tests/run/tdomulttest.nim Normal file
View file

@ -0,0 +1,17 @@
discard """
file: "tasynciossl.nim"
cmd: "nimrod cc --hints:on --define:ssl $# $#"
output: "555\ntest\nmulti lines\n99999999\nend"
"""
proc foo(bar, baz: proc (x: int): int) =
echo bar(555)
echo baz(99999999)
foo do (x: int) -> int:
return x
do (x: int) -> int:
echo("test")
echo("multi lines")
return x
echo("end")