aboutsummaryrefslogtreecommitdiff
path: root/tests/metaprogramming.nom
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-05-27 18:28:23 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-05-27 18:29:23 -0700
commit2e15c0fd5067318601e2f3b70ee6fc16ef58200d (patch)
tree0006e0825b2680d457bb531c3d079661b16d6bc8 /tests/metaprogramming.nom
parent6ce32bdd25694d71dc232c50a008f8824f8a75ce (diff)
Some tweaks/cleanup on the nomsu code as well as adding variable
mangling to 'parse % as %' to make almost hygienic macros.
Diffstat (limited to 'tests/metaprogramming.nom')
-rw-r--r--tests/metaprogramming.nom15
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/metaprogramming.nom b/tests/metaprogramming.nom
index 9a4c9b2..26a750a 100644
--- a/tests/metaprogramming.nom
+++ b/tests/metaprogramming.nom
@@ -36,7 +36,20 @@ immediately
parse [V] as: five
assume ((V) = 5) or barf "Parse as compile action failed."
-remove action "foo %"
+immediately
+ parse [swap %x and %y] as
+ do
+ %tmp <- %x
+ %x <- %y
+ %y <- %tmp
+<- {%1:1, %2:2}
+swap %1 and %2
+assume ((%1 = 2) and (%2 = 1)) or barf "'parse % as %' failed on 'swap % and %'"
+<- {%tmp:1, %tmp2:2}
+swap %tmp and %tmp2
+assume ((%tmp = 2) and (%tmp2 = 1)) or barf "'parse % as %' variable mangling failed."
+
+remove action (foo %)
try: foo 99
..and if it succeeds: barf "Failed to delete action"