Remove expr/stmt (#5857)

This commit is contained in:
Arne Döring 2017-07-25 09:28:23 +02:00 • committed by Andreas Rumpf
commit 000b8afd26
168 changed files with 497 additions and 529 deletions

View file

@ -105,10 +105,10 @@ proc pat2kind(pattern: string): FormulaKind =
import macros
proc matchAgainst(n, pattern: NimNode): NimNode {.compileTime.} =
template `@`(current, field: expr): expr =
template `@`(current, field: untyped): untyped =
newDotExpr(current, newIdentNode(astToStr(field)))
template `==@`(n, pattern: expr): expr =
template `==@`(n, pattern: untyped): untyped =
newCall("==", n@kind, newIdentNode($pat2kind($pattern.ident)))
case pattern.kind
@ -126,7 +126,7 @@ proc matchAgainst(n, pattern: NimNode): NimNode {.compileTime.} =
else:
error "invalid pattern"
macro `=~` (n: Formula, pattern: expr): bool =
macro `=~` (n: Formula, pattern: untyped): bool =
result = matchAgainst(n, pattern)
proc isPolyTerm2(n: Formula): bool = n =~ c * x^c

View file

@ -10,7 +10,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] == '$':
@ -29,11 +29,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)
let f = f.strVal
formatImpl(newLit)

View file

@ -2,7 +2,7 @@ discard """
output: "<br>"
"""
template htmlTag(tag: expr) {.immediate.} =
template htmlTag(tag: untyped) =
proc tag(): string = "<" & astToStr(tag) & ">"
htmlTag(br)

View file

@ -4,20 +4,20 @@ discard """
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: untyped) =
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

View file

@ -5,7 +5,7 @@ new instantiation
some call of p'''
"""
template once(body: stmt) =
template once(body) =
var x {.global.} = false
if not x:
x = true

View file

@ -4,7 +4,7 @@ discard """
import macros
macro check(ex: expr): stmt =
macro check(ex: untyped): untyped =
var info = ex.lineInfo
var expString = ex.toStrLit
result = quote do: