-
Notifications
You must be signed in to change notification settings - Fork 5
/
sml_syntax.sml
76 lines (66 loc) · 1.81 KB
/
sml_syntax.sml
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
structure SmlSyntax =
struct
datatype BASETYPE
= Str
| Bool
| Int
| Char
datatype TYPE
= TypeVar of string
| ArrowType of TYPE * TYPE
| ProdType of TYPE list
| AppType of TYPE list * TYPE
| ModProjType of STRUCT * string
| BaseType of BASETYPE
and SIG
= SigVar of string
| SigBody of decl list
| WhereType of SIG * TYPE * TYPE
and decl
= BlankDecl
| StructureDecl of string * SIG
| TypeDecls of
{datatypes : (string * string list * data_cases) list,
aliases : (string * string list * TYPE option) list}
| ValDecl of string * TYPE
| SharingDecl of TYPE * TYPE
and PAT
= Wild
| VarPat of string
| TuplePat of PAT list
| InjPat of string * PAT
| ListPat of PAT list
| AscribedPat of PAT * TYPE
| ConsPat of PAT * PAT
and EXP
= ExpVar of string
| TupleExp of EXP list
| CaseExp of EXP * (PAT * EXP) list
| SeqExp of EXP list
| IntExp of int
| StringExp of string
| ListExp of EXP list
| LetExp of defn list * EXP
| LamExp of (PAT * EXP) list
| IfExp of EXP * EXP * EXP
| BoolAnd
and STRUCT
= StructVar of string
| StructBody of defn list
| StructApp of string * STRUCT
and defn
= BlankDefn
| StructureDefn of string * SIG option * STRUCT
| TypeDefns of
{datatypes : (string * string list * data_cases) list,
aliases : (string * string list * TYPE) list}
| ValDefn of PAT * EXP
| FunDefns of (string * PAT list * TYPE option * EXP) list
| OpenDefn of STRUCT
| DatatypeCopy of string * TYPE
withtype data_cases = (string * TYPE option) list
datatype toplevel_defn
= TLSignature of string * SIG
| TLStructure of string * SIG option * STRUCT
| TLFunctor of string * decl list * SIG option * STRUCT
end