13 // output "s2:{s2:{s0 s0} x}";
14 // output "s2:{s0 x}";
40 output "1:{{a b} {c}}";
43 ids = "1":: id (" " ids &~ id ((~[])*)!)
44 | "2":: id ( ids &~ id ((~[])*)!)
52 output "2:{{a} 1:{{b} {c}}}";
53 output "1:{{a b} {c}}";
56 ids = "1":: id " " ids
89 output "xbx:{{a} abab:{a b} {b}}";
99 output "bam:{a bam:{a bam:{a x}}}";
109 output "s2:{b0 a:{a:{epsilon}}}";
110 output "b:{a:{a:{epsilon}} epsilon}";
121 output "q:{a:{s1:{epsilon}}}";
131 output "s1:{a2:{a2:{a0 b0} b0}}";
142 output "s3:{s3:{epsilon a0 epsilon epsilon} epsilon epsilon epsilon}";
143 output "s3:{s3:{epsilon epsilon epsilon epsilon} a0 epsilon epsilon}";
144 output "s3:{s3:{epsilon epsilon a0 epsilon} epsilon epsilon epsilon}";
145 output "s3:{s3:{epsilon epsilon epsilon a0} epsilon epsilon epsilon}";
146 output "s3:{epsilon epsilon a0 a0}";
147 output "s3:{s3:{s3:{epsilon epsilon epsilon epsilon} epsilon epsilon epsilon} epsilon epsilon epsilon}";
148 output "s3:{s3:{epsilon epsilon epsilon epsilon} epsilon epsilon a0}";
149 output "s3:{s3:{epsilon epsilon epsilon epsilon} epsilon a0 epsilon}";
150 output "s3:{epsilon a0 epsilon a0}";
151 output "s3:{epsilon a0 a0 epsilon}";
161 output "poo:{poo:{poox poox} poox}";
162 output "poo:{poox poo:{poox poox}}";
169 output "s:{aa:{aa:{a b} b}}";
178 output "sx:{b aa:{aa:{b b} b}}";
189 output "+:{{a} *:{{b} {c}}}";
201 output "plus:{stringify:{{a}} minus:{stringify:{{b}} times:{stringify:{{d}} stringify:{{c}}}}}";
202 output "times:{plus:{stringify:{{a}} minus:{stringify:{{b}} stringify:{{d}}}} stringify:{{c}}}";
203 output "plus:{stringify:{{a}} times:{minus:{stringify:{{b}} stringify:{{d}}} stringify:{{c}}}}";
204 output "times:{minus:{plus:{stringify:{{a}} stringify:{{b}}} stringify:{{d}}} stringify:{{c}}}";
205 output "minus:{plus:{stringify:{{a}} stringify:{{b}}} times:{stringify:{{d}} stringify:{{c}}}}";
216 id = stringify:: idl++
222 // output "times:{stringify:{{a}} times:{stringify:{{b}} stringify:{{c}}}}";
225 // s = l "=" r => "assign"
228 // | l "=" r => "assign"
229 // | r "+" r => "plus"
230 // | (r) "*" r => "times"
233 // id = idl++ => "stringify"
239 output "plus:{stringify:{{a}} times:{stringify:{{b}} stringify:{{c}}}}";
250 id = stringify:: idl++
256 output "{q:{{a a}} q:{{b b}}}";
283 output "smt:{while:{>:{{x} {0}} while:{>:{{y} {0}} sbb:{{f o o} {b a r}}}} while:{>:{{x} {0}} sbb:{while:{>:{{y} {0}} {f o o}} {b a r}}}}";
286 outdent = " " outdent " "
289 w = " " | "\n" | "\r"
295 s = smt:: ws! statement ws! statement ws!
297 block = "\n"! indent! blockBody
298 &~ "\n"! (" " outdent! " ") (~[\ ])! ((~[])*)!
300 blockBody = statement
301 > sbb:: statement ws blockBody
304 | ^"while" expr block /ws
315 ident = [a-z]++ &~ keyword
316 keyword = "if" | "then" | "else" | "while"
328 q = a3:: [a-z] [a-z] [a-z]
329 &~ (~[])! "b" ((~[])*)!
336 s = s:: [a-z] [a-z] [a-z] " "*
342 output "Plus:{left:{Foo} right:{{2}}}";
346 | Plus:: (left::Expra) "+" (right::Expr)
347 Expra = Foo:: ("a" | "b")
353 output "top:{a q:{{a a a}} a}";
355 s = top:: z (q::"a"*) z
360 input "if (x) if (y) z else q";
361 output "if:{ident:{{x}} else:{if:{ident:{{y}} then:{ident:{{z}}}} ident:{{q}}}}";
364 Expr = if:: "if" "(" Expr ")" IfBody /ws
366 IfBody = else:: Expr "else" Expr /ws
367 | then:: Expr &~ ((~[])* "else" Expr! /ws)
374 output "ac:{{2 1 2 1}}";
375 //output "a:{{2 1 2 1}}";
376 //output "c:{{c:{1 1} c:{1 1}}}";
389 c = ("c":: x "2" x "1")*