Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [general]
- expose TopLevel
- [ast]
- StmtList
- Cons (head, tail)
- Nil
- Stmt
- Eval (expr)
- Assign (token, expr)
- Expr
- BinOp (lhs, op:BinOp, rhs)
- Decimal (literal)
- Float (literal)
- BinOp
- Or
- And
- EQ
- NE
- LE
- LT
- GE
- GT
- Sub
- Add
- Div
- Mul
- Pow
- [grammar]
- TopLevel
- | Statements
- Statements : StmtList
- | Statement Statements {Cons($1,$2)}
- | {Nil}
- Statement : Stmt
- | Expr {Eval($1)}
- | identifier = Expr {Assign($1,$3)}
- Expr : Expr
- | expr[10]
- expr[prec]
- prec = 10 | expr[10] or expr[9] {BinOp($1,Or,$3)}
- prec = 9 | expr[9] and expr[8] {BinOp($1,And,$3)}
- prec = 8 | expr[8] == expr[7] {BinOp($1,EQ,$3)}
- prec = 8 | expr[8] <> expr[7] {BinOp($1,NE,$3)}
- prec = 8 | expr[8] <= expr[7] {BinOp($1,LE,$3)}
- prec = 8 | expr[8] >= expr[7] {BinOp($1,GE,$3)}
- prec = 8 | expr[8] < expr[7] {BinOp($1,LT,$3)}
- prec = 8 | expr[8] > expr[7] {BinOp($1,GT,$3)}
- prec = 7 | expr[7] - expr[6] {BinOp($1,Sub,$3)}
- prec = 7 | expr[7] + expr[6] {BinOp($1,Add,$3)}
- prec = 6 | expr[6] / expr[5] {BinOp($1,Div,$3)}
- prec = 6 | expr[6] * expr[5] {BinOp($1,Mul,$3)}
- prec = 5 | expr[4] ^ expr[5] {BinOp($1,Pow,$3)}
- prec = 0 | prim_expr
- prec > 0 | expr[prec-1]
- prim_expr
- | decimal {Decimal($1)}
- | float {Float($1)}
- | ( expr[10] ) {$2}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement