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 GotoCallRet;
15
16	sp = ' ';
17
18	handle := any @{
19		prints "handle ";
20		fhold;
21		if ( val == 1 ) fnext *fentry(one);
22		if ( val == 2 ) fnext *fentry(two);
23		if ( val == 3 ) fnext main;
24	};
25
26	one := |*
27		'{' => { prints "{ "; fcall *fentry(one); };
28		"[" => { prints "[ "; fcall *fentry(two); };
29		"}" sp* => { prints "} "; fret; };
30		[a-z]+ => { prints "word "; val = 1; fgoto *fentry(handle); };
31		' ' => { prints "space "; };
32	*|;
33
34	two := |*
35		'{' => { prints "{ "; fcall *fentry(one); };
36		"[" => { prints "[ "; fcall *fentry(two); };
37		']' sp* => { prints "] "; fret; };
38		[a-z]+ => { prints "word "; val = 2; fgoto *fentry(handle); };
39		' ' => { prints "space "; };
40	*|;
41
42	main := |*
43		'{' => { prints "{ "; fcall one; };
44		"[" => { prints "[ "; fcall two; };
45		[a-z]+ => { prints "word "; val = 3; fgoto handle; };
46		[a-z] ' foil' => { prints "this is the foil";};
47		' ' => { prints "space "; };
48		'\n';
49	*|;
50}%%
51/* _____INPUT_____
52"{a{b[c d]d}c}\n"
53"[a{b[c d]d}c}\n"
54"[a[b]c]d{ef{g{h}i}j}l\n"
55"{{[]}}\n"
56"a b c\n"
57"{a b c}\n"
58"[a b c]\n"
59"{]\n"
60"{{}\n"
61"[[[[[[]]]]]]\n"
62"[[[[[[]]}]]]\n"
63_____INPUT_____ */
64/* _____OUTPUT_____
65{ word handle { word handle [ word handle space word handle ] word handle } word handle } ACCEPT
66[ word handle { word handle [ word handle space word handle ] word handle } word handle FAIL
67[ word handle [ word handle ] word handle ] word handle { word handle { word handle { word handle } word handle } word handle } word handle ACCEPT
68{ { [ ] } } ACCEPT
69word handle space word handle space word handle ACCEPT
70{ word handle space word handle space word handle } ACCEPT
71[ word handle space word handle space word handle ] ACCEPT
72{ FAIL
73{ { } FAIL
74[ [ [ [ [ [ ] ] ] ] ] ] ACCEPT
75[ [ [ [ [ [ ] ] FAIL
76_____OUTPUT_____ */
77
78