2989ac338c
Uses Operator-precedence parsing algorithm, which I don't fully understand.
25 lines
487 B
Plaintext
25 lines
487 B
Plaintext
|
|
|
|
<program> := <statements> EOF
|
|
|
|
<statements> := <statement>
|
|
| <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
|
|
| ( <expr> )
|
|
| <binop>
|
|
|
|
<binop> := <simple_expr>
|
|
| <simple_expr> <id> <binop>
|
|
|
|
<simple_expr> := <id>
|
|
| <number>
|
|
| <string>
|
|
|
|
|