Started adding cases to the grammar.
This commit is contained in:
parent
d345ccb33b
commit
7cedc2e28c
2 changed files with 28 additions and 19 deletions
23
Grammar.cf
23
Grammar.cf
|
|
@ -1,12 +1,21 @@
|
||||||
Program. Program ::= [Bind];
|
Program. Program ::= [Bind];
|
||||||
|
|
||||||
EId. Exp3 ::= Ident;
|
|
||||||
EInt. Exp3 ::= Integer;
|
EId. Exp3 ::= Ident;
|
||||||
ELet. Exp3 ::= "let" [Bind] "in" Exp;
|
EInt. Exp3 ::= Integer;
|
||||||
EApp. Exp2 ::= Exp2 Exp3;
|
ELet. Exp3 ::= "let" [Bind] "in" Exp;
|
||||||
EAdd. Exp1 ::= Exp1 "+" Exp2;
|
EApp. Exp2 ::= Exp2 Exp3;
|
||||||
EAbs. Exp ::= "\\" Ident ":" Type "." Exp;
|
EAdd. Exp1 ::= Exp1 "+" Exp2;
|
||||||
EAnn. Exp3 ::= "(" Exp ":" Type ")";
|
EAbs. Exp ::= "\\" Ident ":" Type "." Exp;
|
||||||
|
EAnn. Exp3 ::= "(" Exp ":" Type ")";
|
||||||
|
|
||||||
|
ECase. Exp ::= "case" Exp "of" "{" [CaseMatch] "}";
|
||||||
|
--
|
||||||
|
CaseMatch. CaseMatch ::= Case "=>" Exp ;
|
||||||
|
separator CaseMatch ",";
|
||||||
|
--terminator CaseMatch ".";
|
||||||
|
|
||||||
|
CInt. Case ::= Integer ;
|
||||||
|
|
||||||
Bind. Bind ::= Ident ":" Type ";"
|
Bind. Bind ::= Ident ":" Type ";"
|
||||||
Ident [Ident] "=" Exp ;
|
Ident [Ident] "=" Exp ;
|
||||||
|
|
|
||||||
|
|
@ -4,17 +4,17 @@
|
||||||
--main : Int;
|
--main : Int;
|
||||||
--main = tripplemagic ((\x:Int. x+x+3) ((\x:Int. x) 2)) 5 3
|
--main = tripplemagic ((\x:Int. x+x+3) ((\x:Int. x) 2)) 5 3
|
||||||
|
|
||||||
apply : (Int -> Int) -> Int -> Int;
|
--apply : (Int -> Int) -> Int -> Int;
|
||||||
apply f x = f x;
|
--apply f x = f x;
|
||||||
|
--
|
||||||
main : Int;
|
|
||||||
main = (\x : Int . x + 5) 5
|
|
||||||
|
|
||||||
|
|
||||||
--apply : (Int -> Int -> Int) -> Int -> Int;
|
|
||||||
--apply f x y = f x y;
|
|
||||||
--krimp: Int -> Int -> Int;
|
|
||||||
--krimp x y = x + y;
|
|
||||||
--main : Int;
|
--main : Int;
|
||||||
--main = apply (krimp) 2 3;--apply (\y: Int . (\x: Int . x + y + 2)) 5 2;
|
--main = (\x : Int . x + 5) 5
|
||||||
|
|
||||||
|
|
||||||
|
apply : (Int -> Int -> Int) -> Int -> Int -> Int;
|
||||||
|
apply f x y = f x y;
|
||||||
|
krimp: Int -> Int -> Int;
|
||||||
|
krimp x y = x + y;
|
||||||
|
main : Int;
|
||||||
|
main = apply (krimp) 2 3;--apply (\y: Int . (\x: Int . x + y + 2)) 5 2;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue