-
Notifications
You must be signed in to change notification settings - Fork 24
/
Core.cf
105 lines (73 loc) · 2.95 KB
/
Core.cf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
-- BNF Converter grammar for GHC External Core.
-- (c) Aarne Ranta (aarne@cs.chalmers.se) 6/11/2003 under GNU GPL
-- on the basis of ExternalCore.lhs and ParserExternalCore.y
-- from the University of Glasgow (2001)
-- Differences from source abstract syntax are marked with ---
Module. Module ::= "%module" Ident [Tdef] [Vdefg] ;
Data. Tdef ::= "%data" QualIdent [Tbind] "=" "{" [Cdef] "}" ;
Newtype. Tdef ::= "%newtype" QualIdent [Tbind] MaybeTy ;
terminator Tdef ";" ;
JustTy. MaybeTy ::= "=" Ty ; --- Maybe Ty
NoTy. MaybeTy ::= ;
---- Constr. Cdef ::= QualIdent [ATbind] [Ty2] ; --- Ident
---- terminator Ty2 "" ;
Constr. Cdef ::= QualIdent [ATbind] [Tyt] ; ---- hack for C
terminator Tyt "" ; ----
TT. Tyt ::= Ty2 ; ----
separator nonempty Cdef ";" ;
Rec. Vdefg ::= "%rec" "{" [Vdef] "}" ;
Nonrec. Vdefg ::= Vdef ;
terminator Vdefg ";" ;
VdefQ. Vdef ::= QualIdent "::" Ty "=" Exp ; --- (,,)
VdefU. Vdef ::= Ident "::" Ty "=" Exp ; --- added, since also occurs
separator nonempty Vdef ";" ;
Var. Exp2 ::= Ident ; --- QualIdent in abs; Ident in parser
Dcon. Exp2 ::= QualIdent ;
Litc. Exp2 ::= Lit ;
App. Exp1 ::= Exp1 Exp2 ;
Appt. Exp1 ::= Exp1 "@" Ty2 ;
Lams. Exp ::= "\\" [Bind] "->" Exp ; --- foldr Lam
Let. Exp ::= "%let" Vdefg "%in" Exp ;
Case. Exp ::= "%case" Exp2 "%of" Vbind "{" [Alt] "}" ;
Coerce. Exp ::= "%coerce" Ty2 Exp ;
Note. Exp ::= "%note" String Exp ; --- STRING
External. Exp ::= "%external" String Ty ;
coercions Exp 2 ;
Vb. Bind ::= Vbind ;
Tb. Bind ::= "@" Tbind ;
terminator nonempty Bind "" ;
Acon. Alt ::= QualIdent [ATbind] [Vbind] "->" Exp ;
Alit. Alt ::= Lit "->" Exp ;
Adefault. Alt ::= "%_" "->" Exp ;
separator nonempty Alt ";" ;
Vbind. Vbind ::= "(" Ident "::" Ty ")" ; --- (,)
terminator Vbind "" ;
TbindPair. Tbind ::= "(" Ident "::" Kind1 ")" ; --- (,)
TbindLift. Tbind ::= Ident ; --- (,Klifted)
separator Tbind "" ;
ATbind. ATbind ::= "@" Tbind ; --- added, for a different list separator
separator ATbind "" ;
Tvar. Ty2 ::= Ident ; -- aty
Tcon. Ty2 ::= QualIdent ;
Tapp. Ty1 ::= Ty1 Ty2 ; -- bty
TArrow. Ty ::= Ty1 "->" Ty ; -- ty --- tArrow
Tforalls. Ty ::= "%forall" [Tbind] "." Ty ; --- foldr Tforall
coercions Ty 2 ;
Klifted. Kind1 ::= "*" ;
Kunlifted. Kind1 ::= "#" ;
Kopen. Kind1 ::= "?" ;
Karrow. Kind ::= Kind1 "->" Kind ;
coercions Kind 1 ;
--- remains to check if the literal definitions are the same as in GHC
Lint. Lit ::= "(" Integer "::" Ty2 ")" ;
Lrational. Lit ::= "(" Double "::" Ty2 ")" ; --- Rational
Lchar. Lit ::= "(" Char "::" Ty2 ")" ;
Lstring. Lit ::= "(" String "::" Ty2 ")" ;
Qual. QualIdent ::= Ident "." Ident ; --- (,)
{-
---- token Str '"' ((char - ["\"\\"]) | ('\\' ["\"\\ntx"]))* '"' ;
token Chr '\'' ((char - ["'\\"]) |
('\\' ["'\\nt"]) |
('\\' 'x' (letter|digit) (letter|digit)))
'\'' ;
-}