annotate trunk/src/dil/Declarations.d @ 492:9c208925a3d4

Added module ImportParser and new stuff from DMD2.008. Moved ImportParser from module Parser to its own module. Added a few methods from class Parser and simplified them. Now protection attributes are taken into consideration as well. Added class TemplateThisParameter. Adapted TypeofType so that typeof(return) can be recognized.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Thu, 06 Dec 2007 22:19:55 +0100
parents 47be6bfe39cd
children 9a7ca8c56e59
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
102
6e8b67ae15b7 - Added modules Declarations and Statements.
aziz
parents:
diff changeset
1 /++
6e8b67ae15b7 - Added modules Declarations and Statements.
aziz
parents:
diff changeset
2 Author: Aziz Köksal
249
32d354584b28 - Upgraded license notices to GPL3.
aziz
parents: 245
diff changeset
3 License: GPL3
102
6e8b67ae15b7 - Added modules Declarations and Statements.
aziz
parents:
diff changeset
4 +/
326
4a7359b88c11 - Added package 'dil' to module declarations.
aziz
parents: 325
diff changeset
5 module dil.Declarations;
327
a48a987f7515 - Added package dil to import declarations.
aziz
parents: 326
diff changeset
6 import dil.SyntaxTree;
a48a987f7515 - Added package dil to import declarations.
aziz
parents: 326
diff changeset
7 import dil.Expressions;
a48a987f7515 - Added package dil to import declarations.
aziz
parents: 326
diff changeset
8 import dil.Types;
a48a987f7515 - Added package dil to import declarations.
aziz
parents: 326
diff changeset
9 import dil.Statements;
a48a987f7515 - Added package dil to import declarations.
aziz
parents: 326
diff changeset
10 import dil.Token;
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
11 import dil.Enums;
486
bd176bc73e43 Fixed a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 461
diff changeset
12 import dil.Scope;
102
6e8b67ae15b7 - Added modules Declarations and Statements.
aziz
parents:
diff changeset
13
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
14 abstract class Declaration : Node
102
6e8b67ae15b7 - Added modules Declarations and Statements.
aziz
parents:
diff changeset
15 {
126
0f0e7352e91d - Renamed member hasDefinition of class Declaration to hasBody.
aziz
parents: 125
diff changeset
16 bool hasBody;
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
17 this()
116
f0c1883cdd4c - Added member hasDefinition to class Declaration.
aziz
parents: 114
diff changeset
18 {
275
e8de572e4d01 - Changed enum NodeType to NodeCategory.
aziz
parents: 265
diff changeset
19 super(NodeCategory.Declaration);
116
f0c1883cdd4c - Added member hasDefinition to class Declaration.
aziz
parents: 114
diff changeset
20 }
486
bd176bc73e43 Fixed a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 461
diff changeset
21
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
22 // Members relevant to semantic phase.
490
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
23 StorageClass stc; /// The storage class of this declaration.
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
24 Protection prot; /// The protection attribute of this declaration.
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
25
486
bd176bc73e43 Fixed a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 461
diff changeset
26 void semantic(Scope sc)
bd176bc73e43 Fixed a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 461
diff changeset
27 {
bd176bc73e43 Fixed a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 461
diff changeset
28 // foreach (node; this.children)
bd176bc73e43 Fixed a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 461
diff changeset
29 // if (node.category == NodeCategory.Declaration)
bd176bc73e43 Fixed a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 461
diff changeset
30 // (cast(Declaration)cast(void*)node).semantic(sc);
bd176bc73e43 Fixed a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 461
diff changeset
31 }
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
32
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
33 final bool isStatic()
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
34 {
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
35 return !!(stc & StorageClass.Static);
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
36 }
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
37
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
38 final bool isPublic()
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
39 {
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
40 return !!(prot & Protection.Public);
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
41 }
102
6e8b67ae15b7 - Added modules Declarations and Statements.
aziz
parents:
diff changeset
42 }
6e8b67ae15b7 - Added modules Declarations and Statements.
aziz
parents:
diff changeset
43
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
44 class Declarations : Declaration
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
45 {
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
46 this()
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
47 {
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
48 hasBody = true;
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
49 mixin(set_kind);
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
50 }
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
51
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
52 void opCatAssign(Declaration d)
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
53 {
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
54 addChild(d);
486
bd176bc73e43 Fixed a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 461
diff changeset
55 }
bd176bc73e43 Fixed a few things in the Parser.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 461
diff changeset
56
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
57 void opCatAssign(Declarations ds)
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
58 {
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
59 addChildren(ds.children);
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
60 }
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
61 }
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
62
129
a9244d409652 - Added class EmptyDeclaration.
aziz
parents: 127
diff changeset
63 class EmptyDeclaration : Declaration
a9244d409652 - Added class EmptyDeclaration.
aziz
parents: 127
diff changeset
64 {
a9244d409652 - Added class EmptyDeclaration.
aziz
parents: 127
diff changeset
65 this()
a9244d409652 - Added class EmptyDeclaration.
aziz
parents: 127
diff changeset
66 {
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
67 mixin(set_kind);
129
a9244d409652 - Added class EmptyDeclaration.
aziz
parents: 127
diff changeset
68 }
a9244d409652 - Added class EmptyDeclaration.
aziz
parents: 127
diff changeset
69 }
a9244d409652 - Added class EmptyDeclaration.
aziz
parents: 127
diff changeset
70
211
d64413278bec - Added class IllegalDeclaration.
aziz
parents: 197
diff changeset
71 class IllegalDeclaration : Declaration
d64413278bec - Added class IllegalDeclaration.
aziz
parents: 197
diff changeset
72 {
292
076152e945e0 - Added member Node[] children to class Node.
aziz
parents: 290
diff changeset
73 Token* token;
076152e945e0 - Added member Node[] children to class Node.
aziz
parents: 290
diff changeset
74 this(Token* token)
211
d64413278bec - Added class IllegalDeclaration.
aziz
parents: 197
diff changeset
75 {
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
76 mixin(set_kind);
292
076152e945e0 - Added member Node[] children to class Node.
aziz
parents: 290
diff changeset
77 this.token = token;
211
d64413278bec - Added class IllegalDeclaration.
aziz
parents: 197
diff changeset
78 }
d64413278bec - Added class IllegalDeclaration.
aziz
parents: 197
diff changeset
79 }
d64413278bec - Added class IllegalDeclaration.
aziz
parents: 197
diff changeset
80
364
1059295c2727 - Every command module has an execute method now.
aziz
parents: 359
diff changeset
81 /// FQN = fully qualified name
1059295c2727 - Every command module has an execute method now.
aziz
parents: 359
diff changeset
82 alias Token*[] ModuleFQN; // Identifier(.Identifier)*
114
83bb5190c0fc - Completed implementation of parseImportDeclaration().
aziz
parents: 113
diff changeset
83
102
6e8b67ae15b7 - Added modules Declarations and Statements.
aziz
parents:
diff changeset
84 class ModuleDeclaration : Declaration
6e8b67ae15b7 - Added modules Declarations and Statements.
aziz
parents:
diff changeset
85 {
364
1059295c2727 - Every command module has an execute method now.
aziz
parents: 359
diff changeset
86 Token* moduleName;
1059295c2727 - Every command module has an execute method now.
aziz
parents: 359
diff changeset
87 Token*[] packages;
1059295c2727 - Every command module has an execute method now.
aziz
parents: 359
diff changeset
88 this(ModuleFQN moduleFQN)
102
6e8b67ae15b7 - Added modules Declarations and Statements.
aziz
parents:
diff changeset
89 {
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
90 mixin(set_kind);
365
ed67acc82268 - Added option includes to config.d.
aziz
parents: 364
diff changeset
91 assert(moduleFQN.length != 0);
ed67acc82268 - Added option includes to config.d.
aziz
parents: 364
diff changeset
92 this.moduleName = moduleFQN[$-1];
ed67acc82268 - Added option includes to config.d.
aziz
parents: 364
diff changeset
93 this.packages = moduleFQN[0..$-1];
ed67acc82268 - Added option includes to config.d.
aziz
parents: 364
diff changeset
94 }
ed67acc82268 - Added option includes to config.d.
aziz
parents: 364
diff changeset
95
391
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 377
diff changeset
96 char[] getFQN()
370
ae4afb66768f - Renamed findModule() to findModulePath().
aziz
parents: 367
diff changeset
97 {
ae4afb66768f - Renamed findModule() to findModulePath().
aziz
parents: 367
diff changeset
98 auto pname = getPackageName('.');
ae4afb66768f - Renamed findModule() to findModulePath().
aziz
parents: 367
diff changeset
99 if (pname.length)
ae4afb66768f - Renamed findModule() to findModulePath().
aziz
parents: 367
diff changeset
100 return pname ~ "." ~ getName();
ae4afb66768f - Renamed findModule() to findModulePath().
aziz
parents: 367
diff changeset
101 else
ae4afb66768f - Renamed findModule() to findModulePath().
aziz
parents: 367
diff changeset
102 return getName();
ae4afb66768f - Renamed findModule() to findModulePath().
aziz
parents: 367
diff changeset
103 }
ae4afb66768f - Renamed findModule() to findModulePath().
aziz
parents: 367
diff changeset
104
391
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 377
diff changeset
105 char[] getName()
365
ed67acc82268 - Added option includes to config.d.
aziz
parents: 364
diff changeset
106 {
ed67acc82268 - Added option includes to config.d.
aziz
parents: 364
diff changeset
107 if (moduleName)
ed67acc82268 - Added option includes to config.d.
aziz
parents: 364
diff changeset
108 return moduleName.identifier;
ed67acc82268 - Added option includes to config.d.
aziz
parents: 364
diff changeset
109 return null;
ed67acc82268 - Added option includes to config.d.
aziz
parents: 364
diff changeset
110 }
ed67acc82268 - Added option includes to config.d.
aziz
parents: 364
diff changeset
111
391
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 377
diff changeset
112 char[] getPackageName(char separator)
365
ed67acc82268 - Added option includes to config.d.
aziz
parents: 364
diff changeset
113 {
ed67acc82268 - Added option includes to config.d.
aziz
parents: 364
diff changeset
114 char[] pname;
ed67acc82268 - Added option includes to config.d.
aziz
parents: 364
diff changeset
115 foreach (pckg; packages)
ed67acc82268 - Added option includes to config.d.
aziz
parents: 364
diff changeset
116 if (pckg)
ed67acc82268 - Added option includes to config.d.
aziz
parents: 364
diff changeset
117 pname ~= pckg.identifier ~ separator;
367
dda55fae37de - ImportGraph.execute() can parse all modules depending on the imports of the root module.
aziz
parents: 366
diff changeset
118 if (pname.length)
dda55fae37de - ImportGraph.execute() can parse all modules depending on the imports of the root module.
aziz
parents: 366
diff changeset
119 pname = pname[0..$-1]; // Remove last separator
365
ed67acc82268 - Added option includes to config.d.
aziz
parents: 364
diff changeset
120 return pname;
114
83bb5190c0fc - Completed implementation of parseImportDeclaration().
aziz
parents: 113
diff changeset
121 }
83bb5190c0fc - Completed implementation of parseImportDeclaration().
aziz
parents: 113
diff changeset
122 }
83bb5190c0fc - Completed implementation of parseImportDeclaration().
aziz
parents: 113
diff changeset
123
83bb5190c0fc - Completed implementation of parseImportDeclaration().
aziz
parents: 113
diff changeset
124 class ImportDeclaration : Declaration
83bb5190c0fc - Completed implementation of parseImportDeclaration().
aziz
parents: 113
diff changeset
125 {
364
1059295c2727 - Every command module has an execute method now.
aziz
parents: 359
diff changeset
126 ModuleFQN[] moduleFQNs;
263
ebcf7941f1db - Changed some string types to Token*.
aziz
parents: 262
diff changeset
127 Token*[] moduleAliases;
ebcf7941f1db - Changed some string types to Token*.
aziz
parents: 262
diff changeset
128 Token*[] bindNames;
ebcf7941f1db - Changed some string types to Token*.
aziz
parents: 262
diff changeset
129 Token*[] bindAliases;
461
c78a54b2617c Added isStatic() and isPublic() to ImportDeclaration.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 406
diff changeset
130
366
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 365
diff changeset
131 this(ModuleFQN[] moduleFQNs, Token*[] moduleAliases, Token*[] bindNames, Token*[] bindAliases, bool isStatic)
114
83bb5190c0fc - Completed implementation of parseImportDeclaration().
aziz
parents: 113
diff changeset
132 {
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
133 mixin(set_kind);
364
1059295c2727 - Every command module has an execute method now.
aziz
parents: 359
diff changeset
134 this.moduleFQNs = moduleFQNs;
114
83bb5190c0fc - Completed implementation of parseImportDeclaration().
aziz
parents: 113
diff changeset
135 this.moduleAliases = moduleAliases;
83bb5190c0fc - Completed implementation of parseImportDeclaration().
aziz
parents: 113
diff changeset
136 this.bindNames = bindNames;
83bb5190c0fc - Completed implementation of parseImportDeclaration().
aziz
parents: 113
diff changeset
137 this.bindAliases = bindAliases;
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
138 if (isStatic)
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
139 this.stc |= StorageClass.Static;
366
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 365
diff changeset
140 }
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 365
diff changeset
141
391
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 377
diff changeset
142 char[][] getModuleFQNs(char separator)
366
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 365
diff changeset
143 {
391
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 377
diff changeset
144 char[][] FQNs;
366
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 365
diff changeset
145 foreach (moduleFQN; moduleFQNs)
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 365
diff changeset
146 {
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 365
diff changeset
147 char[] FQN;
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 365
diff changeset
148 foreach (ident; moduleFQN)
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 365
diff changeset
149 if (ident)
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 365
diff changeset
150 FQN ~= ident.identifier ~ separator;
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 365
diff changeset
151 FQNs ~= FQN[0..$-1]; // Remove last separator
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 365
diff changeset
152 }
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 365
diff changeset
153 return FQNs;
102
6e8b67ae15b7 - Added modules Declarations and Statements.
aziz
parents:
diff changeset
154 }
6e8b67ae15b7 - Added modules Declarations and Statements.
aziz
parents:
diff changeset
155 }
6e8b67ae15b7 - Added modules Declarations and Statements.
aziz
parents:
diff changeset
156
191
3ce110cefbc5 - Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents: 161
diff changeset
157 class AliasDeclaration : Declaration
3ce110cefbc5 - Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents: 161
diff changeset
158 {
3ce110cefbc5 - Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents: 161
diff changeset
159 Declaration decl;
3ce110cefbc5 - Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents: 161
diff changeset
160 this(Declaration decl)
3ce110cefbc5 - Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents: 161
diff changeset
161 {
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
162 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
163 addChild(decl);
191
3ce110cefbc5 - Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents: 161
diff changeset
164 this.decl = decl;
3ce110cefbc5 - Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents: 161
diff changeset
165 }
3ce110cefbc5 - Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents: 161
diff changeset
166 }
3ce110cefbc5 - Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents: 161
diff changeset
167
3ce110cefbc5 - Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents: 161
diff changeset
168 class TypedefDeclaration : Declaration
3ce110cefbc5 - Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents: 161
diff changeset
169 {
3ce110cefbc5 - Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents: 161
diff changeset
170 Declaration decl;
3ce110cefbc5 - Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents: 161
diff changeset
171 this(Declaration decl)
3ce110cefbc5 - Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents: 161
diff changeset
172 {
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
173 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
174 addChild(decl);
191
3ce110cefbc5 - Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents: 161
diff changeset
175 this.decl = decl;
3ce110cefbc5 - Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents: 161
diff changeset
176 }
3ce110cefbc5 - Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents: 161
diff changeset
177 }
3ce110cefbc5 - Added code for parsing AliasDeclaration and TypedefDeclaration.
aziz
parents: 161
diff changeset
178
107
722c05bbd5eb - Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents: 102
diff changeset
179 class EnumDeclaration : Declaration
722c05bbd5eb - Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents: 102
diff changeset
180 {
264
50cc74026ea8 - Changed some string types to Token*.
aziz
parents: 263
diff changeset
181 Token* name;
107
722c05bbd5eb - Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents: 102
diff changeset
182 Type baseType;
406
e242f0ee2d27 Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 396
diff changeset
183 EnumMember[] members;
e242f0ee2d27 Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 396
diff changeset
184 this(Token* name, Type baseType, EnumMember[] members, bool hasBody)
107
722c05bbd5eb - Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents: 102
diff changeset
185 {
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
186 super.hasBody = hasBody;
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
187 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
188 addOptChild(baseType);
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
189 addOptChildren(members);
406
e242f0ee2d27 Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 396
diff changeset
190
107
722c05bbd5eb - Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents: 102
diff changeset
191 this.name = name;
722c05bbd5eb - Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents: 102
diff changeset
192 this.baseType = baseType;
722c05bbd5eb - Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents: 102
diff changeset
193 this.members = members;
406
e242f0ee2d27 Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 396
diff changeset
194 }
e242f0ee2d27 Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 396
diff changeset
195 }
e242f0ee2d27 Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 396
diff changeset
196
e242f0ee2d27 Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 396
diff changeset
197 class EnumMember : Node
e242f0ee2d27 Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 396
diff changeset
198 {
e242f0ee2d27 Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 396
diff changeset
199 Token* name;
e242f0ee2d27 Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 396
diff changeset
200 Expression value;
e242f0ee2d27 Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 396
diff changeset
201 this(Token* name, Expression value)
e242f0ee2d27 Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 396
diff changeset
202 {
e242f0ee2d27 Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 396
diff changeset
203 super(NodeCategory.Other);
e242f0ee2d27 Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 396
diff changeset
204 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
205 addOptChild(value);
406
e242f0ee2d27 Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 396
diff changeset
206
e242f0ee2d27 Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 396
diff changeset
207 this.name = name;
e242f0ee2d27 Added class EnumMember.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 396
diff changeset
208 this.value = value;
107
722c05bbd5eb - Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents: 102
diff changeset
209 }
722c05bbd5eb - Implemented parseEnumDeclaration() and added class EnumDeclaration.
aziz
parents: 102
diff changeset
210 }
109
d0cc281cacbd - Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents: 107
diff changeset
211
d0cc281cacbd - Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents: 107
diff changeset
212 class ClassDeclaration : Declaration
d0cc281cacbd - Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents: 107
diff changeset
213 {
264
50cc74026ea8 - Changed some string types to Token*.
aziz
parents: 263
diff changeset
214 Token* name;
258
112a57f433f2 - Created class TemplateParameters.
aziz
parents: 252
diff changeset
215 TemplateParameters tparams;
109
d0cc281cacbd - Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents: 107
diff changeset
216 BaseClass[] bases;
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
217 Declarations decls;
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
218 this(Token* name, TemplateParameters tparams, BaseClass[] bases, Declarations decls, bool hasBody)
109
d0cc281cacbd - Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents: 107
diff changeset
219 {
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
220 super.hasBody = hasBody;
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
221 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
222 addOptChild(tparams);
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
223 addOptChildren(bases);
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
224 addOptChild(decls);
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
225
112
004d98df65af - Implemented parseInterfaceDeclaration().
aziz
parents: 109
diff changeset
226 this.name = name;
195
37c2ffd649c4 - Parsing template parameter list for class, interface, struct and union declarations.
aziz
parents: 194
diff changeset
227 this.tparams = tparams;
109
d0cc281cacbd - Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents: 107
diff changeset
228 this.bases = bases;
d0cc281cacbd - Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents: 107
diff changeset
229 this.decls = decls;
d0cc281cacbd - Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents: 107
diff changeset
230 }
d0cc281cacbd - Added methods parseClassDeclaration() and parseBaseClasses().
aziz
parents: 107
diff changeset
231 }
112
004d98df65af - Implemented parseInterfaceDeclaration().
aziz
parents: 109
diff changeset
232
004d98df65af - Implemented parseInterfaceDeclaration().
aziz
parents: 109
diff changeset
233 class InterfaceDeclaration : Declaration
004d98df65af - Implemented parseInterfaceDeclaration().
aziz
parents: 109
diff changeset
234 {
264
50cc74026ea8 - Changed some string types to Token*.
aziz
parents: 263
diff changeset
235 Token* name;
258
112a57f433f2 - Created class TemplateParameters.
aziz
parents: 252
diff changeset
236 TemplateParameters tparams;
112
004d98df65af - Implemented parseInterfaceDeclaration().
aziz
parents: 109
diff changeset
237 BaseClass[] bases;
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
238 Declarations decls;
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
239 this(Token* name, TemplateParameters tparams, BaseClass[] bases, Declarations decls, bool hasBody)
112
004d98df65af - Implemented parseInterfaceDeclaration().
aziz
parents: 109
diff changeset
240 {
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
241 super.hasBody = hasBody;
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
242 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
243 addOptChild(tparams);
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
244 addOptChildren(bases);
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
245 addOptChild(decls);
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
246
112
004d98df65af - Implemented parseInterfaceDeclaration().
aziz
parents: 109
diff changeset
247 this.name = name;
195
37c2ffd649c4 - Parsing template parameter list for class, interface, struct and union declarations.
aziz
parents: 194
diff changeset
248 this.tparams = tparams;
112
004d98df65af - Implemented parseInterfaceDeclaration().
aziz
parents: 109
diff changeset
249 this.bases = bases;
004d98df65af - Implemented parseInterfaceDeclaration().
aziz
parents: 109
diff changeset
250 this.decls = decls;
004d98df65af - Implemented parseInterfaceDeclaration().
aziz
parents: 109
diff changeset
251 }
004d98df65af - Implemented parseInterfaceDeclaration().
aziz
parents: 109
diff changeset
252 }
113
20d8ae8a3fd9 - Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents: 112
diff changeset
253
20d8ae8a3fd9 - Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents: 112
diff changeset
254 class StructDeclaration : Declaration
20d8ae8a3fd9 - Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents: 112
diff changeset
255 {
264
50cc74026ea8 - Changed some string types to Token*.
aziz
parents: 263
diff changeset
256 Token* name;
258
112a57f433f2 - Created class TemplateParameters.
aziz
parents: 252
diff changeset
257 TemplateParameters tparams;
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
258 Declarations decls;
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
259 this(Token* name, TemplateParameters tparams, Declarations decls, bool hasBody)
113
20d8ae8a3fd9 - Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents: 112
diff changeset
260 {
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
261 super.hasBody = hasBody;
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
262 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
263 addOptChild(tparams);
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
264 addOptChild(decls);
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
265
113
20d8ae8a3fd9 - Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents: 112
diff changeset
266 this.name = name;
195
37c2ffd649c4 - Parsing template parameter list for class, interface, struct and union declarations.
aziz
parents: 194
diff changeset
267 this.tparams = tparams;
113
20d8ae8a3fd9 - Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents: 112
diff changeset
268 this.decls = decls;
20d8ae8a3fd9 - Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents: 112
diff changeset
269 }
20d8ae8a3fd9 - Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents: 112
diff changeset
270 }
20d8ae8a3fd9 - Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents: 112
diff changeset
271
20d8ae8a3fd9 - Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents: 112
diff changeset
272 class UnionDeclaration : Declaration
20d8ae8a3fd9 - Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents: 112
diff changeset
273 {
264
50cc74026ea8 - Changed some string types to Token*.
aziz
parents: 263
diff changeset
274 Token* name;
258
112a57f433f2 - Created class TemplateParameters.
aziz
parents: 252
diff changeset
275 TemplateParameters tparams;
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
276 Declarations decls;
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
277 this(Token* name, TemplateParameters tparams, Declarations decls, bool hasBody)
113
20d8ae8a3fd9 - Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents: 112
diff changeset
278 {
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
279 super.hasBody = hasBody;
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
280 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
281 addOptChild(tparams);
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
282 addOptChild(decls);
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
283
113
20d8ae8a3fd9 - Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents: 112
diff changeset
284 this.name = name;
195
37c2ffd649c4 - Parsing template parameter list for class, interface, struct and union declarations.
aziz
parents: 194
diff changeset
285 this.tparams = tparams;
113
20d8ae8a3fd9 - Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents: 112
diff changeset
286 this.decls = decls;
20d8ae8a3fd9 - Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents: 112
diff changeset
287 }
20d8ae8a3fd9 - Implemented parseAggregateDeclaration for Struct- and UnionDeclarations.
aziz
parents: 112
diff changeset
288 }
117
79857de26e86 - Moved class Parameter to module Types. Added struct Parameters.
aziz
parents: 116
diff changeset
289
79857de26e86 - Moved class Parameter to module Types. Added struct Parameters.
aziz
parents: 116
diff changeset
290 class ConstructorDeclaration : Declaration
79857de26e86 - Moved class Parameter to module Types. Added struct Parameters.
aziz
parents: 116
diff changeset
291 {
79857de26e86 - Moved class Parameter to module Types. Added struct Parameters.
aziz
parents: 116
diff changeset
292 Parameters parameters;
197
ff32eb87300e - Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents: 195
diff changeset
293 FunctionBody funcBody;
ff32eb87300e - Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents: 195
diff changeset
294 this(Parameters parameters, FunctionBody funcBody)
117
79857de26e86 - Moved class Parameter to module Types. Added struct Parameters.
aziz
parents: 116
diff changeset
295 {
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
296 super.hasBody = true;
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
297 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
298 addChild(parameters);
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
299 addChild(funcBody);
396
0a4619735ce9 Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
300
117
79857de26e86 - Moved class Parameter to module Types. Added struct Parameters.
aziz
parents: 116
diff changeset
301 this.parameters = parameters;
197
ff32eb87300e - Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents: 195
diff changeset
302 this.funcBody = funcBody;
117
79857de26e86 - Moved class Parameter to module Types. Added struct Parameters.
aziz
parents: 116
diff changeset
303 }
79857de26e86 - Moved class Parameter to module Types. Added struct Parameters.
aziz
parents: 116
diff changeset
304 }
118
379f33cbd521 - Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents: 117
diff changeset
305
119
363cd39022f9 - Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents: 118
diff changeset
306 class StaticConstructorDeclaration : Declaration
363cd39022f9 - Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents: 118
diff changeset
307 {
197
ff32eb87300e - Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents: 195
diff changeset
308 FunctionBody funcBody;
ff32eb87300e - Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents: 195
diff changeset
309 this(FunctionBody funcBody)
119
363cd39022f9 - Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents: 118
diff changeset
310 {
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
311 super.hasBody = true;
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
312 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
313 addChild(funcBody);
396
0a4619735ce9 Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
314
197
ff32eb87300e - Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents: 195
diff changeset
315 this.funcBody = funcBody;
119
363cd39022f9 - Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents: 118
diff changeset
316 }
363cd39022f9 - Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents: 118
diff changeset
317 }
363cd39022f9 - Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents: 118
diff changeset
318
118
379f33cbd521 - Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents: 117
diff changeset
319 class DestructorDeclaration : Declaration
379f33cbd521 - Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents: 117
diff changeset
320 {
197
ff32eb87300e - Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents: 195
diff changeset
321 FunctionBody funcBody;
ff32eb87300e - Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents: 195
diff changeset
322 this(FunctionBody funcBody)
118
379f33cbd521 - Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents: 117
diff changeset
323 {
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
324 super.hasBody = true;
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
325 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
326 addChild(funcBody);
396
0a4619735ce9 Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
327
197
ff32eb87300e - Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents: 195
diff changeset
328 this.funcBody = funcBody;
118
379f33cbd521 - Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents: 117
diff changeset
329 }
379f33cbd521 - Added parseDestructorDeclaration() and DestructorDeclaration class.
aziz
parents: 117
diff changeset
330 }
119
363cd39022f9 - Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents: 118
diff changeset
331
363cd39022f9 - Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents: 118
diff changeset
332 class StaticDestructorDeclaration : Declaration
363cd39022f9 - Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents: 118
diff changeset
333 {
197
ff32eb87300e - Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents: 195
diff changeset
334 FunctionBody funcBody;
ff32eb87300e - Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents: 195
diff changeset
335 this(FunctionBody funcBody)
119
363cd39022f9 - Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents: 118
diff changeset
336 {
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
337 super.hasBody = true;
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
338 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
339 addChild(funcBody);
396
0a4619735ce9 Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
340
197
ff32eb87300e - Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents: 195
diff changeset
341 this.funcBody = funcBody;
119
363cd39022f9 - Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents: 118
diff changeset
342 }
363cd39022f9 - Added parseStaticConstructor- and DestructorDeclaration().
aziz
parents: 118
diff changeset
343 }
120
e5329dac0405 - Added parseInvariantDeclaration().
aziz
parents: 119
diff changeset
344
192
5c898f80b436 - Started implementation of parseDeclaration().
aziz
parents: 191
diff changeset
345 class FunctionDeclaration : Declaration
5c898f80b436 - Started implementation of parseDeclaration().
aziz
parents: 191
diff changeset
346 {
290
7933a0c17c9f - Changed class FunctionDeclaration. Parses passes return type, function name, template parameters, normal parameters and function body to constructor.
aziz
parents: 283
diff changeset
347 Type returnType;
262
0f22269e76ff - Changed some string types to Token*.
aziz
parents: 258
diff changeset
348 Token* funcName;
258
112a57f433f2 - Created class TemplateParameters.
aziz
parents: 252
diff changeset
349 TemplateParameters tparams;
290
7933a0c17c9f - Changed class FunctionDeclaration. Parses passes return type, function name, template parameters, normal parameters and function body to constructor.
aziz
parents: 283
diff changeset
350 Parameters params;
192
5c898f80b436 - Started implementation of parseDeclaration().
aziz
parents: 191
diff changeset
351 FunctionBody funcBody;
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
352 this(Type returnType, Token* funcName, TemplateParameters tparams,
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
353 Parameters params, FunctionBody funcBody, StorageClass stc)
192
5c898f80b436 - Started implementation of parseDeclaration().
aziz
parents: 191
diff changeset
354 {
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
355 super.hasBody = funcBody.funcBody !is null;
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
356 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
357 addChild(returnType);
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
358 addOptChild(tparams);
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
359 addChild(params);
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
360 addChild(funcBody);
396
0a4619735ce9 Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
361
492
9c208925a3d4 Added module ImportParser and new stuff from DMD2.008.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 490
diff changeset
362 this.stc = stc;
290
7933a0c17c9f - Changed class FunctionDeclaration. Parses passes return type, function name, template parameters, normal parameters and function body to constructor.
aziz
parents: 283
diff changeset
363 this.returnType = returnType;
192
5c898f80b436 - Started implementation of parseDeclaration().
aziz
parents: 191
diff changeset
364 this.funcName = funcName;
290
7933a0c17c9f - Changed class FunctionDeclaration. Parses passes return type, function name, template parameters, normal parameters and function body to constructor.
aziz
parents: 283
diff changeset
365 this.tparams = tparams;
7933a0c17c9f - Changed class FunctionDeclaration. Parses passes return type, function name, template parameters, normal parameters and function body to constructor.
aziz
parents: 283
diff changeset
366 this.params = params;
192
5c898f80b436 - Started implementation of parseDeclaration().
aziz
parents: 191
diff changeset
367 this.funcBody = funcBody;
5c898f80b436 - Started implementation of parseDeclaration().
aziz
parents: 191
diff changeset
368 }
5c898f80b436 - Started implementation of parseDeclaration().
aziz
parents: 191
diff changeset
369 }
5c898f80b436 - Started implementation of parseDeclaration().
aziz
parents: 191
diff changeset
370
194
b3604b237292 - Implemented parsing variable declarations.
aziz
parents: 192
diff changeset
371 class VariableDeclaration : Declaration
b3604b237292 - Implemented parsing variable declarations.
aziz
parents: 192
diff changeset
372 {
283
df657dd98ffa - Fix: added member type to VariableDeclaration.
aziz
parents: 277
diff changeset
373 Type type;
262
0f22269e76ff - Changed some string types to Token*.
aziz
parents: 258
diff changeset
374 Token*[] idents;
194
b3604b237292 - Implemented parsing variable declarations.
aziz
parents: 192
diff changeset
375 Expression[] values;
283
df657dd98ffa - Fix: added member type to VariableDeclaration.
aziz
parents: 277
diff changeset
376 this(Type type, Token*[] idents, Expression[] values)
194
b3604b237292 - Implemented parsing variable declarations.
aziz
parents: 192
diff changeset
377 {
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
378 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
379 addOptChild(type);
299
559d5d62e0c1 - Added checks for null before adding member to Node.children.
aziz
parents: 292
diff changeset
380 foreach(value; values)
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
381 addOptChild(value);
396
0a4619735ce9 Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
382
283
df657dd98ffa - Fix: added member type to VariableDeclaration.
aziz
parents: 277
diff changeset
383 this.type = type;
194
b3604b237292 - Implemented parsing variable declarations.
aziz
parents: 192
diff changeset
384 this.idents = idents;
b3604b237292 - Implemented parsing variable declarations.
aziz
parents: 192
diff changeset
385 this.values = values;
b3604b237292 - Implemented parsing variable declarations.
aziz
parents: 192
diff changeset
386 }
b3604b237292 - Implemented parsing variable declarations.
aziz
parents: 192
diff changeset
387 }
b3604b237292 - Implemented parsing variable declarations.
aziz
parents: 192
diff changeset
388
120
e5329dac0405 - Added parseInvariantDeclaration().
aziz
parents: 119
diff changeset
389 class InvariantDeclaration : Declaration
e5329dac0405 - Added parseInvariantDeclaration().
aziz
parents: 119
diff changeset
390 {
197
ff32eb87300e - Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents: 195
diff changeset
391 FunctionBody funcBody;
ff32eb87300e - Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents: 195
diff changeset
392 this(FunctionBody funcBody)
120
e5329dac0405 - Added parseInvariantDeclaration().
aziz
parents: 119
diff changeset
393 {
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
394 super.hasBody = true;
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
395 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
396 addChild(funcBody);
396
0a4619735ce9 Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
397
197
ff32eb87300e - Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents: 195
diff changeset
398 this.funcBody = funcBody;
120
e5329dac0405 - Added parseInvariantDeclaration().
aziz
parents: 119
diff changeset
399 }
e5329dac0405 - Added parseInvariantDeclaration().
aziz
parents: 119
diff changeset
400 }
121
030933c6b5f0 - Added parseUnittestDeclaration().
aziz
parents: 120
diff changeset
401
030933c6b5f0 - Added parseUnittestDeclaration().
aziz
parents: 120
diff changeset
402 class UnittestDeclaration : Declaration
030933c6b5f0 - Added parseUnittestDeclaration().
aziz
parents: 120
diff changeset
403 {
197
ff32eb87300e - Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents: 195
diff changeset
404 FunctionBody funcBody;
ff32eb87300e - Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents: 195
diff changeset
405 this(FunctionBody funcBody)
121
030933c6b5f0 - Added parseUnittestDeclaration().
aziz
parents: 120
diff changeset
406 {
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
407 super.hasBody = true;
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
408 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
409 addChild(funcBody);
396
0a4619735ce9 Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
410
197
ff32eb87300e - Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents: 195
diff changeset
411 this.funcBody = funcBody;
121
030933c6b5f0 - Added parseUnittestDeclaration().
aziz
parents: 120
diff changeset
412 }
030933c6b5f0 - Added parseUnittestDeclaration().
aziz
parents: 120
diff changeset
413 }
122
9849a263f148 - Added method parseDeclarationsBlock().
aziz
parents: 121
diff changeset
414
9849a263f148 - Added method parseDeclarationsBlock().
aziz
parents: 121
diff changeset
415 class DebugDeclaration : Declaration
9849a263f148 - Added method parseDeclarationsBlock().
aziz
parents: 121
diff changeset
416 {
264
50cc74026ea8 - Changed some string types to Token*.
aziz
parents: 263
diff changeset
417 Token* spec;
50cc74026ea8 - Changed some string types to Token*.
aziz
parents: 263
diff changeset
418 Token* cond;
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
419 Declaration decls, elseDecls;
122
9849a263f148 - Added method parseDeclarationsBlock().
aziz
parents: 121
diff changeset
420
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
421 this(Token* spec, Token* cond, Declaration decls, Declaration elseDecls)
122
9849a263f148 - Added method parseDeclarationsBlock().
aziz
parents: 121
diff changeset
422 {
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
423 super.hasBody = decls !is null;
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
424 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
425 addOptChild(decls);
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
426 addOptChild(elseDecls);
396
0a4619735ce9 Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
427
264
50cc74026ea8 - Changed some string types to Token*.
aziz
parents: 263
diff changeset
428 this.spec = spec;
50cc74026ea8 - Changed some string types to Token*.
aziz
parents: 263
diff changeset
429 this.cond = cond;
122
9849a263f148 - Added method parseDeclarationsBlock().
aziz
parents: 121
diff changeset
430 this.decls = decls;
9849a263f148 - Added method parseDeclarationsBlock().
aziz
parents: 121
diff changeset
431 this.elseDecls = elseDecls;
9849a263f148 - Added method parseDeclarationsBlock().
aziz
parents: 121
diff changeset
432 }
9849a263f148 - Added method parseDeclarationsBlock().
aziz
parents: 121
diff changeset
433 }
123
0f55c0ac6589 - Added method parseVersionDeclaration().
aziz
parents: 122
diff changeset
434
0f55c0ac6589 - Added method parseVersionDeclaration().
aziz
parents: 122
diff changeset
435 class VersionDeclaration : Declaration
0f55c0ac6589 - Added method parseVersionDeclaration().
aziz
parents: 122
diff changeset
436 {
264
50cc74026ea8 - Changed some string types to Token*.
aziz
parents: 263
diff changeset
437 Token* spec;
50cc74026ea8 - Changed some string types to Token*.
aziz
parents: 263
diff changeset
438 Token* cond;
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
439 Declaration decls, elseDecls;
123
0f55c0ac6589 - Added method parseVersionDeclaration().
aziz
parents: 122
diff changeset
440
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
441 this(Token* spec, Token* cond, Declaration decls, Declaration elseDecls)
123
0f55c0ac6589 - Added method parseVersionDeclaration().
aziz
parents: 122
diff changeset
442 {
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
443 super.hasBody = decls !is null;
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
444 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
445 addOptChild(decls);
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
446 addOptChild(elseDecls);
396
0a4619735ce9 Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
447
264
50cc74026ea8 - Changed some string types to Token*.
aziz
parents: 263
diff changeset
448 this.spec = spec;
50cc74026ea8 - Changed some string types to Token*.
aziz
parents: 263
diff changeset
449 this.cond = cond;
123
0f55c0ac6589 - Added method parseVersionDeclaration().
aziz
parents: 122
diff changeset
450 this.decls = decls;
0f55c0ac6589 - Added method parseVersionDeclaration().
aziz
parents: 122
diff changeset
451 this.elseDecls = elseDecls;
0f55c0ac6589 - Added method parseVersionDeclaration().
aziz
parents: 122
diff changeset
452 }
0f55c0ac6589 - Added method parseVersionDeclaration().
aziz
parents: 122
diff changeset
453 }
125
240a8b053803 - Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents: 123
diff changeset
454
240a8b053803 - Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents: 123
diff changeset
455 class StaticIfDeclaration : Declaration
240a8b053803 - Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents: 123
diff changeset
456 {
240a8b053803 - Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents: 123
diff changeset
457 Expression condition;
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
458 Declaration ifDecls, elseDecls;
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
459 this(Expression condition, Declaration ifDecls, Declaration elseDecls)
125
240a8b053803 - Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents: 123
diff changeset
460 {
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
461 super.hasBody = true;
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
462 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
463 addChild(condition);
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
464 addOptChild(ifDecls);
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
465 addOptChild(elseDecls);
396
0a4619735ce9 Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
466
125
240a8b053803 - Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents: 123
diff changeset
467 this.condition = condition;
240a8b053803 - Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents: 123
diff changeset
468 this.ifDecls = ifDecls;
240a8b053803 - Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents: 123
diff changeset
469 this.elseDecls = elseDecls;
240a8b053803 - Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents: 123
diff changeset
470 }
240a8b053803 - Added method parseStaticIfDeclaration and added class StaticIfDeclaration.
aziz
parents: 123
diff changeset
471 }
127
cb9a97ebb570 - Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents: 126
diff changeset
472
cb9a97ebb570 - Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents: 126
diff changeset
473 class StaticAssertDeclaration : Declaration
cb9a97ebb570 - Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents: 126
diff changeset
474 {
cb9a97ebb570 - Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents: 126
diff changeset
475 Expression condition, message;
cb9a97ebb570 - Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents: 126
diff changeset
476 this(Expression condition, Expression message)
cb9a97ebb570 - Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents: 126
diff changeset
477 {
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
478 super.hasBody = true;
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
479 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
480 addChild(condition);
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
481 addOptChild(message);
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
482
127
cb9a97ebb570 - Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents: 126
diff changeset
483 this.condition = condition;
cb9a97ebb570 - Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents: 126
diff changeset
484 this.message = message;
cb9a97ebb570 - Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents: 126
diff changeset
485 }
cb9a97ebb570 - Added method parseStaticAssertDeclaration and added class StaticAssertDeclaration.
aziz
parents: 126
diff changeset
486 }
140
64d7186b087c - Implemented parseTemplateParameters().
aziz
parents: 129
diff changeset
487
64d7186b087c - Implemented parseTemplateParameters().
aziz
parents: 129
diff changeset
488 class TemplateDeclaration : Declaration
64d7186b087c - Implemented parseTemplateParameters().
aziz
parents: 129
diff changeset
489 {
292
076152e945e0 - Added member Node[] children to class Node.
aziz
parents: 290
diff changeset
490 Token* name;
076152e945e0 - Added member Node[] children to class Node.
aziz
parents: 290
diff changeset
491 TemplateParameters tparams;
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
492 Declarations decls;
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
493 this(Token* name, TemplateParameters tparams, Declarations decls)
140
64d7186b087c - Implemented parseTemplateParameters().
aziz
parents: 129
diff changeset
494 {
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
495 super.hasBody = true;
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
496 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
497 addOptChild(tparams);
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
498 addChild(decls);
396
0a4619735ce9 Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
499
292
076152e945e0 - Added member Node[] children to class Node.
aziz
parents: 290
diff changeset
500 this.name = name;
076152e945e0 - Added member Node[] children to class Node.
aziz
parents: 290
diff changeset
501 this.tparams = tparams;
140
64d7186b087c - Implemented parseTemplateParameters().
aziz
parents: 129
diff changeset
502 this.decls = decls;
64d7186b087c - Implemented parseTemplateParameters().
aziz
parents: 129
diff changeset
503 }
64d7186b087c - Implemented parseTemplateParameters().
aziz
parents: 129
diff changeset
504 }
141
7ab33ee1a641 - Implemented parseNew- and DeleteDeclaration().
aziz
parents: 140
diff changeset
505
7ab33ee1a641 - Implemented parseNew- and DeleteDeclaration().
aziz
parents: 140
diff changeset
506 class NewDeclaration : Declaration
7ab33ee1a641 - Implemented parseNew- and DeleteDeclaration().
aziz
parents: 140
diff changeset
507 {
7ab33ee1a641 - Implemented parseNew- and DeleteDeclaration().
aziz
parents: 140
diff changeset
508 Parameters parameters;
197
ff32eb87300e - Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents: 195
diff changeset
509 FunctionBody funcBody;
ff32eb87300e - Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents: 195
diff changeset
510 this(Parameters parameters, FunctionBody funcBody)
141
7ab33ee1a641 - Implemented parseNew- and DeleteDeclaration().
aziz
parents: 140
diff changeset
511 {
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
512 super.hasBody = true;
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
513 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
514 addChild(parameters);
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
515 addChild(funcBody);
396
0a4619735ce9 Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
516
141
7ab33ee1a641 - Implemented parseNew- and DeleteDeclaration().
aziz
parents: 140
diff changeset
517 this.parameters = parameters;
197
ff32eb87300e - Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents: 195
diff changeset
518 this.funcBody = funcBody;
141
7ab33ee1a641 - Implemented parseNew- and DeleteDeclaration().
aziz
parents: 140
diff changeset
519 }
7ab33ee1a641 - Implemented parseNew- and DeleteDeclaration().
aziz
parents: 140
diff changeset
520 }
7ab33ee1a641 - Implemented parseNew- and DeleteDeclaration().
aziz
parents: 140
diff changeset
521
7ab33ee1a641 - Implemented parseNew- and DeleteDeclaration().
aziz
parents: 140
diff changeset
522 class DeleteDeclaration : Declaration
7ab33ee1a641 - Implemented parseNew- and DeleteDeclaration().
aziz
parents: 140
diff changeset
523 {
7ab33ee1a641 - Implemented parseNew- and DeleteDeclaration().
aziz
parents: 140
diff changeset
524 Parameters parameters;
197
ff32eb87300e - Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents: 195
diff changeset
525 FunctionBody funcBody;
ff32eb87300e - Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents: 195
diff changeset
526 this(Parameters parameters, FunctionBody funcBody)
141
7ab33ee1a641 - Implemented parseNew- and DeleteDeclaration().
aziz
parents: 140
diff changeset
527 {
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
528 super.hasBody = true;
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
529 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
530 addChild(parameters);
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
531 addChild(funcBody);
396
0a4619735ce9 Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
532
141
7ab33ee1a641 - Implemented parseNew- and DeleteDeclaration().
aziz
parents: 140
diff changeset
533 this.parameters = parameters;
197
ff32eb87300e - Using parseFunctionBody() for Constructor-,Destructor-,StaticConstructor-,StaticDestructor-,Invariant-,Unittest-,New- and DeleteDeclaration.
aziz
parents: 195
diff changeset
534 this.funcBody = funcBody;
141
7ab33ee1a641 - Implemented parseNew- and DeleteDeclaration().
aziz
parents: 140
diff changeset
535 }
7ab33ee1a641 - Implemented parseNew- and DeleteDeclaration().
aziz
parents: 140
diff changeset
536 }
146
8180eb84e69c - Started implementation of parseAttributeSpecifier().
aziz
parents: 141
diff changeset
537
149
37e2e0d06013 - Removed ProtectionDeclaration.
aziz
parents: 148
diff changeset
538 class AttributeDeclaration : Declaration
146
8180eb84e69c - Started implementation of parseAttributeSpecifier().
aziz
parents: 141
diff changeset
539 {
149
37e2e0d06013 - Removed ProtectionDeclaration.
aziz
parents: 148
diff changeset
540 TOK attribute;
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
541 Declaration decls;
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
542 this(TOK attribute, Declaration decls)
146
8180eb84e69c - Started implementation of parseAttributeSpecifier().
aziz
parents: 141
diff changeset
543 {
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
544 super.hasBody = true;
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
545 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
546 addChild(decls);
396
0a4619735ce9 Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
547
149
37e2e0d06013 - Removed ProtectionDeclaration.
aziz
parents: 148
diff changeset
548 this.attribute = attribute;
146
8180eb84e69c - Started implementation of parseAttributeSpecifier().
aziz
parents: 141
diff changeset
549 this.decls = decls;
8180eb84e69c - Started implementation of parseAttributeSpecifier().
aziz
parents: 141
diff changeset
550 }
8180eb84e69c - Started implementation of parseAttributeSpecifier().
aziz
parents: 141
diff changeset
551 }
147
e46b3415ec16 - Implemented parsing pragma declarations.
aziz
parents: 146
diff changeset
552
490
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
553 class ProtectionDeclaration : AttributeDeclaration
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
554 {
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
555 this(Protection prot, Declaration decls)
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
556 {
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
557 super(cast(TOK)0, decls);
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
558 mixin(set_kind);
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
559 super.prot = prot;
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
560 }
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
561
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
562 void semantic(Scope scop)
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
563 {
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
564 /+
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
565 void traverse(Node[] nodes)
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
566 {
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
567 foreach (node; nodes)
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
568 {
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
569 if (node.kind == NodeKind.ProtectionDeclaration)
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
570 break;
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
571 if (node.category == NodeCategory.Declaration)
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
572 {
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
573 auto decl = cast(Declaration)cast(void*)node;
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
574 decl.prot = this.prot;
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
575 if (node.children)
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
576 traverse(node.children);
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
577 }
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
578 }
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
579 }
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
580 traverse([this.decls]);
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
581 +/
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
582 }
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
583 }
47be6bfe39cd Refactored code and added new modules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 489
diff changeset
584
149
37e2e0d06013 - Removed ProtectionDeclaration.
aziz
parents: 148
diff changeset
585 class ExternDeclaration : AttributeDeclaration
37e2e0d06013 - Removed ProtectionDeclaration.
aziz
parents: 148
diff changeset
586 {
159
5aa877506db0 - Added enum Linkage.
aziz
parents: 158
diff changeset
587 Linkage linkage;
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
588 this(Linkage linkage, Declaration decls)
149
37e2e0d06013 - Removed ProtectionDeclaration.
aziz
parents: 148
diff changeset
589 {
37e2e0d06013 - Removed ProtectionDeclaration.
aziz
parents: 148
diff changeset
590 super(TOK.Extern, decls);
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
591 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
592 addOptChild(linkage);
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
593
149
37e2e0d06013 - Removed ProtectionDeclaration.
aziz
parents: 148
diff changeset
594 this.linkage = linkage;
37e2e0d06013 - Removed ProtectionDeclaration.
aziz
parents: 148
diff changeset
595 }
37e2e0d06013 - Removed ProtectionDeclaration.
aziz
parents: 148
diff changeset
596 }
37e2e0d06013 - Removed ProtectionDeclaration.
aziz
parents: 148
diff changeset
597
37e2e0d06013 - Removed ProtectionDeclaration.
aziz
parents: 148
diff changeset
598 class AlignDeclaration : AttributeDeclaration
37e2e0d06013 - Removed ProtectionDeclaration.
aziz
parents: 148
diff changeset
599 {
37e2e0d06013 - Removed ProtectionDeclaration.
aziz
parents: 148
diff changeset
600 int size;
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
601 this(int size, Declaration decls)
149
37e2e0d06013 - Removed ProtectionDeclaration.
aziz
parents: 148
diff changeset
602 {
37e2e0d06013 - Removed ProtectionDeclaration.
aziz
parents: 148
diff changeset
603 super(TOK.Align, decls);
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
604 mixin(set_kind);
149
37e2e0d06013 - Removed ProtectionDeclaration.
aziz
parents: 148
diff changeset
605 this.size = size;
37e2e0d06013 - Removed ProtectionDeclaration.
aziz
parents: 148
diff changeset
606 }
37e2e0d06013 - Removed ProtectionDeclaration.
aziz
parents: 148
diff changeset
607 }
37e2e0d06013 - Removed ProtectionDeclaration.
aziz
parents: 148
diff changeset
608
37e2e0d06013 - Removed ProtectionDeclaration.
aziz
parents: 148
diff changeset
609 class PragmaDeclaration : AttributeDeclaration
147
e46b3415ec16 - Implemented parsing pragma declarations.
aziz
parents: 146
diff changeset
610 {
245
93d37f874658 - Changed type of pragma identifier to Token*.
aziz
parents: 240
diff changeset
611 Token* ident;
147
e46b3415ec16 - Implemented parsing pragma declarations.
aziz
parents: 146
diff changeset
612 Expression[] args;
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 301
diff changeset
613 this(Token* ident, Expression[] args, Declaration decls)
147
e46b3415ec16 - Implemented parsing pragma declarations.
aziz
parents: 146
diff changeset
614 {
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
615 addOptChildren(args); // Add args before calling super().
149
37e2e0d06013 - Removed ProtectionDeclaration.
aziz
parents: 148
diff changeset
616 super(TOK.Pragma, decls);
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
617 mixin(set_kind);
396
0a4619735ce9 Applied fixes to Lexer, Parser and other classes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
618
147
e46b3415ec16 - Implemented parsing pragma declarations.
aziz
parents: 146
diff changeset
619 this.ident = ident;
e46b3415ec16 - Implemented parsing pragma declarations.
aziz
parents: 146
diff changeset
620 this.args = args;
e46b3415ec16 - Implemented parsing pragma declarations.
aziz
parents: 146
diff changeset
621 }
e46b3415ec16 - Implemented parsing pragma declarations.
aziz
parents: 146
diff changeset
622 }
150
753bc07bf3a0 - Forgot to pass ident to constructor of TemplateArgument.
aziz
parents: 149
diff changeset
623
753bc07bf3a0 - Forgot to pass ident to constructor of TemplateArgument.
aziz
parents: 149
diff changeset
624 class MixinDeclaration : Declaration
753bc07bf3a0 - Forgot to pass ident to constructor of TemplateArgument.
aziz
parents: 149
diff changeset
625 {
292
076152e945e0 - Added member Node[] children to class Node.
aziz
parents: 290
diff changeset
626 Expression[] templateIdents;
252
788398655d24 - Changed some string types to Token*. Adapted parser accordingly.
aziz
parents: 249
diff changeset
627 Token* mixinIdent;
292
076152e945e0 - Added member Node[] children to class Node.
aziz
parents: 290
diff changeset
628 Expression argument; // mixin ( AssignExpression )
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
629
292
076152e945e0 - Added member Node[] children to class Node.
aziz
parents: 290
diff changeset
630 this(Expression[] templateIdents, Token* mixinIdent)
150
753bc07bf3a0 - Forgot to pass ident to constructor of TemplateArgument.
aziz
parents: 149
diff changeset
631 {
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
632 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
633 addChildren(templateIdents);
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
634
292
076152e945e0 - Added member Node[] children to class Node.
aziz
parents: 290
diff changeset
635 this.templateIdents = templateIdents;
150
753bc07bf3a0 - Forgot to pass ident to constructor of TemplateArgument.
aziz
parents: 149
diff changeset
636 this.mixinIdent = mixinIdent;
753bc07bf3a0 - Forgot to pass ident to constructor of TemplateArgument.
aziz
parents: 149
diff changeset
637 }
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
638
292
076152e945e0 - Added member Node[] children to class Node.
aziz
parents: 290
diff changeset
639 this(Expression argument)
151
2e959f67000b - Added code for parsing mixin expression declarations.
aziz
parents: 150
diff changeset
640 {
277
38a68e534a3b - Made classes Declaration, Expression and Statement abstract.
aziz
parents: 275
diff changeset
641 mixin(set_kind);
489
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
642 addChild(argument);
a7291d3ee9d7 Refactored classes that inherit from Node.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 486
diff changeset
643
292
076152e945e0 - Added member Node[] children to class Node.
aziz
parents: 290
diff changeset
644 this.argument = argument;
151
2e959f67000b - Added code for parsing mixin expression declarations.
aziz
parents: 150
diff changeset
645 }
150
753bc07bf3a0 - Forgot to pass ident to constructor of TemplateArgument.
aziz
parents: 149
diff changeset
646 }