2015-07-21 03:32:16 -07:00
|
|
|
|
|
|
|
|
|
|
|
<program> := <statements> EOF
|
|
|
|
|
2015-07-24 02:06:45 -07:00
|
|
|
<statements> := <statement>
|
2015-07-21 03:32:16 -07:00
|
|
|
| <statement> SEP <statements>
|
|
|
|
|
|
|
|
<statement> := let <id> = <expr>
|
|
|
|
| <expr>
|
|
|
|
|
|
|
|
<expr> := if <expr> then <statements> end
|
|
|
|
| if <expr> then <statements> else <statements> end
|
|
|
|
| while <expr> SEP <statements> end
|
|
|
|
| <binexpr>
|
|
|
|
| <number>
|
|
|
|
| <id>
|
|
|
|
|
|
|
|
|
|
|
|
<binexpr> :=
|
|
|
|
|
|
|
|
|
2015-07-24 02:06:45 -07:00
|
|
|
/* actual grammar encoded in program */
|
|
|
|
|
|
|
|
<program> := <statements> EOF
|
|
|
|
<statements> := <statement> | <statement> SEP <statements>
|
|
|
|
<let_expression> := let <identifier> = <rhs>
|
|
|
|
<rhs> := <num_literal> | <str_literal> | <identifier>
|
|
|
|
|