Rename PNimrodNode to NimNode

This commit is contained in:
def 2015-03-17 17:50:32 +01:00
commit fd4e629905
30 changed files with 508 additions and 518 deletions

View file

@ -1,13 +1,13 @@
# Dump the contents of a PNimrodNode
# Dump the contents of a NimNode
import macros
proc dumpit(n: PNimrodNode): string {.compileTime.} =
proc dumpit(n: NimNode): string {.compileTime.} =
if n == nil: return "nil"
result = $n.kind
add(result, "(")
case n.kind
of nnkEmpty: discard # same as nil node in this representation
of nnkEmpty: discard # same as nil node in this representation
of nnkNilLit: add(result, "nil")
of nnkCharLit..nnkInt64Lit: add(result, $n.intVal)
of nnkFloatLit..nnkFloat64Lit: add(result, $n.floatVal)
@ -20,17 +20,17 @@ proc dumpit(n: PNimrodNode): string {.compileTime.} =
add(result, ", ")
add(result, dumpit(n[j]))
add(result, ")")
macro dumpAST(n: stmt): stmt {.immediate.} =
macro dumpAST(n: stmt): stmt {.immediate.} =
# dump AST as a side-effect and return the inner node
let n = callsite()
echo dumpit(n)
result = n[1]
dumpAST:
proc add(x, y: int): int =
return x + y
proc sub(x, y: int): int = return x - y