diff options
-rw-r--r-- | compiler/parser.nim | 8 | ||||
-rw-r--r-- | doc/grammar.txt | 2 | ||||
-rw-r--r-- | tests/parser/tletcolon.nim | 3 |
3 files changed, 10 insertions, 3 deletions
diff --git a/compiler/parser.nim b/compiler/parser.nim index 46953de1e..e9dff25ac 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -1208,7 +1208,7 @@ proc parseMacroColon(p: var TParser, x: PNode): PNode = proc parseExprStmt(p: var TParser): PNode = #| exprStmt = simpleExpr - #| (( '=' optInd expr ) + #| (( '=' optInd expr colonBody? ) #| / ( expr ^+ comma #| doBlocks #| / macroColon @@ -1219,6 +1219,12 @@ proc parseExprStmt(p: var TParser): PNode = getTok(p) optInd(p, result) var b = parseExpr(p) + if p.tok.tokType == tkColon and p.tok.indent < 0: + if b.kind != nkEmpty: + let call = makeCall(b) + call.add parseDoBlock(p, parLineInfo(p)) + parseDoBlocks(p, call) + b = call addSon(result, a) addSon(result, b) else: diff --git a/doc/grammar.txt b/doc/grammar.txt index f6b9b115f..f50045233 100644 --- a/doc/grammar.txt +++ b/doc/grammar.txt @@ -103,7 +103,7 @@ macroColon = ':' stmt? ( IND{=} 'of' exprList ':' stmt | IND{=} 'except' exprList ':' stmt | IND{=} 'else' ':' stmt )* exprStmt = simpleExpr - (( '=' optInd expr ) + (( '=' optInd expr colonBody? ) / ( expr ^+ comma doBlocks / macroColon diff --git a/tests/parser/tletcolon.nim b/tests/parser/tletcolon.nim index ec7c24106..6b86535c8 100644 --- a/tests/parser/tletcolon.nim +++ b/tests/parser/tletcolon.nim @@ -18,7 +18,8 @@ template y(val, body): untyped = proc mana = let foo = x: echo "boo" - var foo2 = y 3: + var foo2: int + foo2 = y 3: echo "3" echo foo, " ", foo2 |