Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,26 @@
|
|||
%{
|
||||
open AbstractSyntaxTree
|
||||
%}
|
||||
|
||||
%start Expr
|
||||
|
||||
// terminal tokens
|
||||
%token <int> INT
|
||||
%token PLUS MINUS TIMES DIVIDE LPAREN RPAREN
|
||||
%token EOF
|
||||
|
||||
// associativity and precedences
|
||||
%left PLUS MINUS
|
||||
%left TIMES DIVIDE
|
||||
|
||||
// return type of Expr
|
||||
%type <Expression> Expr
|
||||
|
||||
%%
|
||||
|
||||
Expr: INT { Int $1 }
|
||||
| Expr PLUS Expr { Plus ($1, $3) }
|
||||
| Expr MINUS Expr { Minus ($1, $3) }
|
||||
| Expr TIMES Expr { Times ($1, $3) }
|
||||
| Expr DIVIDE Expr { Divide ($1, $3) }
|
||||
| LPAREN Expr RPAREN { $2 }
|
||||
Loading…
Add table
Add a link
Reference in a new issue