94 lines
2.8 KiB
CFEngine3
94 lines
2.8 KiB
CFEngine3
|
|
-------------------------------------------------------------------------------
|
|
-- * PROGRAM
|
|
-------------------------------------------------------------------------------
|
|
|
|
Program. Program ::= [Def] ;
|
|
|
|
-------------------------------------------------------------------------------
|
|
-- * TOP-LEVEL
|
|
-------------------------------------------------------------------------------
|
|
|
|
DBind. Def ::= Bind ;
|
|
DSig. Def ::= Sig ;
|
|
DData. Def ::= Data ;
|
|
|
|
Sig. Sig ::= LIdent ":" Type ;
|
|
|
|
Bind. Bind ::= LIdent [LIdent] "=" Exp ;
|
|
|
|
-------------------------------------------------------------------------------
|
|
-- * TYPES
|
|
-------------------------------------------------------------------------------
|
|
|
|
TLit. Type2 ::= UIdent ;
|
|
TVar. Type2 ::= TVar ;
|
|
TAll. Type1 ::= "forall" TVar "." Type ;
|
|
TData. Type1 ::= UIdent "(" [Type] ")" ;
|
|
internal TEVar. Type1 ::= TEVar ;
|
|
TFun. Type ::= Type1 "->" Type ;
|
|
|
|
MkTVar. TVar ::= LIdent ;
|
|
internal MkTEVar. TEVar ::= LIdent ;
|
|
|
|
-------------------------------------------------------------------------------
|
|
-- * DATA TYPES
|
|
-------------------------------------------------------------------------------
|
|
|
|
Constructor. Constructor ::= UIdent ":" Type ;
|
|
|
|
Data. Data ::= "data" Type "where" "{" [Constructor] "}" ;
|
|
|
|
-------------------------------------------------------------------------------
|
|
-- * EXPRESSIONS
|
|
-------------------------------------------------------------------------------
|
|
|
|
EAnn. Exp4 ::= "(" Exp ":" Type ")" ;
|
|
EVar. Exp3 ::= LIdent ;
|
|
EInj. Exp3 ::= UIdent ;
|
|
ELit. Exp3 ::= Lit ;
|
|
EApp. Exp2 ::= Exp2 Exp3 ;
|
|
EAdd. Exp1 ::= Exp1 "+" Exp2 ;
|
|
ELet. Exp ::= "let" Bind "in" Exp ;
|
|
EAbs. Exp ::= "\\" LIdent "." Exp ;
|
|
ECase. Exp ::= "case" Exp "of" "{" [Branch] "}";
|
|
|
|
-------------------------------------------------------------------------------
|
|
-- * LITERALS
|
|
-------------------------------------------------------------------------------
|
|
|
|
LInt. Lit ::= Integer ;
|
|
LChar. Lit ::= Char ;
|
|
|
|
-------------------------------------------------------------------------------
|
|
-- * CASE
|
|
-------------------------------------------------------------------------------
|
|
|
|
Branch. Branch ::= Pattern "=>" Exp ;
|
|
|
|
PVar. Pattern ::= LIdent ;
|
|
PLit. Pattern ::= Lit ;
|
|
PInj. Pattern ::= UIdent [Pattern] ;
|
|
PCatch. Pattern ::= "_" ;
|
|
|
|
-------------------------------------------------------------------------------
|
|
-- * AUX
|
|
-------------------------------------------------------------------------------
|
|
|
|
separator Def ";" ;
|
|
separator nonempty Constructor "" ;
|
|
separator Type " " ;
|
|
separator Pattern " " ;
|
|
separator Branch "," ;
|
|
separator Ident " ";
|
|
separator LIdent " ";
|
|
separator TVar " " ;
|
|
|
|
coercions Exp 4 ;
|
|
coercions Type 2 ;
|
|
|
|
token UIdent (upper (letter | digit | '_')*) ;
|
|
token LIdent (lower (letter | digit | '_')*) ;
|
|
|
|
comment "--" ;
|
|
comment "{-" "-}" ;
|