lambda/parser.mly
2018-02-20 05:04:09 -06:00

34 lines
499 B
OCaml

%{
open Types
%}
%token EOL
%token Dot
%token Equal
%token LParen
%token RParen
%token <string> Ident
%token Lambda
%right prec_Abs
%left prec_App
%start main
%type <Types.input> main
%%
main:
| assign EOL { $1 }
| expr EOL { Types.Term($1) }
;
assign:
| Ident Equal expr { Types.Assign($1, $3) }
;
expr:
| Ident { Types.TmVar($1) }
| LParen expr RParen { $2 }
| Lambda Ident Dot expr %prec prec_Abs { Types.TmAbs($2, $4) }
| expr expr %prec prec_App { Types.TmApp($1, $2) }
;