annotate trunk/src/dil/Declarations.d @ 494:9a7ca8c56e59

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