13 // output "s2:{s2:{s0 s0} x}";
14 // output "s2:{s0 x}";
34 Hello ::= "hello" ws { "there" ws "how" ws { { "are" } ws } }
39 output "1:{{a b} {c}}";
42 ids ::= id (" " ids &~ id [~]*) => "1"
43 | id ( ids &~ id [~]*) => "2"
51 output "2:{{a} 1:{{b} {c}}}";
52 output "1:{{a b} {c}}";
55 ids ::= id " " ids => "1"
88 output "ac:{{2 1 2 1}}";
89 //output "a:{{2 1 2 1}}";
90 //output "c:{{c:{1 1} c:{1 1}}}";
102 b ::= (x "2" => "b")*
103 c ::= (x "2" x "1" => "c")*
109 output "bam:{a bam:{a bam:{a x}}}";
118 output "s2:{b0 a:{a:{epsilon}}}";
119 output "b:{a:{a:{epsilon}} epsilon}";
130 output "q:{a:{s1:{epsilon}}}";
134 x ::= () => "epsilon"
140 output "s1:{a2:{a2:{a0 b0} b0}}";
143 a ::= "a" a b => "a2"
151 output "s3:{s3:{epsilon a0 epsilon epsilon} epsilon epsilon epsilon}";
152 output "s3:{s3:{epsilon epsilon epsilon epsilon} a0 epsilon epsilon}";
153 output "s3:{s3:{epsilon epsilon a0 epsilon} epsilon epsilon epsilon}";
154 output "s3:{s3:{epsilon epsilon epsilon a0} epsilon epsilon epsilon}";
155 output "s3:{epsilon epsilon a0 a0}";
156 output "s3:{s3:{s3:{epsilon epsilon epsilon epsilon} epsilon epsilon epsilon} epsilon epsilon epsilon}";
157 output "s3:{s3:{epsilon epsilon epsilon epsilon} epsilon epsilon a0}";
158 output "s3:{s3:{epsilon epsilon epsilon epsilon} epsilon a0 epsilon}";
159 output "s3:{epsilon a0 epsilon a0}";
160 output "s3:{epsilon a0 a0 epsilon}";
162 s ::= "a" s a a a => "s3"
170 output "poo:{poo:{poox poox} poox}";
171 output "poo:{poox poo:{poox poox}}";
172 s ::= s s "a" => "poo"
178 output "s:{aa:{aa:{a b} b}}";
180 a ::= "a" a b => "aa"
187 output "sx:{b aa:{aa:{b b} b}}";
188 s ::= b d "a" "b" => "sx"
189 s ::= "a" d "a" d => "sy"
190 d ::= "a" a b => "aa"
191 a ::= "a" b b => "aa"
198 output "+:{{a} *:{{b} {c}}}";
210 output "plus:{stringify:{{a}} minus:{stringify:{{b}} times:{stringify:{{d}} stringify:{{c}}}}}";
211 output "times:{plus:{stringify:{{a}} minus:{stringify:{{b}} stringify:{{d}}}} stringify:{{c}}}";
212 output "plus:{stringify:{{a}} times:{minus:{stringify:{{b}} stringify:{{d}}} stringify:{{c}}}}";
213 output "times:{minus:{plus:{stringify:{{a}} stringify:{{b}}} stringify:{{d}}} stringify:{{c}}}";
214 output "minus:{plus:{stringify:{{a}} stringify:{{b}}} times:{stringify:{{d}} stringify:{{c}}}}";
217 s ::= l "=" q => "assign"
220 | l "=" q => "assign"
225 id ::= idl++ => "stringify"
231 output "times:{stringify:{{a}} times:{stringify:{{b}} stringify:{{c}}}}";
234 s ::= l "=" r => "assign"
237 | l "=" r => "assign"
239 | (r) "*" r => "times"
242 id ::= idl++ => "stringify"
248 output "plus:{stringify:{{a}} times:{stringify:{{b}} stringify:{{c}}}}";
251 s ::= l "=" r => "assign"
254 | l "=" r => "assign"
259 id ::= idl++ => "stringify"
280 output "smt:{while:{>:{{x} {0}} while:{>:{{y} {0}} sbb:{{f o o} {b a r}}}}}";
281 output "smt:{while:{>:{{x} {0}} sbb:{while:{>:{{y} {0}} {f o o}} {b a r}}}}";
284 outdent !::= " " outdent " "
288 s ::= !any "\n\n" !ww statement !ww "\n\n" !any => smt
293 block ::= "\n" !indent blockBody
294 &~ "\n" outdent [~\ ] [~]*
296 blockBody ::= statement
297 > statement blockBody /ws => "sbb"
300 | ^"while" expr block /ws
307 call ::= expr "()" /ws
311 ident ::= [a-z]++ &~ keyword
312 keyword ::= "if" | "then" | "else" | "while"
314 w ::= " " | "\n" | "\r"