diff options
author | Araq <rumpf_a@web.de> | 2012-05-28 01:17:17 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2012-05-28 01:17:17 +0200 |
commit | f3980eb24ad76001671c76ce668f0ee25e481ba0 (patch) | |
tree | e9fd3187ea7b9d9baf4d46fbd24520fbc7c9edf7 /lib/core/macros.nim | |
parent | 22188a0647c90f56d3fa23c5723d909c0ea70714 (diff) | |
download | Nim-f3980eb24ad76001671c76ce668f0ee25e481ba0.tar.gz |
made tsequtils green again
Diffstat (limited to 'lib/core/macros.nim')
-rwxr-xr-x | lib/core/macros.nim | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim index 21f5134e2..b0f237924 100755 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -217,10 +217,19 @@ template emit*(s: expr): stmt = ## Example: ## ## emit("echo " & '"' & "hello world".toUpper & '"') - ## - block: - const evaluated = s - eval: result = evaluated.parseStmt + ## + block: + const evaluated = s + eval: result = evaluated.parseStmt + when false: + template once(x: expr): expr = + block: + const y = x + y + + macro `payload`(x: stmt): stmt = result = once(s).parseStmt + `payload`() + proc expectKind*(n: PNimrodNode, k: TNimrodNodeKind) {.compileTime.} = ## checks that `n` is of kind `k`. If this is not the case, @@ -323,7 +332,7 @@ proc lispRepr*(n: PNimrodNode): string {.compileTime.} = macro dumpTree*(s: stmt): stmt = echo s[1].treeRepr ## Accepts a block of nimrod code and prints the parsed abstract syntax - ## tree using the `toTree` function. + ## tree using the `toTree` function. Printing is done *at compile time*. ## ## You can use this as a tool to explore the Nimrod's abstract syntax ## tree and to discover what kind of nodes must be created to represent @@ -331,7 +340,7 @@ macro dumpTree*(s: stmt): stmt = echo s[1].treeRepr macro dumpLisp*(s: stmt): stmt = echo s[1].lispRepr ## Accepts a block of nimrod code and prints the parsed abstract syntax - ## tree using the `toLisp` function. + ## tree using the `toLisp` function. Printing is done *at compile time*. ## ## See `dumpTree`. |