-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtoken.sml
161 lines (143 loc) · 3.17 KB
/
token.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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
structure Token = struct
(* Used to avoid reduce-reduce conflicts *)
datatype left_paren_kind
= Normal
| DotInRight
datatype t
= LPAREN of left_paren_kind ref
| RPAREN
| LBRACE of left_paren_kind ref
| RBRACE
| LBRACK
| RBRACK
| LPAREN_PROJ
| LBRACE_PROJ
| DOT
| NUMBER of int
| STRING of string
| CHAR of char
| LOWER_IDENT of string
| UPPER_IDENT of string
| QUOTE_IDENT of string
| VAL_OP of string
| EQUAL
| COLON
| COLON_GT
| COLON_EQ
| COLON_COLON
| RARROW
| BAR
| UNDERSCORE
| ASTERISK
| COMMA
| DOLLAR
| PLUS
| MINUS
| GT
| LT
| GT_EQ
| LT_EQ
| GT_GT_GT
| LT_LT_LT
| EQUAL_EQUAL
| SLASH_EQUAL
| LT_GT
| LT_PLUS_GT
| SUBMODULE
| STRUCT
| SIG
| VAL
| TYPE
| MODULE
| SIGNATURE
| INCLUDE
| OPEN
| WHERE
| DATATYPE
| OF
| LET
| IN
| FUN
| FUNCTION
| FUNCTOR
| IF
| THEN
| ELSE
| FALSE
| TRUE
| MATCH
| WITH
| END
| REC
| AND
| PACK
| UNPACK
fun show (LPAREN _) = "("
| show RPAREN = ")"
| show (LBRACE _) = "{"
| show RBRACE = "}"
| show LBRACK = "["
| show RBRACK = "]"
| show LPAREN_PROJ = "("
| show LBRACE_PROJ = "{"
| show DOT = "."
| show (NUMBER n) = Int.toString n
| show (STRING s) = String.toString s
| show (CHAR c) = Char.toString c
| show (LOWER_IDENT s) = s
| show (UPPER_IDENT s) = s
| show (QUOTE_IDENT s) = "'" ^ s
| show (VAL_OP s) = "val" ^ s
| show EQUAL = "="
| show COLON = ":"
| show COLON_GT = ":>"
| show COLON_EQ = ":="
| show COLON_COLON = "::"
| show RARROW = "->"
| show BAR = "|"
| show UNDERSCORE = "_"
| show ASTERISK = "*"
| show COMMA = ","
| show DOLLAR = "$"
| show PLUS = "+"
| show MINUS = "-"
| show GT = ">"
| show LT = "<"
| show GT_EQ = ">="
| show LT_EQ = "<="
| show GT_GT_GT = ">>>"
| show LT_LT_LT = "<<<"
| show EQUAL_EQUAL = "=="
| show SLASH_EQUAL = "/="
| show LT_GT = "<>"
| show LT_PLUS_GT = "<+>"
| show SUBMODULE = "submodule"
| show STRUCT = "struct"
| show SIG = "sig"
| show VAL = "val"
| show TYPE = "type"
| show MODULE = "module"
| show SIGNATURE = "signature"
| show INCLUDE = "include"
| show OPEN = "open"
| show WHERE = "where"
| show DATATYPE = "datatype"
| show OF = "of"
| show LET = "let"
| show IN = "in"
| show FUN = "fun"
| show FUNCTION = "function"
| show FUNCTOR = "functor"
| show IF = "if"
| show THEN = "then"
| show ELSE = "else"
| show FALSE = "false"
| show TRUE = "true"
| show MATCH = "match"
| show WITH = "with"
| show END = "end"
| show REC = "rec"
| show AND = "and"
| show PACK = "pack"
| show UNPACK = "unpack"
end