13 // output "s2:{s2:{s0 s0} x}";
14 // output "s2:{s0 x}";
32 s ::= { Hello } => "yep"
35 Hello ::= "hello" ws { ws "there" ws "how" ws { { "are" } ws } }
40 output "1:{{a b} {c}}";
43 ids ::= id (" " ids &~ id [~]*) => "1"
44 | id ( ids &~ id [~]*) => "2"
52 output "2:{{a} 1:{{b} {c}}}";
53 output "1:{{a b} {c}}";
56 ids ::= id " " ids => "1"
89 output "ac:{{2 1 2 1}}";
90 //output "a:{{2 1 2 1}}";
91 //output "c:{{c:{1 1} c:{1 1}}}";
103 b ::= (x "2" => "b")*
104 c ::= (x "2" x "1" => "c")*
110 output "bam:{a bam:{a bam:{a x}}}";
119 output "s2:{b0 a:{a:{epsilon}}}";
120 output "b:{a:{a:{epsilon}} epsilon}";
131 output "q:{a:{s1:{epsilon}}}";
135 x ::= () => "epsilon"
141 output "s1:{a2:{a2:{a0 b0} b0}}";
144 a ::= "a" a b => "a2"
152 output "s3:{s3:{epsilon a0 epsilon epsilon} epsilon epsilon epsilon}";
153 output "s3:{s3:{epsilon epsilon epsilon epsilon} a0 epsilon epsilon}";
154 output "s3:{s3:{epsilon epsilon a0 epsilon} epsilon epsilon epsilon}";
155 output "s3:{s3:{epsilon epsilon epsilon a0} epsilon epsilon epsilon}";
156 output "s3:{epsilon epsilon a0 a0}";
157 output "s3:{s3:{s3:{epsilon epsilon epsilon epsilon} epsilon epsilon epsilon} epsilon epsilon epsilon}";
158 output "s3:{s3:{epsilon epsilon epsilon epsilon} epsilon epsilon a0}";
159 output "s3:{s3:{epsilon epsilon epsilon epsilon} epsilon a0 epsilon}";
160 output "s3:{epsilon a0 epsilon a0}";
161 output "s3:{epsilon a0 a0 epsilon}";
163 s ::= "a" s a a a => "s3"
171 output "poo:{poo:{poox poox} poox}";
172 output "poo:{poox poo:{poox poox}}";
173 s ::= s s "a" => "poo"
179 output "s:{aa:{aa:{a b} b}}";
181 a ::= "a" a b => "aa"
188 output "sx:{b aa:{aa:{b b} b}}";
189 s ::= b d "a" "b" => "sx"
190 s ::= "a" d "a" d => "sy"
191 d ::= "a" a b => "aa"
192 a ::= "a" b b => "aa"
199 output "+:{{a} *:{{b} {c}}}";
211 output "plus:{stringify:{{a}} minus:{stringify:{{b}} times:{stringify:{{d}} stringify:{{c}}}}}";
212 output "times:{plus:{stringify:{{a}} minus:{stringify:{{b}} stringify:{{d}}}} stringify:{{c}}}";
213 output "plus:{stringify:{{a}} times:{minus:{stringify:{{b}} stringify:{{d}}} stringify:{{c}}}}";
214 output "times:{minus:{plus:{stringify:{{a}} stringify:{{b}}} stringify:{{d}}} stringify:{{c}}}";
215 output "minus:{plus:{stringify:{{a}} stringify:{{b}}} times:{stringify:{{d}} stringify:{{c}}}}";
218 s ::= l "=" q => "assign"
221 | l "=" q => "assign"
226 id ::= idl++ => "stringify"
232 output "times:{stringify:{{a}} times:{stringify:{{b}} stringify:{{c}}}}";
235 s ::= l "=" r => "assign"
238 | l "=" r => "assign"
240 | (r) "*" r => "times"
243 id ::= idl++ => "stringify"
249 output "plus:{stringify:{{a}} times:{stringify:{{b}} stringify:{{c}}}}";
252 s ::= l "=" r => "assign"
255 | l "=" r => "assign"
260 id ::= idl++ => "stringify"
281 output "smt:{while:{>:{{x} {0}} while:{>:{{y} {0}} sbb:{{f o o} {b a r}}}}}";
282 output "smt:{while:{>:{{x} {0}} sbb:{while:{>:{{y} {0}} {f o o}} {b a r}}}}";
285 outdent !::= " " outdent " "
289 s ::= any "\n\n" ww statement ww "\n\n" any => smt
294 block ::= "\n" indent blockBody
295 &~ "\n" outdent [~\ ] [~]*
297 blockBody ::= statement
298 > statement blockBody /ws => "sbb"
301 | ^"while" expr block /ws
308 call ::= expr "()" /ws
312 ident ::= [a-z]++ &~ keyword
313 keyword ::= "if" | "then" | "else" | "while"
315 w ::= " " | "\n" | "\r"