summaryrefslogtreecommitdiff
path: root/test/trans.d/case/patact.rl
diff options
context:
space:
mode:
Diffstat (limited to 'test/trans.d/case/patact.rl')
-rw-r--r--test/trans.d/case/patact.rl99
1 files changed, 99 insertions, 0 deletions
diff --git a/test/trans.d/case/patact.rl b/test/trans.d/case/patact.rl
new file mode 100644
index 00000000..1e16c63a
--- /dev/null
+++ b/test/trans.d/case/patact.rl
@@ -0,0 +1,99 @@
+/*
+ * @LANG: indep
+ * @NEEDS_EOF: yes
+ */
+
+char comm;
+int top;
+int stack[32];
+ptr ts;
+ptr te;
+int act;
+int value;
+
+%%{
+ machine patact;
+
+ other := |*
+ [a-z]+ => { print_str "word\n"; };
+ [0-9]+ => { print_str "num\n"; };
+ [\n ] => { print_str "space\n"; };
+ *|;
+
+ exec_test := |*
+ [a-z]+ => { print_str "word (w/lbh)\n"; fexec te-1; fgoto other; };
+ [a-z]+ ' foil' => { print_str "word (c/lbh)\n"; };
+ [\n ] => { print_str "space\n"; };
+ '22' => { print_str "num (w/switch)\n"; };
+ [0-9]+ => { print_str "num (w/switch)\n"; fexec te-1; fgoto other;};
+ [0-9]+ ' foil' => {print_str "num (c/switch)\n"; };
+ '!';# => { print_str "immdiate\n"; fgoto exec_test; };
+ *|;
+
+ semi := |*
+ ';' => { print_str "in semi\n"; fgoto main; };
+ *|;
+
+ main := |*
+ [a-z]+ => { print_str "word (w/lbh)\n"; fhold; fgoto other; };
+ [a-z]+ ' foil' => { print_str "word (c/lbh)\n"; };
+ [\n ] => { print_str "space\n"; };
+ '22' => { print_str "num (w/switch)\n"; };
+ [0-9]+ => { print_str "num (w/switch)\n"; fhold; fgoto other;};
+ [0-9]+ ' foil' => {print_str "num (c/switch)\n"; };
+ ';' => { print_str "going to semi\n"; fhold; fgoto semi;};
+ '!' => { print_str "immdiate\n"; fgoto exec_test; };
+ *|;
+}%%
+
+##### INPUT #####
+"abcd foix\n"
+"abcd\nanother\n"
+"123 foix\n"
+"!abcd foix\n"
+"!abcd\nanother\n"
+"!123 foix\n"
+";"
+##### OUTPUT #####
+word (w/lbh)
+word
+space
+word
+space
+ACCEPT
+word (w/lbh)
+word
+space
+word
+space
+ACCEPT
+num (w/switch)
+num
+space
+word
+space
+ACCEPT
+immdiate
+word (w/lbh)
+word
+space
+word
+space
+ACCEPT
+immdiate
+word (w/lbh)
+word
+space
+word
+space
+ACCEPT
+immdiate
+num (w/switch)
+num
+space
+word
+space
+ACCEPT
+going to semi
+in semi
+ACCEPT