diff options
author | Araq <rumpf_a@web.de> | 2017-11-21 01:42:58 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2017-11-21 01:42:58 +0100 |
commit | 1bbab827c494d41cc87d6cb94524f5f23c54fe88 (patch) | |
tree | 4fbc478c72dbdc0dd5b84e6b1e581e7fa934d91e /examples/talk | |
parent | fba5f5acd6ab1b0aaca79241f55f95b089fbad2c (diff) | |
parent | 2ad49836d95f5d825ba271d64cab1c312f3ccc31 (diff) | |
download | Nim-1bbab827c494d41cc87d6cb94524f5f23c54fe88.tar.gz |
Merge branch 'devel' of github.com:nim-lang/Nim into devel
Diffstat (limited to 'examples/talk')
-rw-r--r-- | examples/talk/dsl.nim | 10 | ||||
-rw-r--r-- | examples/talk/formatoptimizer.nim | 6 | ||||
-rw-r--r-- | examples/talk/quasiquote.nim | 2 | ||||
-rw-r--r-- | examples/talk/tags.nim | 3 |
4 files changed, 11 insertions, 10 deletions
diff --git a/examples/talk/dsl.nim b/examples/talk/dsl.nim index 1034c99d4..2dde51790 100644 --- a/examples/talk/dsl.nim +++ b/examples/talk/dsl.nim @@ -1,20 +1,20 @@ import strutils -template html(name: expr, matter: stmt) {.immediate.} = +template html(name, matter: untyped) = proc name(): string = result = "<html>" matter result.add("</html>") -template nestedTag(tag: expr) {.immediate.} = - template tag(matter: stmt) {.immediate.} = +template nestedTag(tag: untyped) = + template tag(matter: typed) = result.add("<" & astToStr(tag) & ">") matter result.add("</" & astToStr(tag) & ">") -template simpleTag(tag: expr) {.immediate.} = - template tag(matter: expr) {.immediate.} = +template simpleTag(tag: untyped) = + template tag(matter: untyped) = result.add("<$1>$2</$1>" % [astToStr(tag), matter]) nestedTag body diff --git a/examples/talk/formatoptimizer.nim b/examples/talk/formatoptimizer.nim index db11d112d..104214e19 100644 --- a/examples/talk/formatoptimizer.nim +++ b/examples/talk/formatoptimizer.nim @@ -5,7 +5,7 @@ import macros proc invalidFormatString() = echo "invalidFormatString" -template formatImpl(handleChar: expr) = +template formatImpl(handleChar: untyped) = var i = 0 while i < f.len: if f[i] == '$': @@ -24,11 +24,11 @@ template formatImpl(handleChar: expr) = i += 1 proc `%`*(f: string, a: openArray[string]): string = - template identity(x: expr): expr = x + template identity(x: untyped): untyped = x result = "" formatImpl(identity) -macro optFormat{`%`(f, a)}(f: string{lit}, a: openArray[string]): expr = +macro optFormat{`%`(f, a)}(f: string{lit}, a: openArray[string]): untyped = result = newNimNode(nnkBracket) #newCall("&") let f = f.strVal diff --git a/examples/talk/quasiquote.nim b/examples/talk/quasiquote.nim index df4003e6e..b3c7bb971 100644 --- a/examples/talk/quasiquote.nim +++ b/examples/talk/quasiquote.nim @@ -1,7 +1,7 @@ import macros -macro check(ex: expr): stmt = +macro check(ex: untyped): typed = var info = ex.lineinfo var expString = ex.toStrLit result = quote do: diff --git a/examples/talk/tags.nim b/examples/talk/tags.nim index 12b9a08c3..8bf3450c9 100644 --- a/examples/talk/tags.nim +++ b/examples/talk/tags.nim @@ -1,8 +1,9 @@ -template htmlTag(tag: expr) {.immediate.} = +template htmlTag(tag: untyped) = proc tag(): string = "<" & astToStr(tag) & ">" htmlTag(br) htmlTag(html) echo br() +echo html() \ No newline at end of file |