2022-01-20 21:05:25 +01:00
|
|
|
layout toplevel ;
|
2022-01-23 12:52:33 +01:00
|
|
|
layout "let" ;
|
|
|
|
layout stop "in" ;
|
2022-01-20 21:05:25 +01:00
|
|
|
|
|
|
|
entrypoints [Def], Exp ;
|
|
|
|
|
2022-01-20 21:14:03 +01:00
|
|
|
token Id ((letter|digit|["[]_"])+) ;
|
2022-01-20 21:05:25 +01:00
|
|
|
|
|
|
|
comment "--" ;
|
|
|
|
comment "{-" "-}" ;
|
|
|
|
|
2022-01-23 12:52:33 +01:00
|
|
|
TypeDef. Def ::= "type" TypeSig1 [Decl] ;
|
2022-01-20 21:05:25 +01:00
|
|
|
VarDef. Def ::= Id ":" TypeSig ":=" Exp ;
|
|
|
|
separator Def ";" ;
|
|
|
|
|
2022-01-23 12:52:33 +01:00
|
|
|
Decl. Decl ::= Id ":" TypeSig ;
|
|
|
|
[]. [Decl] ::= ;
|
|
|
|
(:). [Decl] ::= "|" Decl [Decl];
|
|
|
|
-- todo custom [Decl]
|
2022-01-20 21:05:25 +01:00
|
|
|
|
|
|
|
TypeFun. TypeSig ::= TypeSig1 "→" TypeSig ;
|
|
|
|
TypeApp. TypeSig1 ::= Id [TypeSig2] ;
|
|
|
|
TypeVar. TypeSig2 ::= Id ;
|
|
|
|
coercions TypeSig 2;
|
|
|
|
|
|
|
|
separator nonempty TypeSig2 "" ;
|
|
|
|
|
2022-01-23 12:52:33 +01:00
|
|
|
ExpLet. Exp ::= "let" "{" [Assign] "}" "in" Exp2 ;
|
|
|
|
ExpTyped. Exp1 ::= Exp2 ":" TypeSig ;
|
|
|
|
ExpAbs. Exp2 ::= "λ" [Id] "." Exp3 ;
|
|
|
|
ExpApp. Exp3 ::= Exp4 [Exp4] ;
|
|
|
|
ExpVar. Exp4 ::= Id ;
|
2022-01-20 21:05:25 +01:00
|
|
|
|
2022-01-23 12:52:33 +01:00
|
|
|
Assign. Assign ::= Ident "=" Exp1 ;
|
|
|
|
separator nonempty Assign ";" ;
|
|
|
|
|
|
|
|
separator nonempty Exp4 "" ;
|
|
|
|
coercions Exp 4 ;
|
2022-01-20 21:05:25 +01:00
|
|
|
|
|
|
|
separator nonempty Id "" ;
|