diff options
author | apense <apense@users.noreply.github.com> | 2015-06-09 16:24:13 -0400 |
---|---|---|
committer | apense <apense@users.noreply.github.com> | 2015-06-09 16:24:13 -0400 |
commit | 867b38496b234df22ab34ef15344f848278b096d (patch) | |
tree | 1031cee9359756aea23662d1d69a191746f1236f /compiler/ast.nim | |
parent | 31424003516f89bc23165ad9c4b1e76c4212508c (diff) | |
download | Nim-867b38496b234df22ab34ef15344f848278b096d.tar.gz |
Moved negative indexing operator here
Only used here (not in standard library)
Diffstat (limited to 'compiler/ast.nim')
-rw-r--r-- | compiler/ast.nim | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim index dc190fd7f..f48003797 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -948,6 +948,9 @@ proc add*(father, son: PNode) = proc `[]`*(n: PNode, i: int): PNode {.inline.} = result = n.sons[i] +template `-|`*(b, s: expr): expr = + (if b >= 0: b else: s.len + b) + # 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 = |