1/* 2 * @LANG: indep 3 */ 4 5char comm; 6int top; 7int stack[32]; 8ptr ts; 9ptr te; 10int act; 11int 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 te-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 te-1; fgoto other;}; 28 [0-9]+ ' foil' => {prints "num (c/switch)\n"; }; 29 '!';# => { prints "immdiate\n"; fgoto exec_test; }; 30 *|; 31 32 semi := |* 33 ';' => { prints "in semi\n"; fgoto main; }; 34 *|; 35 36 main := |* 37 [a-z]+ => { prints "word (w/lbh)\n"; fhold; fgoto other; }; 38 [a-z]+ ' foil' => { prints "word (c/lbh)\n"; }; 39 [\n ] => { prints "space\n"; }; 40 '22' => { prints "num (w/switch)\n"; }; 41 [0-9]+ => { prints "num (w/switch)\n"; fhold; fgoto other;}; 42 [0-9]+ ' foil' => {prints "num (c/switch)\n"; }; 43 ';' => { prints "going to semi\n"; fhold; fgoto semi;}; 44 '!' => { prints "immdiate\n"; fgoto exec_test; }; 45 *|; 46}%% 47/* _____INPUT_____ 48"abcd foix\n" 49"abcd\nanother\n" 50"123 foix\n" 51"!abcd foix\n" 52"!abcd\nanother\n" 53"!123 foix\n" 54";" 55_____INPUT_____ */ 56/* _____OUTPUT_____ 57word (w/lbh) 58word 59space 60word 61space 62ACCEPT 63word (w/lbh) 64word 65space 66word 67space 68ACCEPT 69num (w/switch) 70num 71space 72word 73space 74ACCEPT 75immdiate 76word (w/lbh) 77word 78space 79word 80space 81ACCEPT 82immdiate 83word (w/lbh) 84word 85space 86word 87space 88ACCEPT 89immdiate 90num (w/switch) 91num 92space 93word 94space 95ACCEPT 96going to semi 97in semi 98ACCEPT 99_____OUTPUT_____ */ 100 101