mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 14:00:35 +00:00
assignments support ': stmtList' like let/var do
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user