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-25 21:00:12 +01:00
|
|
|
ExpLet. Exp ::= "let" "{" [Assign] "}" "in" Exp1 ;
|
|
|
|
ExpAbs. Exp1 ::= "λ" [Id] "." Exp1 ;
|
|
|
|
ExpApp. Exp1 ::= Exp2 [Exp2] ;
|
|
|
|
ExpVar. Exp2 ::= Id ;
|
2022-01-20 21:05:25 +01:00
|
|
|
|
2022-01-25 21:00:12 +01:00
|
|
|
Assign. Assign ::= Id ":=" Exp ;
|
2022-01-23 12:52:33 +01:00
|
|
|
separator nonempty Assign ";" ;
|
|
|
|
|
2022-01-25 21:00:12 +01:00
|
|
|
separator nonempty Exp2 "" ;
|
|
|
|
coercions Exp 2 ;
|
2022-01-20 21:05:25 +01:00
|
|
|
|
|
|
|
separator nonempty Id "" ;
|