summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-09-10 00:37:23 +0200
committerAraq <rumpf_a@web.de>2013-09-10 00:37:23 +0200
commit094d7fd4b1e4cd23450f0f5c7e1e2971dc2dcaa6 (patch)
tree5db0f68381c01c0a4e4f00819863d2895266cc7b /lib
parentff1273a3123ba8296780d62d7ad67ffee8c4b8c2 (diff)
downloadNim-094d7fd4b1e4cd23450f0f5c7e1e2971dc2dcaa6.tar.gz
added 'newLit'
Diffstat (limited to 'lib')
-rw-r--r--lib/core/macros.nim22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim
index 9ac6b0082..92cd2d315 100644
--- a/lib/core/macros.nim
+++ b/lib/core/macros.nim
@@ -336,6 +336,26 @@ proc newCall*(theProc: string,
   result.add(newIdentNode(theProc))
   result.add(args)
 
+proc newLit*(c: char): PNimrodNode {.compileTime.} =
+  ## produces a new character literal node.
+  result = newNimNode(nnkCharLit)
+  result.intVal = ord(c)
+
+proc newLit*(i: biggestInt): PNimrodNode {.compileTime.} =
+  ## produces a new integer literal node.
+  result = newNimNode(nnkIntLit)
+  result.intVal = i
+
+proc newLit*(f: biggestFloat): PNimrodNode {.compileTime.} =
+  ## produces a new float literal node.
+  result = newNimNode(nnkFloatLit)
+  result.floatVal = f
+
+proc newLit*(s: string): PNimrodNode {.compileTime.} =
+  ## produces a new string literal node.
+  result = newNimNode(nnkStrLit)
+  result.strVal = s
+
 proc nestList*(theProc: TNimrodIdent,
                x: PNimrodNode): PNimrodNode {.compileTime.} =
   ## nests the list `x` into a tree of call expressions:
@@ -677,7 +697,7 @@ proc addIdentIfAbsent*(dest: PNimrodNode, ident: string) {.compiletime.} =
     of nnkIdent:
       if ident.eqIdent($node): return
     of nnkExprColonExpr:
-      if ident.eqIdent($ node[0]): return
+      if ident.eqIdent($node[0]): return
     else: nil
   dest.add(ident(ident))