unit tests, started on pattern matching
This commit is contained in:
parent
d23d417ff3
commit
05313652f9
9 changed files with 212 additions and 133 deletions
41
Grammar.cf
41
Grammar.cf
|
|
@ -8,6 +8,18 @@ separator Def ";" ;
|
|||
Bind. Bind ::= Ident ":" Type ";"
|
||||
Ident [Ident] "=" Exp ;
|
||||
|
||||
Data. Data ::= "data" Type "where" "{"
|
||||
[Constructor] "}" ;
|
||||
|
||||
separator nonempty Constructor "" ;
|
||||
|
||||
Constructor. Constructor ::= Ident ":" Type ;
|
||||
|
||||
TMono. Type1 ::= "_" Ident ;
|
||||
TPol. Type1 ::= "'" Ident ;
|
||||
TConstr. Type1 ::= Ident "(" [Type] ")" ;
|
||||
TArr. Type ::= Type1 "->" Type ;
|
||||
|
||||
EAnn. Exp5 ::= "(" Exp ":" Type ")" ;
|
||||
EId. Exp4 ::= Ident ;
|
||||
ELit. Exp4 ::= Literal ;
|
||||
|
|
@ -15,43 +27,24 @@ EApp. Exp3 ::= Exp3 Exp4 ;
|
|||
EAdd. Exp1 ::= Exp1 "+" Exp2 ;
|
||||
ELet. Exp ::= "let" Ident "=" Exp "in" Exp ;
|
||||
EAbs. Exp ::= "\\" Ident "." Exp ;
|
||||
ECase. Exp ::= "case" Exp "of" "{" [Inj] "}";
|
||||
ECase. Exp ::= "case" Exp "of" "{" [Inj] "}";
|
||||
|
||||
LInt. Literal ::= Integer ;
|
||||
|
||||
Inj. Inj ::= Init "=>" Exp ;
|
||||
terminator Inj ";" ;
|
||||
separator nonempty Inj ";" ;
|
||||
|
||||
InitLit. Init ::= Literal ;
|
||||
InitConstr. Init ::= Ident [Match] ;
|
||||
InitCatch. Init ::= "_" ;
|
||||
|
||||
LMatch. Match ::= Literal ;
|
||||
IMatch. Match ::= Ident ;
|
||||
InitMatch. Match ::= Ident Match ;
|
||||
separator Match " " ;
|
||||
|
||||
TMono. Type1 ::= "_" Ident ;
|
||||
TPol. Type1 ::= "'" Ident ;
|
||||
TConstr. Type1 ::= Ident "(" [Type] ")" ;
|
||||
TArr. Type ::= Type1 "->" Type ;
|
||||
InitLit. Init ::= Literal ;
|
||||
InitConstr. Init ::= Ident [Ident] ;
|
||||
InitCatch. Init ::= "_" ;
|
||||
|
||||
separator Type " " ;
|
||||
coercions Type 2 ;
|
||||
|
||||
-- shift/reduce problem here
|
||||
Data. Data ::= "data" Type "where" ";"
|
||||
[Constructor];
|
||||
|
||||
separator Constructor "," ;
|
||||
|
||||
Constructor. Constructor ::= Ident ":" Type ;
|
||||
|
||||
-- This doesn't seem to work so we'll have to live with ugly keywords for now
|
||||
-- token Poly upper (letter | digit | '_')* ;
|
||||
-- token Mono lower (letter | digit | '_')* ;
|
||||
|
||||
separator Bind ";" ;
|
||||
separator Ident " ";
|
||||
|
||||
coercions Exp 5 ;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue