fixes #13; fixes #18

This commit is contained in:
Araq 2011-03-08 01:59:15 +01:00
commit fa332b7298
4 changed files with 102 additions and 21 deletions

View file

@ -0,0 +1,27 @@
discard """
output: "ta-da Your value sir: 'HE!!!!o Wor!!d'"
"""
import macros, strutils
proc testBlock(): string {.compileTime.} =
block myBlock:
while true:
echo "inner block"
break myBlock
echo "outer block"
result = "ta-da"
macro mac(n: expr): expr =
expectKind(n, nnkCall)
expectLen(n, 2)
expectKind(n[1], nnkStrLit)
var s: string = n[1].strVal
s = s.replace("l", "!!")
result = newStrLitNode("Your value sir: '$#'" % [s])
const s = testBlock()
const t = mac("HEllo World")
echo s, " ", t