Skip to content

Instantly share code, notes, and snippets.

@autotaker
Created March 3, 2015 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save autotaker/114a58bce2ab6af47926 to your computer and use it in GitHub Desktop.
Save autotaker/114a58bce2ab6af47926 to your computer and use it in GitHub Desktop.
%{
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