13 // output "s2:{s2:{s0 s0} x}";
14 // output "s2:{s0 x}";
24 output "1:{{a b} {c}}";
27 ids ::= id (" " ids &~ id [~]*) => "1"
28 | id ( ids &~ id [~]*) => "2"
36 output "2:{{a} 1:{{b} {c}}}";
37 output "1:{{a b} {c}}";
40 ids ::= id " " ids => "1"
73 output "ac:{{2 1 2 1}}";
74 //output "a:{{2 1 2 1}}";
75 //output "c:{{c:{1 1} c:{1 1}}}";
88 c ::= (x "2" x "1" => "c")*
94 output "bam:{a bam:{a bam:{a x}}}";
103 output "s2:{b0 a:{a:{epsilon}}}";
104 output "b:{a:{a:{epsilon}} epsilon}";
115 output "q:{a:{s1:{epsilon}}}";
119 x ::= () => "epsilon"
125 output "s1:{a2:{a2:{a0 b0} b0}}";
128 a ::= "a" a b => "a2"
136 output "s3:{s3:{epsilon a0 epsilon epsilon} epsilon epsilon epsilon}";
137 output "s3:{s3:{epsilon epsilon epsilon epsilon} a0 epsilon epsilon}";
138 output "s3:{s3:{epsilon epsilon a0 epsilon} epsilon epsilon epsilon}";
139 output "s3:{s3:{epsilon epsilon epsilon a0} epsilon epsilon epsilon}";
140 output "s3:{epsilon epsilon a0 a0}";
141 output "s3:{s3:{s3:{epsilon epsilon epsilon epsilon} epsilon epsilon epsilon} epsilon epsilon epsilon}";
142 output "s3:{s3:{epsilon epsilon epsilon epsilon} epsilon epsilon a0}";
143 output "s3:{s3:{epsilon epsilon epsilon epsilon} epsilon a0 epsilon}";
144 output "s3:{epsilon a0 epsilon a0}";
145 output "s3:{epsilon a0 a0 epsilon}";
147 s ::= "a" s a a a => "s3"
155 output "poo:{poo:{poox poox} poox}";
156 output "poo:{poox poo:{poox poox}}";
157 s ::= s s "a" => "poo"
163 output "s:{aa:{aa:{a b} b}}";
165 a ::= "a" a b => "aa"
172 output "sx:{b aa:{aa:{b b} b}}";
173 s ::= b d "a" "b" => "sx"
174 s ::= "a" d "a" d => "sy"
175 d ::= "a" a b => "aa"
176 a ::= "a" b b => "aa"
183 output "+:{{a} *:{{b} {c}}}";
195 output "plus:{stringify:{{a}} minus:{stringify:{{b}} times:{stringify:{{d}} stringify:{{c}}}}}";
196 output "times:{plus:{stringify:{{a}} minus:{stringify:{{b}} stringify:{{d}}}} stringify:{{c}}}";
197 output "plus:{stringify:{{a}} times:{minus:{stringify:{{b}} stringify:{{d}}} stringify:{{c}}}}";
198 output "times:{minus:{plus:{stringify:{{a}} stringify:{{b}}} stringify:{{d}}} stringify:{{c}}}";
199 output "minus:{plus:{stringify:{{a}} stringify:{{b}}} times:{stringify:{{d}} stringify:{{c}}}}";
203 S ::= L "=" Q => "assign"
206 | L "=" Q => "assign"
211 id ::= idl++ => "stringify"
217 output "times:{stringify:{{a}} times:{stringify:{{b}} stringify:{{c}}}}";
221 S ::= L "=" R => "assign"
224 | L "=" R => "assign"
226 | (R) "*" R => "times"
229 id ::= idl++ => "stringify"
235 output "plus:{stringify:{{a}} times:{stringify:{{b}} stringify:{{c}}}}";
239 S ::= L "=" R => "assign"
242 | L "=" R => "assign"
247 id ::= idl++ => "stringify"
268 output "smt:{while:{>:{{x} {0}} while:{>:{{y} {0}} sbb:{{f o o} {b a r}}}}}";
269 output "smt:{while:{>:{{x} {0}} sbb:{while:{>:{{y} {0}} {f o o}} {b a r}}}}";
272 outdent !::= " " outdent " "
276 s ::= !any "\n\n" !ww Statement !ww "\n\n" !any => smt
280 block ::= "\n" !indent BlockBody
281 &~ "\n" outdent [~\ ] [~]*
283 BlockBody ::= Statement
284 > Statement BlockBody => "sbb"
287 | ^"while" Expr block
298 ident ::= [a-z]++ &~ keyword
299 keyword ::= "if" | "then" | "else" | "while"
301 w ::= " " | "\n" | "\r"