From e51389d68ef2e152054d987d7a99930bce180954 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 23 Mar 2010 17:35:53 -0400 Subject: Implement macro support. --- tests/dimension/directives.pov | 22 +++++++++++++++------- tests/dimension/directives.sh | 20 +++++++++++++------- 2 files changed, 28 insertions(+), 14 deletions(-) (limited to 'tests') diff --git a/tests/dimension/directives.pov b/tests/dimension/directives.pov index 416bbf5..e4721fc 100644 --- a/tests/dimension/directives.pov +++ b/tests/dimension/directives.pov @@ -40,18 +40,26 @@ #error "#undef failed" #end +#macro Make_Sphere(n) + sphere { + Center + <0, n, 0>, R + pigment { + color Color green 1 + } + } +#end + +#macro Inc(n) + #declare n = n + 1; +#end + #declare Counter = 0; #while (Counter < 2) #if (#if (1 = 1) 0 #end = 0 & !1) #error "Nested #if parsing failed" #else - sphere { - Center + <0, Counter, 0>, R - pigment { - color Color green 1 - } - } + Make_Sphere(Counter) #end - #declare Counter = Counter + 1; + Inc(Counter) #end diff --git a/tests/dimension/directives.sh b/tests/dimension/directives.sh index 42815a6..713a1fe 100755 --- a/tests/dimension/directives.sh +++ b/tests/dimension/directives.sh @@ -35,19 +35,25 @@ directives_exp="$(echo -n \ #ifdef \( (identifier "Unused") \) #error (string "#undef failed") #end + #macro (identifier "Make_Sphere") \( (identifier "n") \) + sphere { + (identifier "Center") + < (integer "0") , (identifier "n") , (integer "0") > , (identifier "R") + pigment { + color (identifier "Color") green (integer "1") + } + } + #end + #macro (identifier "Inc") \( (identifier "n") \) + #declare (identifier "n") = (identifier "n") + (integer "1") ; + #end #declare (identifier "Counter") = (integer "0") ; #while \( (identifier "Counter") < (integer "2") \) #if \( #if \( (integer "1") = (integer "1") \) (integer "0") #end = (integer "0") & ! (integer "1") \) #error (string "Nested #if parsing failed") #else - sphere { - (identifier "Center") + < (integer "0") , (identifier "Counter") , (integer "0") > , (identifier "R") - pigment { - color (identifier "Color") green (integer "1") - } - } + (identifier "Make_Sphere") \( (identifier "Counter") \) #end - #declare (identifier "Counter") = (identifier "Counter") + (integer "1") ; + (identifier "Inc") \( (identifier "Counter") \) #end)' \ | tr '\n' ' ' | sed -r 's/[[:space:]]+/ /g') $(echo -n \ -- cgit v1.2.3