working on adapting the typechecker

This commit is contained in:
sebastianselander 2023-03-22 17:52:39 +01:00
parent 936cb1301f
commit 914855e20f
3 changed files with 658 additions and 652 deletions

View file

@ -1,12 +1,13 @@
--------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- * PROGRAM
--------------------------------------------------------------------------------
-------------------------------------------------------------------------------
Program. Program ::= [Def] ;
--------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- * TOP-LEVEL
--------------------------------------------------------------------------------
-------------------------------------------------------------------------------
DBind. Def ::= Bind ;
DSig. Def ::= Sig ;
@ -16,9 +17,9 @@ Sig. Sig ::= LIdent ":" Type ;
Bind. Bind ::= LIdent [LIdent] "=" Exp ;
--------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- * TYPES
--------------------------------------------------------------------------------
-------------------------------------------------------------------------------
TLit. Type2 ::= UIdent ;
TVar. Type2 ::= TVar ;
@ -30,9 +31,9 @@ internal TEVar. Type1 ::= TEVar ;
MkTVar. TVar ::= LIdent ;
internal MkTEVar. TEVar ::= LIdent ;
--------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- * DATA TYPES
--------------------------------------------------------------------------------
-------------------------------------------------------------------------------
Constructor. Constructor ::= UIdent ":" Type ;
@ -40,12 +41,12 @@ Indexed. Indexed ::= UIdent "(" [Type] ")" ;
Data. Data ::= "data" Indexed "where" "{" [Constructor] "}" ;
--------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- * EXPRESSIONS
--------------------------------------------------------------------------------
-------------------------------------------------------------------------------
EAnn. Exp5 ::= "(" Exp ":" Type ")" ;
EId. Exp4 ::= LIdent ;
EId. Exp4 ::= Ident ;
ELit. Exp4 ::= Lit ;
EApp. Exp3 ::= Exp3 Exp4 ;
EAdd. Exp1 ::= Exp1 "+" Exp2 ;
@ -53,16 +54,16 @@ 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 ;
@ -70,9 +71,9 @@ InitLit. Init ::= Lit ;
InitConstructor. Init ::= UIdent [LIdent] ;
InitCatch. Init ::= "_" ;
--------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- * AUX
--------------------------------------------------------------------------------
-------------------------------------------------------------------------------
separator Def ";" ;
separator nonempty Constructor "" ;
@ -80,6 +81,7 @@ separator Type " " ;
separator nonempty Inj ";" ;
separator Ident " ";
separator LIdent " ";
separator TVar " " ;
coercions Exp 5 ;
coercions Type 2 ;