tr macros now documented

This commit is contained in:
Araq 2012-09-10 19:34:16 +02:00
commit 92b449562e
14 changed files with 332 additions and 18 deletions

View file

@ -12,11 +12,12 @@ proc `*`(a, b: TMat): TMat = nil
proc `+`(a, b: TMat): TMat = nil
proc `-`(a, b: TMat): TMat = nil
proc `$`(a: TMat): string = result = $a.dummy
proc mat32(): TMat =
proc mat21(): TMat =
result.dummy = 21
macro optOps{ (`+`|`-`|`*`) *| a }(a: TMat): expr =
result = newCall(bindSym"mat32")
macro optOps{ (`+`|`-`|`*`) ** a }(a: TMat): expr =
echo treeRepr(a)
result = newCall(bindSym"mat21")
#macro optPlus{ `+` * a }(a: varargs[TMat]): expr =
# result = newIntLitNode(21)

View file

@ -7,3 +7,14 @@ template testOr{ (arithOps{f})(a, b) }(a, b, f: expr): expr = f(a+1, b)
let xx = 10
echo 10*xx
template t{x = (~x){y} and (~x){z}}(x, y, z: bool): stmt =
x = y
if x: x = z
var
a = true
b = true
c = false
a = b and a
echo a

View file

@ -10,7 +10,7 @@ proc `&&`(s: varargs[string]): string =
for i in 1..len(s)-1: result.add s[i]
inc calls
template optConc{ `&&` * a }(a: varargs[string]): expr = &&a
template optConc{ `&&` * a }(a: string): expr = &&a
let space = " "
echo "my" && (space & "awe" && "some " ) && "concat"