13 // output "s2:{s2:{s0 s0} x}";
14 // output "s2:{s0 x}";
32 s ::= { Hello } => "yep"
35 Hello ::= "hello" ws { "there" "how" { "are" } }
41 output "1:{{a b} {c}}";
44 ids ::= id (" " ids &~ id ~[]*) => "1"
45 | id ( ids &~ id ~[]*) => "2"
53 output "2:{{a} 1:{{b} {c}}}";
54 output "1:{{a b} {c}}";
57 ids ::= id " " ids => "1"
90 output "ac:{{2 1 2 1}}";
91 //output "a:{{2 1 2 1}}";
92 //output "c:{{c:{1 1} c:{1 1}}}";
104 b ::= (x "2" => "b")*
105 c ::= (x "2" x "1" => "c")*
111 output "bam:{a bam:{a bam:{a x:{x}}}}";
121 output "s2:{b0 a:{a:{epsilon}}}";
122 output "b:{a:{a:{epsilon}} epsilon}";
133 output "q:{a:{s1:{epsilon}}}";
137 x ::= () => "epsilon"
143 output "s1:{a2:{a2:{a0 b0} b0}}";
146 a ::= "a" a b => "a2"
154 output "s3:{s3:{epsilon a0 epsilon epsilon} epsilon epsilon epsilon}";
155 output "s3:{s3:{epsilon epsilon epsilon epsilon} a0 epsilon epsilon}";
156 output "s3:{s3:{epsilon epsilon a0 epsilon} epsilon epsilon epsilon}";
157 output "s3:{s3:{epsilon epsilon epsilon a0} epsilon epsilon epsilon}";
158 output "s3:{epsilon epsilon a0 a0}";
159 output "s3:{s3:{s3:{epsilon epsilon epsilon epsilon} epsilon epsilon epsilon} epsilon epsilon epsilon}";
160 output "s3:{s3:{epsilon epsilon epsilon epsilon} epsilon epsilon a0}";
161 output "s3:{s3:{epsilon epsilon epsilon epsilon} epsilon a0 epsilon}";
162 output "s3:{epsilon a0 epsilon a0}";
163 output "s3:{epsilon a0 a0 epsilon}";
165 s ::= "a" s a a a => "s3"
173 output "poo:{poo:{poox poox} poox}";
174 output "poo:{poox poo:{poox poox}}";
175 s ::= s s "a" => "poo"
181 output "s:{aa:{aa:{a b} b}}";
183 a ::= "a" a b => "aa"
190 output "sx:{b aa:{aa:{b b} b}}";
191 s ::= b d "a" "b" => "sx"
192 s ::= "a" d "a" d => "sy"
193 d ::= "a" a b => "aa"
194 a ::= "a" b b => "aa"
201 output "+:{{a} *:{{b} {c}}}";
213 output "plus:{stringify:{{a}} minus:{stringify:{{b}} times:{stringify:{{d}} stringify:{{c}}}}}";
214 output "times:{plus:{stringify:{{a}} minus:{stringify:{{b}} stringify:{{d}}}} stringify:{{c}}}";
215 output "plus:{stringify:{{a}} times:{minus:{stringify:{{b}} stringify:{{d}}} stringify:{{c}}}}";
216 output "times:{minus:{plus:{stringify:{{a}} stringify:{{b}}} stringify:{{d}}} stringify:{{c}}}";
217 output "minus:{plus:{stringify:{{a}} stringify:{{b}}} times:{stringify:{{d}} stringify:{{c}}}}";
220 s ::= l "=" q => "assign"
223 | l "=" q => "assign"
228 id ::= idl++ => "stringify"
234 output "times:{stringify:{{a}} times:{stringify:{{b}} stringify:{{c}}}}";
237 s ::= l "=" r => "assign"
240 | l "=" r => "assign"
242 | (r) "*" r => "times"
245 id ::= idl++ => "stringify"
251 output "plus:{stringify:{{a}} times:{stringify:{{b}} stringify:{{c}}}}";
254 s ::= l "=" r => "assign"
257 | l "=" r => "assign"
262 id ::= idl++ => "stringify"
283 output "smt:{while:{>:{{x} {0}} while:{>:{{y} {0}} sbb:{{f o o} {b a r}}}}}";
284 output "smt:{while:{>:{{x} {0}} sbb:{while:{>:{{y} {0}} {f o o}} {b a r}}}}";
287 outdent !::= " " outdent " "
291 s ::= any "\n\n" ww statement ww "\n\n" any => smt
296 block ::= "\n" indent blockBody
297 &~ "\n" outdent ~[\ ] ~[]*
299 blockBody ::= statement
300 > statement blockBody /ws => "sbb"
303 | ^"while" expr block /ws
310 call ::= expr "()" /ws
314 ident ::= [a-z]++ &~ keyword
315 keyword ::= "if" | "then" | "else" | "while"
317 w ::= " " | "\n" | "\r"
325 output "{q:{{a a}} q:{{b b}}}";