-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathIAstNodeTypeMgr.cs
312 lines (243 loc) · 12.2 KB
/
IAstNodeTypeMgr.cs
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
/* M2Sharp -- Modula-2 to C# Translator & Compiler
*
* Copyright (c) 2016 The Modula-2 Software Foundation
*
* Author & Maintainer: Benjamin Kowarsch <trijezdci@org.m2sf>
*
* @synopsis
*
* M2Sharp is a multi-dialect Modula-2 to C# translator and via-C# compiler.
* It supports the dialects described in the 3rd and 4th editions of Niklaus
* Wirth's book "Programming in Modula-2" (PIM) published by Springer Verlag,
* and an extended mode with select features from the revised language by
* B.Kowarsch and R.Sutcliffe "Modula-2 Revision 2010" (M2R10).
*
* In translator mode, M2Sharp translates Modula-2 source to C# source files.
* In compiler mode, M2Sharp compiles Modula-2 source via C# source files
* to object code or executables using the host system's C# compiler.
*
* @repository
*
* https://github.com/m2sf/m2sharp
*
* @file
*
* IAstNodeTypeMgr.cs
*
* Public interface for AST node types and node type checks.
*
* @license
*
* M2Sharp is free software: you can redistribute and/or modify it under the
* terms of the GNU Lesser General Public License (LGPL) either version 2.1
* or at your choice version 3 as published by the Free Software Foundation.
* However, you may not alter the copyright, author and license information.
*
* M2Sharp is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. Read the license for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with M2Sharp. If not, see <https://www.gnu.org/copyleft/lesser.html>.
*
* NB: Components in the domain part of email addresses are in reverse order.
*/
namespace org.m2sf.m2sharp {
/* ---------------------------------------------------------------------------
* type AstNodeType
* ---------------------------------------------------------------------------
* Enumerated values representing AST node types.
* ------------------------------------------------------------------------ */
public enum AstNodeType {
/* Empty Node Type */
AST_EMPTY,
/* Root Node Type */
AST_ROOT,
/* Definition Module Non-Terminal Node Types */
AST_DEFMOD, /* definition module node type */
AST_IMPLIST, /* qualified import list node type */
AST_IMPORT, /* qualified import list node type */
AST_UNQIMP, /* unqualified import list node type */
AST_DEFLIST, /* definition list node type */
AST_CONSTDEF, /* constant definition node type */
AST_TYPEDEF, /* type definition node type */
AST_PROCDEF, /* procedure definition node type */
AST_SUBR, /* subrange type node type */
AST_ENUM, /* enumeration type node type */
AST_SET, /* set type node type */
AST_ARRAY, /* array type node type */
AST_RECORD, /* simple record type node type */
AST_POINTER, /* pointer type node type */
AST_PROCTYPE, /* procedure type node type */
AST_EXTREC, /* extensible record type node type */
AST_VRNTREC, /* variant record type node type */
AST_INDEXLIST, /* array index type list node type */
AST_FIELDLISTSEQ, /* field list sequence node type */
AST_FIELDLIST, /* field list node type */
AST_VFLISTSEQ, /* variant field list sequence node type */
AST_VFLIST, /* variant field list node type */
AST_VARIANTLIST, /* variant list node type */
AST_VARIANT, /* variant node type */
AST_CLABELLIST, /* case label list node type */
AST_CLABELS, /* case labels node type */
AST_FTYPELIST, /* formal type list node type */
AST_ARGLIST, /* variadic parameter list formal type node type */
AST_OPENARRAY, /* open array formal type node type */
AST_CONSTP, /* CONST formal type node type */
AST_VARP, /* VAR formal type node type */
AST_FPARAMLIST, /* formal parameter list node type */
AST_FPARAMS, /* formal parameters node type */
/* Implementation/Program Module AST Node Types */
AST_IMPMOD, /* implementation/program module node type */
AST_BLOCK, /* block node type */
AST_DECLLIST, /* declaration list node type */
AST_TYPEDECL, /* type declaration node type */
AST_VARDECL, /* variable declaration node type */
AST_PROC, /* procedure declaration node type */
AST_MODDECL, /* local module declaration node type */
AST_VSREC, /* variable size record type node type */
AST_VSFIELD, /* variable size field node type */
AST_EXPORT, /* unqualified export list node type */
AST_QUALEXP, /* qualified export list node type */
AST_STMTSEQ, /* statement sequence node type */
AST_ASSIGN, /* assignment node type */
AST_PCALL, /* procedure call node type */
AST_RETURN, /* RETURN statement node type */
AST_WITH, /* WITH statement node type */
AST_IF, /* IF statement node type */
AST_SWITCH, /* CASE statement node type */
AST_LOOP, /* LOOP statement node type */
AST_WHILE, /* WHILE statement node type */
AST_REPEAT, /* REPEAT statement node type */
AST_FORTO, /* FOR TO statement node type */
AST_EXIT, /* EXIT statement node type */
AST_ARGS, /* actual parameter list node type */
AST_ELSIFSEQ, /* ELSIF branch sequence node type */
AST_ELSIF, /* ELSIF branch node type */
AST_CASELIST, /* case list node type */
AST_CASE, /* case branch node type */
AST_ELEMLIST, /* element list node type */
AST_RANGE, /* expression range node type */
/* Designator Subnode Types */
AST_FIELD, /* record field selector node type */
AST_INDEX, /* array subscript node type */
/* Expression Node Types */
AST_DESIG, /* designator node type */
AST_DEREF, /* pointer dereference node type */
AST_NEG, /* arithmetic negation sub-expression node */
AST_NOT, /* logical negation sub-expression node */
AST_EQ, /* equality sub-expression node */
AST_NEQ, /* inequality sub-expression node */
AST_LT, /* less-than sub-expression node */
AST_LTEQ, /* less-than-or-equal sub-expression node */
AST_GT, /* greater-than sub-expression node */
AST_GTEQ, /* greater-than-or-equal sub-expression node */
AST_IN, /* set membership sub-expression node */
AST_PLUS, /* plus sub-expression node */
AST_MINUS, /* minus sub-expression node */
AST_OR, /* logical disjunction sub-expression node */
AST_ASTERISK, /* asterisk sub-expression node */
AST_SOLIDUS, /* solidus sub-expression node */
AST_DIV, /* euclidean division sub-expression node */
AST_MOD, /* modulus sub-expression node */
AST_AND, /* logical conjunction expression node */
AST_FCALL, /* function call node */
AST_SETVAL, /* set value node */
/* Identifier Node Types */
AST_IDENT, /* identifier node type */
AST_QUALIDENT, /* qualified identifier node type */
/* Literal Value Node Types */
AST_INTVAL, /* whole number value node */
AST_REALVAL, /* real number value node */
AST_CHRVAL, /* character code value node */
AST_QUOTEDVAL, /* quoted literal value node */
AST_IDENTLIST, /* identifier list node type */
/* Compilation Parameter Node Types */
AST_FILENAME, /* filename node type */
AST_OPTIONS, /* compiler option list node type */
/* Invalid Node Type */
AST_INVALID /* for use as failure indicator */
} /* AstNodeType */
/* ---------------------------------------------------------------------------
* AST node type groupings.
* ---------------------------------------------------------------------------
* first valid node type : AST_EMPTY
* last valid node type : AST_QUOTEDVAL
*
* first non-terminal node type : AST_EMPTY
* last non-terminal node type : AST_SETVAL
*
* first terminal node type : AST_INTVAL
* last terminal node type : AST_OPTIONS
*
* first definition node type : AST_CONSTDEF
* last definition node type : AST_PROCDEF
*
* first type definition node type : AST_SUBR
* last type definition node type : AST_VRNTREC
*
* first field type node type : AST_SUBR
* last field type node type : AST_PROCTYPE
*
* first declaration node type : AST_TYPEDECL
* last declaration node type : AST_MODDECL
*
* first statement node type : AST_ASSIGN
* last statement node type : AST_EXIT
*
* first expression node type : AST_DESIG
* last expression node type : AST_QUOTEDVAL
*
* first literal node type : AST_INTVAL
* last literal node type : AST_QUOTEDVAL
* ------------------------------------------------------------------------ */
public interface IAstNodeTypeMgr {
/* ---------------------------------------------------------------------------
* method IsValid(nodeType)
* ---------------------------------------------------------------------------
* Returns true if nodeType is a valid node type, otherwise false.
* ------------------------------------------------------------------------ */
bool IsValid(AstNodeType nodeType);
/* ---------------------------------------------------------------------------
* method IsNonterminalType(nodeType)
* ---------------------------------------------------------------------------
* Returns true if nodeType is a nonterminal node type, otherwise false.
* ------------------------------------------------------------------------ */
bool IsNonterminalType (AstNodeType nodeType);
/* ---------------------------------------------------------------------------
* method IsTerminalType(nodeType)
* ---------------------------------------------------------------------------
* Returns true if nodeType is a terminal node type, otherwise false.
* ------------------------------------------------------------------------ */
bool IsTerminalType (AstNodeType nodeType);
/* ---------------------------------------------------------------------------
* method IsListType(nodeType)
* ---------------------------------------------------------------------------
* Returns true if nodeType is a list node type, otherwise false.
* ------------------------------------------------------------------------ */
bool IsListType (AstNodeType nodeType);
/* ---------------------------------------------------------------------------
* method IsLegalSubnodeCount(nodeType, subnodeCount)
* ---------------------------------------------------------------------------
* Returns true if the given subnode count is a legal value for the given
* node type, otherwise false.
* ------------------------------------------------------------------------ */
bool IsLegalSubnodeCount (AstNodeType nodeType, int SubnodeCount);
/* ---------------------------------------------------------------------------
* method IsLegalSubnodeType(inNodeType, subnodeType, index)
* ---------------------------------------------------------------------------
* Returns true if the given subnode type is a legal node type for the given
* index in a node of the given subnode type, otherwise false.
* ------------------------------------------------------------------------ */
bool IsLegalSubnodeType
(AstNodeType inNodeType, AstNodeType subnodeType, int index);
/* ---------------------------------------------------------------------------
* method NameForNodeType(nodeType)
* ---------------------------------------------------------------------------
* Returns a string with a human readable name for nodeType or null if the
* given node type is invalid.
* ------------------------------------------------------------------------ */
string NameForNodeType (AstNodeType nodeType);
} /* IAstNodeTypeMgr */
} /* namespace */
/* END OF FILE */