From 2e15c0fd5067318601e2f3b70ee6fc16ef58200d Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 27 May 2018 18:28:23 -0700 Subject: Some tweaks/cleanup on the nomsu code as well as adding variable mangling to 'parse % as %' to make almost hygienic macros. --- tests/metaprogramming.nom | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'tests/metaprogramming.nom') 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" -- cgit v1.2.3