Mercurial > projects > dil
annotate trunk/src/dil/ast/Node.d @ 612:c65b11c2074c
Added getDocComments() to class Node.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Mon, 07 Jan 2008 20:36:08 +0100 |
parents | 39fac5531b85 |
children | 7034d3f9e40c |
rev | line source |
---|---|
142 | 1 /++ |
2 Author: Aziz Köksal | |
249 | 3 License: GPL3 |
142 | 4 +/ |
580
fa6d3c52757d
Moved SyntaxTree.d to new package 'ast'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
543
diff
changeset
|
5 module dil.ast.Node; |
596
39fac5531b85
Moved dil.Token to dil.lexer.Token.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
580
diff
changeset
|
6 |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
374
diff
changeset
|
7 import common; |
142 | 8 |
596
39fac5531b85
Moved dil.Token to dil.lexer.Token.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
580
diff
changeset
|
9 public import dil.lexer.Token; |
39fac5531b85
Moved dil.Token to dil.lexer.Token.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
580
diff
changeset
|
10 |
275 | 11 enum NodeCategory |
142 | 12 { |
13 Declaration, | |
14 Statement, | |
15 Expression, | |
242
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
189
diff
changeset
|
16 Type, |
7ec7ad8df9da
- Changed type of member tok in class BinaryExpression to Token*.
aziz
parents:
189
diff
changeset
|
17 Other |
142 | 18 } |
19 | |
276
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
20 enum NodeKind |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
21 { |
278 | 22 // Declarations: |
305 | 23 Declarations, |
278 | 24 EmptyDeclaration, |
25 IllegalDeclaration, | |
26 ModuleDeclaration, | |
27 ImportDeclaration, | |
28 AliasDeclaration, | |
29 TypedefDeclaration, | |
30 EnumDeclaration, | |
31 ClassDeclaration, | |
32 InterfaceDeclaration, | |
33 StructDeclaration, | |
34 UnionDeclaration, | |
35 ConstructorDeclaration, | |
36 StaticConstructorDeclaration, | |
37 DestructorDeclaration, | |
38 StaticDestructorDeclaration, | |
39 FunctionDeclaration, | |
40 VariableDeclaration, | |
41 InvariantDeclaration, | |
42 UnittestDeclaration, | |
43 DebugDeclaration, | |
44 VersionDeclaration, | |
45 StaticIfDeclaration, | |
46 StaticAssertDeclaration, | |
47 TemplateDeclaration, | |
48 NewDeclaration, | |
49 DeleteDeclaration, | |
50 AttributeDeclaration, | |
490
47be6bfe39cd
Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
489
diff
changeset
|
51 ProtectionDeclaration, |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
492
diff
changeset
|
52 StorageClassDeclaration, |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
492
diff
changeset
|
53 LinkageDeclaration, |
278 | 54 AlignDeclaration, |
55 PragmaDeclaration, | |
56 MixinDeclaration, | |
57 | |
58 // Statements: | |
59 Statements, | |
60 IllegalStatement, | |
61 EmptyStatement, | |
62 ScopeStatement, | |
63 LabeledStatement, | |
64 ExpressionStatement, | |
65 DeclarationStatement, | |
66 IfStatement, | |
67 ConditionalStatement, | |
68 WhileStatement, | |
69 DoWhileStatement, | |
70 ForStatement, | |
71 ForeachStatement, | |
72 ForeachRangeStatement, // D2.0 | |
73 SwitchStatement, | |
74 CaseStatement, | |
75 DefaultStatement, | |
76 ContinueStatement, | |
77 BreakStatement, | |
78 ReturnStatement, | |
79 GotoStatement, | |
80 WithStatement, | |
81 SynchronizedStatement, | |
82 TryStatement, | |
83 CatchBody, | |
84 FinallyBody, | |
85 ScopeGuardStatement, | |
86 ThrowStatement, | |
87 VolatileStatement, | |
88 AsmStatement, | |
285 | 89 AsmInstruction, |
374 | 90 AsmAlignStatement, |
285 | 91 IllegalAsmInstruction, |
278 | 92 PragmaStatement, |
93 MixinStatement, | |
94 StaticIfStatement, | |
95 StaticAssertStatement, | |
96 DebugStatement, | |
97 VersionStatement, | |
98 | |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
276
diff
changeset
|
99 // Expressions: |
276
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
100 EmptyExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
101 BinaryExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
102 CondExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
103 CommaExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
104 OrOrExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
105 AndAndExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
106 OrExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
107 XorExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
108 AndExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
109 CmpExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
110 EqualExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
111 IdentityExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
112 RelExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
113 InExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
114 LShiftExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
115 RShiftExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
116 URShiftExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
117 PlusExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
118 MinusExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
119 CatExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
120 MulExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
121 DivExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
122 ModExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
123 AssignExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
124 LShiftAssignExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
125 RShiftAssignExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
126 URShiftAssignExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
127 OrAssignExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
128 AndAssignExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
129 PlusAssignExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
130 MinusAssignExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
131 DivAssignExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
132 MulAssignExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
133 ModAssignExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
134 XorAssignExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
135 CatAssignExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
136 UnaryExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
137 AddressExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
138 PreIncrExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
139 PreDecrExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
140 PostIncrExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
141 PostDecrExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
142 DerefExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
143 SignExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
144 NotExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
145 CompExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
146 PostDotListExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
147 CallExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
148 NewExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
149 NewAnonClassExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
150 DeleteExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
151 CastExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
152 IndexExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
153 SliceExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
154 PrimaryExpressio, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
155 IdentifierExpression, |
312 | 156 SpecialTokenExpression, |
488
cfb3805768b6
Added DotExpression and DotType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
409
diff
changeset
|
157 DotExpression, |
276
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
158 DotListExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
159 TemplateInstanceExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
160 ThisExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
161 SuperExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
162 NullExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
163 DollarExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
164 BoolExpression, |
399
ff1d11c27061
Renamed some Expression classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
165 IntExpression, |
ff1d11c27061
Renamed some Expression classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
166 RealExpression, |
543
c9579ea87228
Added ComplexExpression to enum NodeKind and setToks() to Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
516
diff
changeset
|
167 ComplexExpression, |
399
ff1d11c27061
Renamed some Expression classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
168 CharExpression, |
ff1d11c27061
Renamed some Expression classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
169 StringExpression, |
276
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
170 ArrayLiteralExpression, |
399
ff1d11c27061
Renamed some Expression classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
171 AArrayLiteralExpression, |
276
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
172 AssertExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
173 MixinExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
174 ImportExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
175 TypeofExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
176 TypeDotIdExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
177 TypeidExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
178 IsExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
179 FunctionLiteralExpression, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
180 TraitsExpression, // D2.0 |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
181 VoidInitializer, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
182 ArrayInitializer, |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
183 StructInitializer, |
287
211bdd69397d
- Added classes AsmTypeExpression, AsmOffsetExpression, AsmSegExpression, AsmPostBracketExpression and AsmBracketExpression.
aziz
parents:
285
diff
changeset
|
184 AsmTypeExpression, |
211bdd69397d
- Added classes AsmTypeExpression, AsmOffsetExpression, AsmSegExpression, AsmPostBracketExpression and AsmBracketExpression.
aziz
parents:
285
diff
changeset
|
185 AsmOffsetExpression, |
211bdd69397d
- Added classes AsmTypeExpression, AsmOffsetExpression, AsmSegExpression, AsmPostBracketExpression and AsmBracketExpression.
aziz
parents:
285
diff
changeset
|
186 AsmSegExpression, |
211bdd69397d
- Added classes AsmTypeExpression, AsmOffsetExpression, AsmSegExpression, AsmPostBracketExpression and AsmBracketExpression.
aziz
parents:
285
diff
changeset
|
187 AsmPostBracketExpression, |
211bdd69397d
- Added classes AsmTypeExpression, AsmOffsetExpression, AsmSegExpression, AsmPostBracketExpression and AsmBracketExpression.
aziz
parents:
285
diff
changeset
|
188 AsmBracketExpression, |
288
833b301497f4
- Added classes AsmLocalSizeExpression and AsmRegisterExpression.
aziz
parents:
287
diff
changeset
|
189 AsmLocalSizeExpression, |
833b301497f4
- Added classes AsmLocalSizeExpression and AsmRegisterExpression.
aziz
parents:
287
diff
changeset
|
190 AsmRegisterExpression, |
277
38a68e534a3b
- Made classes Declaration, Expression and Statement abstract.
aziz
parents:
276
diff
changeset
|
191 |
281 | 192 // Types: |
193 IntegralType, | |
194 UndefinedType, | |
488
cfb3805768b6
Added DotExpression and DotType.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
409
diff
changeset
|
195 DotType, |
281 | 196 DotListType, |
197 IdentifierType, | |
198 TypeofType, | |
199 TemplateInstanceType, | |
200 PointerType, | |
201 ArrayType, | |
202 FunctionType, | |
203 DelegateType, | |
409
38fccd2640eb
Added code for parsing C function pointer declarations.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
406
diff
changeset
|
204 CFuncPointerType, |
281 | 205 ConstType, // D2.0 |
206 InvariantType, // D2.0 | |
207 | |
208 // Other: | |
278 | 209 FunctionBody, |
281 | 210 Parameter, |
211 Parameters, | |
212 BaseClass, | |
340
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
213 TemplateAliasParameter, |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
214 TemplateTypeParameter, |
492
9c208925a3d4
Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
490
diff
changeset
|
215 TemplateThisParameter, // D2.0 |
340
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
216 TemplateValueParameter, |
1accb3013bd2
- Changed class TemplateParameter to an abstract class.
aziz
parents:
327
diff
changeset
|
217 TemplateTupleParameter, |
281 | 218 TemplateParameters, |
219 TemplateArguments, | |
406
e242f0ee2d27
Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
399
diff
changeset
|
220 EnumMember, |
276
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
221 } |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
222 |
281 | 223 /// This string is mixed into the constructor of a class that inherits from Node. |
276
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
224 const string set_kind = `this.kind = mixin("NodeKind." ~ typeof(this).stringof);`; |
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
225 |
516
433d51c18524
Renamed template Cast to TryCast.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
495
diff
changeset
|
226 Class TryCast(Class)(Node n) |
309 | 227 { |
228 assert(n !is null); | |
229 if (n.kind == mixin("NodeKind." ~ typeof(Class).stringof)) | |
230 return cast(Class)cast(void*)n; | |
231 return null; | |
232 } | |
233 | |
495
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
492
diff
changeset
|
234 Class CastTo(Class)(Node n) |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
492
diff
changeset
|
235 { |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
492
diff
changeset
|
236 assert(n !is null && n.kind == mixin("NodeKind." ~ typeof(Class).stringof)); |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
492
diff
changeset
|
237 return cast(Class)cast(void*)n; |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
492
diff
changeset
|
238 } |
b60450804b6e
Attributes are evaluated during the parsing phase now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
492
diff
changeset
|
239 |
142 | 240 class Node |
241 { | |
275 | 242 NodeCategory category; |
276
d6b2f7616ca5
- Added enum NodeKind to classify different nodes in the AST. Correspondingly added member 'kind' to class Node.
aziz
parents:
275
diff
changeset
|
243 NodeKind kind; |
292 | 244 Node[] children; |
189 | 245 Token* begin, end; |
246 | |
275 | 247 this(NodeCategory category) |
142 | 248 { |
275 | 249 this.category = category; |
142 | 250 } |
189 | 251 |
252 void setTokens(Token* begin, Token* end) | |
253 { | |
254 this.begin = begin; | |
255 this.end = end; | |
256 } | |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
257 |
543
c9579ea87228
Added ComplexExpression to enum NodeKind and setToks() to Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
516
diff
changeset
|
258 Class setToks(Class)(Class node) |
c9579ea87228
Added ComplexExpression to enum NodeKind and setToks() to Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
516
diff
changeset
|
259 { |
c9579ea87228
Added ComplexExpression to enum NodeKind and setToks() to Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
516
diff
changeset
|
260 node.setTokens(this.begin, this.end); |
c9579ea87228
Added ComplexExpression to enum NodeKind and setToks() to Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
516
diff
changeset
|
261 return node; |
c9579ea87228
Added ComplexExpression to enum NodeKind and setToks() to Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
516
diff
changeset
|
262 } |
c9579ea87228
Added ComplexExpression to enum NodeKind and setToks() to Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
516
diff
changeset
|
263 |
489
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
264 void addChild(Node child) |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
265 { |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
266 assert(child !is null, "failed in " ~ this.classinfo.name); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
267 this.children ~= child; |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
268 } |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
269 |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
270 void addOptChild(Node child) |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
271 { |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
272 child is null || addChild(child); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
273 } |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
274 |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
275 void addChildren(Node[] children) |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
276 { |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
277 assert(children !is null && delegate{ |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
278 foreach (child; children) |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
279 if (child is null) |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
280 return false; |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
281 return true; }(), |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
282 "failed in " ~ this.classinfo.name |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
283 ); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
284 this.children ~= children; |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
285 } |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
286 |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
287 void addOptChildren(Node[] children) |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
288 { |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
289 children is null || addChildren(children); |
a7291d3ee9d7
Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
488
diff
changeset
|
290 } |
612
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
291 |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
292 static bool isDoxygenComment(Token* token) |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
293 { // Doxygen: '/+!' '/*!' '//!' |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
294 return token.type == TOK.Comment && token.start[2] == '!'; |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
295 } |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
296 |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
297 static bool isDDocComment(Token* token) |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
298 { // DDOC: '/++' '/**' '///' |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
299 return token.type == TOK.Comment && token.start[1] == token.start[2]; |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
300 } |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
301 |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
302 /++ |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
303 Returns the surrounding documentation comment tokens. |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
304 Note: this function works correctly only if |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
305 the source text is syntactically correct. |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
306 +/ |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
307 Token*[] getDocComments(bool function(Token*) isDocComment = &isDDocComment) |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
308 { |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
309 Token*[] comments; |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
310 // Get comment to the right. |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
311 auto token = end.next; |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
312 if (token.type == TOK.Comment && |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
313 isDocComment(token)) |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
314 comments ~= token; |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
315 // Get preceding comments. |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
316 token = begin; |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
317 // Scan backwards until we hit another declaration. |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
318 while (1) |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
319 { |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
320 token = token.prev; |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
321 if (token.type == TOK.LBrace || |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
322 token.type == TOK.RBrace || |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
323 token.type == TOK.Semicolon || |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
324 token.type == TOK.HEAD) |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
325 break; |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
326 if (token.type == TOK.Comment) |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
327 { |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
328 // Check that this comment doesn't belong to the previous declaration. |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
329 switch (token.prev.type) |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
330 { |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
331 case TOK.Semicolon, TOK.RBrace: |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
332 break; |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
333 default: |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
334 if (isDocComment(token)) |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
335 comments ~= token; |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
336 } |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
337 } |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
338 } |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
339 return comments; |
c65b11c2074c
Added getDocComments() to class Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
340 } |
142 | 341 } |