You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

39 lines
604 B

%{
open Lang
%}
%token LET FUN IN RARROW EQ
%token UNIT
%token<bool> BOOL
%token<string> VARID
%token EOF
%right LET
%right IN
%left FUN RARROW BOOL VARID UNIT
%start <Lang.file> file
%%
%inline literal:
| UNIT { Unit }
| b = BOOL { Bool b }
%inline var_id:
| id = VARID { id }
%inline const:
| l = literal { Literal l }
| v = var_id { Var v }
%inline pattern:
| p = var_id { p }
expr:
| FUN p = pattern RARROW e = expr { Abstract (p, e) }
| LET p = pattern EQ e = expr IN e2 = expr { Bind (p, e, e2) }
| e = expr e2 = expr { Apply (e, e2) }
| c = const { Const c }
file:
| e = expr EOF { e }