2018-02-13 23:43:40 +00:00
|
|
|
%{
|
|
|
|
open Types
|
|
|
|
%}
|
|
|
|
|
|
|
|
%token EOL
|
|
|
|
%token Dot
|
2018-02-16 11:22:07 +00:00
|
|
|
%token Equal
|
|
|
|
%token LParen
|
|
|
|
%token RParen
|
2018-02-20 11:19:49 +00:00
|
|
|
%token Let
|
2018-02-16 11:22:07 +00:00
|
|
|
%token <string> Ident
|
2018-02-13 23:43:40 +00:00
|
|
|
%token Lambda
|
|
|
|
|
2018-02-20 11:04:09 +00:00
|
|
|
%right prec_Abs
|
|
|
|
%left prec_App
|
|
|
|
|
2018-02-13 23:43:40 +00:00
|
|
|
%start main
|
2018-02-20 09:24:52 +00:00
|
|
|
%type <Types.input> main
|
2018-02-20 11:04:09 +00:00
|
|
|
|
2018-02-13 23:43:40 +00:00
|
|
|
%%
|
|
|
|
|
|
|
|
main:
|
2018-02-16 11:22:07 +00:00
|
|
|
| assign EOL { $1 }
|
2018-02-20 09:24:52 +00:00
|
|
|
| expr EOL { Types.Term($1) }
|
2018-02-16 11:22:07 +00:00
|
|
|
;
|
|
|
|
assign:
|
2018-02-20 11:19:49 +00:00
|
|
|
| Let Ident Equal expr { Types.Assign($2, $4) }
|
2018-02-13 23:43:40 +00:00
|
|
|
;
|
|
|
|
expr:
|
2018-02-20 11:04:09 +00:00
|
|
|
| Ident { Types.TmVar($1) }
|
2018-02-20 09:24:52 +00:00
|
|
|
| LParen expr RParen { $2 }
|
2018-02-20 11:04:09 +00:00
|
|
|
| Lambda Ident Dot expr %prec prec_Abs { Types.TmAbs($2, $4) }
|
|
|
|
| expr expr %prec prec_App { Types.TmApp($1, $2) }
|
2018-02-13 23:43:40 +00:00
|
|
|
;
|
|
|
|
|