summary refs log tree commit diff stats
path: root/lib/core/macros.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-02-24 19:20:34 +0100
committerAraq <rumpf_a@web.de>2012-02-24 19:20:34 +0100
commitd72b00cf15402b050f4a1ca7e5e73a5968550d0c (patch)
treebda5e87d6d9b22eb824d4201fc6b944ca44815a2 /lib/core/macros.nim
parent8273ebcc289ab079b1e35ea6cac803c6f40efb27 (diff)
parenta3f16968a75e3a9b254b6fac7820fea83debd1e8 (diff)
downloadNim-d72b00cf15402b050f4a1ca7e5e73a5968550d0c.tar.gz
Merge branch 'master' of github.com:Araq/Nimrod
Diffstat (limited to 'lib/core/macros.nim')
-rwxr-xr-xlib/core/macros.nim13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim
index 4d13a076d..e8a16865e 100755
--- a/lib/core/macros.nim
+++ b/lib/core/macros.nim
@@ -208,7 +208,18 @@ proc getAst*(macroOrTemplate: expr): expr {.magic: "ExpandToAst".}
   ##

   ##   macro FooMacro() = 

   ##     var ast = getAst(BarTemplate())

-  

+

+template emit*(s: expr): stmt =

+  ## accepts a single sting argument and treats it as nimrod code

+  ## that should be inserted verbatim in the program

+  ## Example:

+  ## 

+  ##   emit("echo " & '"' & "hello world".toUpper & '"')

+  ##

+  block:

+    const evaluated = s

+    eval: result = evaluated.parseStmt

+

 proc expectKind*(n: PNimrodNode, k: TNimrodNodeKind) {.compileTime.} =

   ## checks that `n` is of kind `k`. If this is not the case,

   ## compilation aborts with an error message. This is useful for writing