diff options
Diffstat (limited to 'compiler/ast.nim')
-rwxr-xr-x | compiler/ast.nim | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim index c6e4d8318..aa94644aa 100755 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -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! |