c15d93d75b326a041f5a44dafaec204de01fc9ff
[external/ragel.git] / test / patact.rl
1 /*
2  * @LANG: indep
3  */
4
5 char comm;
6 int top;
7 int stack[32];
8 ptr tokstart;
9 ptr tokend;
10 int act;
11 int val;
12 %%
13 %%{
14         machine patact;
15
16         other := |* 
17                 [a-z]+ => { prints "word\n"; };
18                 [0-9]+ => { prints "num\n"; };
19                 [\n ] => { prints "space\n"; };
20         *|;
21
22         exec_test := |* 
23                 [a-z]+ => { prints "word (w/lbh)\n"; fexec tokend-1; fgoto other; };
24                 [a-z]+ ' foil' => { prints "word (c/lbh)\n"; };
25                 [\n ] => { prints "space\n"; };
26                 '22' => { prints "num (w/switch)\n"; };
27                 [0-9]+ => { prints "num (w/switch)\n"; fexec tokend-1; fgoto other;};
28                 [0-9]+ ' foil' => {prints "num (c/switch)\n"; };
29                 '!';# => { prints "immdiate\n"; fgoto exec_test; };
30         *|;
31
32         main := |* 
33                 [a-z]+ => { prints "word (w/lbh)\n"; fhold; fgoto other; };
34                 [a-z]+ ' foil' => { prints "word (c/lbh)\n"; };
35                 [\n ] => { prints "space\n"; };
36                 '22' => { prints "num (w/switch)\n"; };
37                 [0-9]+ => { prints "num (w/switch)\n"; fhold; fgoto other;};
38                 [0-9]+ ' foil' => {prints "num (c/switch)\n"; };
39                 '!' => { prints "immdiate\n"; fgoto exec_test; };
40         *|;
41 }%%
42 /* _____INPUT_____
43 "abcd foix\n"
44 "abcd\nanother\n"
45 "123 foix\n"
46 "!abcd foix\n"
47 "!abcd\nanother\n"
48 "!123 foix\n"
49 _____INPUT_____ */
50 /* _____OUTPUT_____
51 word (w/lbh)
52 word
53 space
54 word
55 space
56 ACCEPT
57 word (w/lbh)
58 word
59 space
60 word
61 space
62 ACCEPT
63 num (w/switch)
64 num
65 space
66 word
67 space
68 ACCEPT
69 immdiate
70 word (w/lbh)
71 word
72 space
73 word
74 space
75 ACCEPT
76 immdiate
77 word (w/lbh)
78 word
79 space
80 word
81 space
82 ACCEPT
83 immdiate
84 num (w/switch)
85 num
86 space
87 word
88 space
89 ACCEPT
90 _____OUTPUT_____ */
91