forked from boo-lang/boo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ast.model.boo
564 lines (440 loc) · 11.2 KB
/
ast.model.boo
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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
"""
The classes in this module model the entire AST for the language.
The actual AST classes and supporting modules are generated
by a boo script.
"""
namespace Boo.Ast
class CompileUnit(Node):
Modules as ModuleCollection
[Flags]
enum TypeMemberModifiers:
None = 0
Private = 1
Internal = 2
Protected = 4
Public = 8
Transient = 16
Static = 32
Final = 64
Virtual = 128
Override = 256
Abstract = 512
Partial = 1024
New = 2048
VisibilityMask = 15
enum MethodImplementationFlags:
None = 0
Runtime = 1
enum ParameterModifiers:
None = 0
Val = 0
Ref = 1
[Flags]
enum ExceptionHandlerFlags:
None = 0
Anonymous = 1
Untyped = 2
Filter = 4
[Flags]
enum GenericParameterConstraints:
None = 0
ValueType = 1
ReferenceType = 2
Constructable = 4
Covariant = 8
Contravariant = 16
abstract class TypeMember(Node, INodeWithAttributes):
Modifiers as TypeMemberModifiers
Name as string
Attributes as AttributeCollection
class TypeMemberStatement(Statement):
TypeMember as TypeMember
class ExplicitMemberInfo(Node):
InterfaceType as SimpleTypeReference
[collection(TypeMember)]
class TypeMemberCollection:
pass
abstract class TypeReference(Node):
IsPointer as bool
class SimpleTypeReference(TypeReference):
Name as string
class ArrayTypeReference(TypeReference):
ElementType as TypeReference
Rank as IntegerLiteralExpression
class CallableTypeReference(TypeReference, INodeWithParameters):
Parameters as ParameterDeclarationCollection
ReturnType as TypeReference
class GenericTypeReference(SimpleTypeReference):
GenericArguments as TypeReferenceCollection
class GenericTypeDefinitionReference(SimpleTypeReference):
GenericPlaceholders as int
[collection(TypeReference)]
class TypeReferenceCollection:
pass
class CallableDefinition(TypeMember, INodeWithParameters, INodeWithGenericParameters):
Parameters as ParameterDeclarationCollection
GenericParameters as GenericParameterDeclarationCollection
ReturnType as TypeReference
ReturnTypeAttributes as AttributeCollection
abstract class TypeDefinition(TypeMember, INodeWithGenericParameters):
Members as TypeMemberCollection
BaseTypes as TypeReferenceCollection
GenericParameters as GenericParameterDeclarationCollection
[collection(TypeDefinition)]
class TypeDefinitionCollection:
pass
class NamespaceDeclaration(Node):
Name as string
class Import(Node):
Expression as Expression
AssemblyReference as ReferenceExpression
Alias as ReferenceExpression
[collection(Import)]
class ImportCollection:
pass
class Module(TypeDefinition):
Namespace as NamespaceDeclaration
Imports as ImportCollection
[auto]
Globals as Block
AssemblyAttributes as AttributeCollection
[collection(Module)]
class ModuleCollection:
pass
class ClassDefinition(TypeDefinition):
pass
class StructDefinition(TypeDefinition):
pass
class InterfaceDefinition(TypeDefinition):
pass
class EnumDefinition(TypeDefinition):
pass
class EnumMember(TypeMember):
Initializer as Expression
class Field(TypeMember):
Type as TypeReference
Initializer as Expression
IsVolatile as bool
class Property(TypeMember, INodeWithParameters, IExplicitMember):
Parameters as ParameterDeclarationCollection
Getter as Method
Setter as Method
Type as TypeReference
ExplicitInfo as ExplicitMemberInfo
class Event(TypeMember):
Add as Method
Remove as Method
Raise as Method
Type as TypeReference
class Local(Node):
Name as string
[collection(Local)]
class LocalCollection:
pass
class BlockExpression(Expression, INodeWithParameters, INodeWithBody):
Parameters as ParameterDeclarationCollection
ReturnType as TypeReference
[auto]
Body as Block
class Method(CallableDefinition, IExplicitMember, INodeWithBody):
[auto]
Body as Block
Locals as LocalCollection
ImplementationFlags as MethodImplementationFlags
ExplicitInfo as ExplicitMemberInfo
class Constructor(Method):
pass
class Destructor(Method):
pass
class ParameterDeclaration(Node, INodeWithAttributes):
Name as string
Type as TypeReference
Modifiers as ParameterModifiers
Attributes as AttributeCollection
[collection(ParameterDeclaration)]
class ParameterDeclarationCollection:
pass
class GenericParameterDeclaration(Node):
Name as string
BaseTypes as TypeReferenceCollection
Constraints as GenericParameterConstraints
[collection(GenericParameterDeclaration)]
class GenericParameterDeclarationCollection:
pass
class Declaration(Node):
Name as string
Type as TypeReference
[collection(Declaration)]
class DeclarationCollection:
pass
class Attribute(Node, INodeWithArguments):
Name as string
Arguments as ExpressionCollection
NamedArguments as ExpressionPairCollection
[collection(Attribute)]
class AttributeCollection:
pass
enum StatementModifierType:
None
If
Unless
While
class StatementModifier(Node):
Type as StatementModifierType
Condition as Expression
abstract class Statement(Node):
Modifier as StatementModifier
class GotoStatement(Statement):
Label as ReferenceExpression
class LabelStatement(Statement):
Name as string
class Block(Statement):
Statements as StatementCollection
[collection(Statement)]
class StatementCollection:
pass
class DeclarationStatement(Statement):
Declaration as Declaration
Initializer as Expression
class MacroStatement(Statement, INodeWithBody):
Name as string
Arguments as ExpressionCollection
[auto]
Body as Block
class TryStatement(Statement):
[auto]
ProtectedBlock as Block
ExceptionHandlers as ExceptionHandlerCollection
FailureBlock as Block
EnsureBlock as Block
class ExceptionHandler(Node):
Declaration as Declaration
FilterCondition as Expression
Flags as ExceptionHandlerFlags
[auto]
Block as Block
[collection(ExceptionHandler)]
class ExceptionHandlerCollection:
pass
abstract class ConditionalStatement(Statement):
Condition as Expression
class IfStatement(ConditionalStatement):
TrueBlock as Block
FalseBlock as Block
class UnlessStatement(ConditionalStatement):
[auto]
Block as Block
class ForStatement(Statement):
Declarations as DeclarationCollection
Iterator as Expression
[auto]
Block as Block
OrBlock as Block
ThenBlock as Block
class WhileStatement(ConditionalStatement):
[auto]
Block as Block
OrBlock as Block
ThenBlock as Block
class BreakStatement(Statement):
pass
class ContinueStatement(Statement):
pass
class ReturnStatement(Statement):
Expression as Expression
class YieldStatement(Statement):
Expression as Expression
class RaiseStatement(Statement):
Exception as Expression
class UnpackStatement(Statement):
Declarations as DeclarationCollection
Expression as Expression
class ExpressionStatement(Statement):
[LexicalInfo]
Expression as Expression
abstract class Expression(Node):
pass
[collection(Expression)]
class ExpressionCollection:
pass
[ignore]
class OmittedExpression(Expression):
pass
class ExpressionPair(Node):
First as Expression
Second as Expression
[collection(ExpressionPair)]
class ExpressionPairCollection:
pass
class MethodInvocationExpression(Expression, INodeWithArguments):
Target as Expression
Arguments as ExpressionCollection
NamedArguments as ExpressionPairCollection
enum BinaryOperatorType:
None
Addition
Subtraction
Multiply
Division
Modulus
Exponentiation
LessThan
LessThanOrEqual
GreaterThan
GreaterThanOrEqual
Equality
Inequality
Match
NotMatch
Assign
InPlaceAddition
InPlaceSubtraction
InPlaceMultiply
InPlaceDivision
InPlaceModulus
InPlaceBitwiseAnd
InPlaceBitwiseOr
ReferenceEquality
ReferenceInequality
TypeTest
Member
NotMember
Or
And
BitwiseOr
BitwiseAnd
ExclusiveOr
InPlaceExclusiveOr
ShiftLeft
InPlaceShiftLeft
ShiftRight
InPlaceShiftRight
#values are ready to be used as mask if/when BinaryOperatorType
#is changed as in patch attached to BOO-1123 (breaking change)
enum BinaryOperatorKind:
Arithmetic = 0xF
Comparison = 0xFF0
TypeComparison = 0xF00
Assignment = 0xFF000
InPlaceAssignment = 0xF0000
Logical = 0x0F00000
Bitwise = 0xF000000
enum UnaryOperatorType:
None
UnaryNegation
Increment
Decrement
PostIncrement
PostDecrement
LogicalNot
Explode
OnesComplement
AddressOf
Indirection
class UnaryExpression(Expression):
Operator as UnaryOperatorType
Operand as Expression
class BinaryExpression(Expression):
Operator as BinaryOperatorType
Left as Expression
Right as Expression
class ConditionalExpression(Expression):
Condition as Expression
TrueValue as Expression
FalseValue as Expression
class ReferenceExpression(Expression):
Name as string
class MemberReferenceExpression(ReferenceExpression):
Target as Expression
class GenericReferenceExpression(Expression):
Target as Expression
GenericArguments as TypeReferenceCollection
abstract class LiteralExpression(Expression):
pass
class QuasiquoteExpression(LiteralExpression):
Node as Node
class StringLiteralExpression(LiteralExpression):
Value as string
class CharLiteralExpression(StringLiteralExpression):
pass
class TimeSpanLiteralExpression(LiteralExpression):
Value as System.TimeSpan
class IntegerLiteralExpression(LiteralExpression):
Value as long
IsLong as bool
class DoubleLiteralExpression(LiteralExpression):
Value as double
IsSingle as bool
class NullLiteralExpression(LiteralExpression):
pass
class SelfLiteralExpression(LiteralExpression):
pass
class SuperLiteralExpression(LiteralExpression):
pass
class BoolLiteralExpression(LiteralExpression):
Value as bool
class RELiteralExpression(LiteralExpression):
Value as string
class SpliceExpression(Expression):
Expression as Expression
class SpliceTypeReference(TypeReference):
Expression as Expression
class SpliceMemberReferenceExpression(Expression):
Target as Expression
NameExpression as Expression
class SpliceTypeMember(TypeMember):
TypeMember as TypeMember
NameExpression as Expression
class SpliceTypeDefinitionBody(TypeMember):
Expression as Expression
class SpliceParameterDeclaration(ParameterDeclaration):
ParameterDeclaration as ParameterDeclaration
NameExpression as Expression
class ExpressionInterpolationExpression(Expression):
Expressions as ExpressionCollection
class HashLiteralExpression(LiteralExpression):
Items as ExpressionPairCollection
class ListLiteralExpression(LiteralExpression):
Items as ExpressionCollection
class CollectionInitializationExpression(Expression):
Collection as Expression
Initializer as Expression
class ArrayLiteralExpression(ListLiteralExpression):
Type as ArrayTypeReference
class GeneratorExpression(Expression):
Expression as Expression
Declarations as DeclarationCollection
Iterator as Expression
Filter as StatementModifier
class ExtendedGeneratorExpression(Expression):
Items as GeneratorExpressionCollection
[collection(GeneratorExpression)]
class GeneratorExpressionCollection:
pass
class Slice(Node):
Begin as Expression
End as Expression
Step as Expression
[collection(Slice)]
class SliceCollection:
pass
class SlicingExpression(Expression):
Target as Expression
Indices as SliceCollection
class TryCastExpression(Expression):
Target as Expression
Type as TypeReference
class CastExpression(Expression):
Target as Expression
Type as TypeReference
class TypeofExpression(Expression):
Type as TypeReference
class CustomStatement(Statement):
pass
class CustomExpression(Expression):
pass
class StatementTypeMember(TypeMember):
"""
Allow for macros and initializing statements inside type definition bodies.
"""
Statement as Statement