Created
March 3, 2015 08:29
-
-
Save autotaker/114a58bce2ab6af47926 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%{ | |
open Syntax | |
%} | |
%token <int> INT | |
%token <string> ID | |
%token LET | |
%token IN | |
%token LPAR | |
%token RPAR | |
%token PLUS | |
%token EOL | |
%token EQ | |
%nonassoc IN | |
%left PLUS | |
%start main | |
%type <Syntax.expr> main | |
%% | |
main: | |
expr EOL { $1 } | |
expr: | |
INT { Int($1) } | |
| ID { Id($1) } | |
| LPAR expr RPAR { $2 } | |
| expr PLUS expr { Plus($1,$3) } | |
| LET ID EQ expr IN expr { Let ($2,$4,$6) } | |
; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment