| 296 | During the parsing phase, an Abstract Syntax Tree (AST) is constructed. There are a number of different node types. There were two approaches for defining the node types: |
| 297 | |
| 298 | 1. Define one node type, that contains all fields that could be needed. An advantage of this approach would be that it simplifies the code. On the other hand, it would probably make the code more obscure to read (since you can't really see what a node represents anymore), and also it would waste memory, since many fields would not be used by most of the instances. Furthermore, it would be easier to misuse certain fields for other purposes than the field was supposed to be used for. |
| 299 | |
| 300 | 2. Define specialized types. This is the approach taken. |
| 301 | |
| 302 | PIRC defines the following node types in [source:/trunk/compilers/pirc/src/pircompunit.h]: |
| 303 | |
| 304 | * [source:/trunk/compilers/pirc/src/pircompunit.h#L162 constdecl], used for a {{{.const}}} or {{{.globalconst}}} declaration |
| 305 | |
| 306 | * [source:/trunk/compilers/pirc/src/pircompunit.h#L172 constant], used to represent literal constants in the source code (e.g. 42, 3.14, "hello") |
| 307 | |
| 308 | * [source:/trunk/compilers/pirc/src/pircompunit.h#L180 label] |
| 309 | |
| 310 | * [source:/trunk/compilers/pirc/src/pircompunit.h#L196 expression] |
| 311 | |
| 312 | * [source:/trunk/compilers/pirc/src/pircompunit.h#L216 key_entry] |
| 313 | |
| 314 | * [source:/trunk/compilers/pirc/src/pircompunit.h#L225 key] |
| 315 | |
| 316 | * [source:/trunk/compilers/pirc/src/pircompunit.h#L238 target] |
| 317 | |
| 318 | * [source:/trunk/compilers/pirc/src/pircompunit.h#L255 argument] |
| 319 | |
| 320 | * [source:/trunk/compilers/pirc/src/pircompunit.h#L275 invocation] |
| 321 | |
| 322 | * [source:/trunk/compilers/pirc/src/pircompunit.h#L288 instruction] |
| 323 | |
| 324 | * [source:/trunk/compilers/pirc/src/pircompunit.h#L354 subroutine] |
| 325 | |