91 lines
2.8 KiB
CFEngine3
91 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 ;
|
|
TIndexed. Type1 ::= Indexed ;
|
|
internal TEVar. Type1 ::= TEVar ;
|
|
TFun. Type ::= Type1 "->" Type ;
|
|
|
|
MkTVar. TVar ::= LIdent ;
|
|
internal MkTEVar. TEVar ::= LIdent ;
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- * DATA TYPES
|
|
--------------------------------------------------------------------------------
|
|
|
|
Constructor. Constructor ::= UIdent ":" Type ;
|
|
|
|
Indexed. Indexed ::= UIdent "(" [Type] ")" ;
|
|
|
|
Data. Data ::= "data" Indexed "where" "{" [Constructor] "}" ;
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- * EXPRESSIONS
|
|
--------------------------------------------------------------------------------
|
|
|
|
EAnn. Exp5 ::= "(" Exp ":" Type ")" ;
|
|
EId. Exp4 ::= LIdent ;
|
|
ELit. Exp4 ::= Lit ;
|
|
EApp. Exp3 ::= Exp3 Exp4 ;
|
|
EAdd. Exp1 ::= Exp1 "+" Exp2 ;
|
|
ELet. Exp ::= "let" LIdent "=" Exp "in" Exp ;
|
|
EAbs. Exp ::= "\\" LIdent "." Exp ;
|
|
ECase. Exp ::= "case" Exp "of" "{" [Inj] "}";
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- * LITERALS
|
|
--------------------------------------------------------------------------------
|
|
|
|
LInt. Lit ::= Integer ;
|
|
LChar. Lit ::= Char ;
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- * CASE
|
|
--------------------------------------------------------------------------------
|
|
|
|
Inj. Inj ::= Init "=>" Exp ;
|
|
|
|
InitLit. Init ::= Lit ;
|
|
InitConstructor. Init ::= UIdent [LIdent] ;
|
|
InitCatch. Init ::= "_" ;
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- * AUX
|
|
--------------------------------------------------------------------------------
|
|
|
|
separator Def ";" ;
|
|
separator nonempty Constructor "" ;
|
|
separator Type " " ;
|
|
separator nonempty Inj ";" ;
|
|
separator Ident " ";
|
|
separator LIdent " ";
|
|
|
|
coercions Exp 5 ;
|
|
coercions Type 2 ;
|
|
|
|
token UIdent (upper (letter | digit | '_')*) ;
|
|
token LIdent (lower (letter | digit | '_')*) ;
|
|
|
|
comment "--" ;
|
|
comment "{-" "-}" ;
|