implemented case expressions

This commit is contained in:
Zahary Karadjov 2012-10-01 23:48:37 +03:00
commit 770d4a997e
8 changed files with 137 additions and 24 deletions

View file

@ -781,6 +781,11 @@ proc add*(father, son: PNode) =
proc `[]`*(n: PNode, i: int): PNode {.inline.} =
result = n.sons[i]
# son access operators with support for negative indices
template `{}`*(n: PNode, i: int): expr = n[i -| n]
template `{}=`*(n: PNode, i: int, s: PNode): stmt =
n.sons[i -| n] = s
var emptyNode* = newNode(nkEmpty)
# There is a single empty node that is shared! Do not overwrite it!