Meta processor
- Described the role (via some examples) of the meta processor
This commit is contained in:
parent
3d463ff1e7
commit
49779c6245
|
@ -9,6 +9,15 @@ that *consumes the AST tree*, applies manipulations to its nodes or
|
|||
completely replaces some, and then finally returns to let the type
|
||||
checker begin its process.
|
||||
|
||||
Examples of things which require AST manipulation are:
|
||||
|
||||
1. Type aliases
|
||||
- `size_t` and `ssize_t` need to be resolved to their concrete types
|
||||
2. Macros
|
||||
- Macros such as `sizeof(<type>)` need to be replaced with a
|
||||
`NumberLiteral` with the value that is equal to the bit-width (in
|
||||
bytes) of the type `<type>`
|
||||
|
||||
### Meta API
|
||||
|
||||
There are some core interfaces which various `Statement`(s) (parser
|
||||
|
@ -70,4 +79,16 @@ TODO: Add an example of it being used here please
|
|||
|
||||
### the `MetaProcessor`
|
||||
|
||||
The `MetaProcessor` is the actual processing facility which can apply
|
||||
different types of AST manipulations to a given `Container`. It is run
|
||||
prior to type checking but after parsing. This makes sense as we want to
|
||||
do AST node manipulation *just* after the parse tree has been
|
||||
constructed, then we can pass the changed program to the `TypeChecker`
|
||||
and it wouldn’t know any different. For all the type checker knows, this
|
||||
is just the original program.
|
||||
|
||||
TODO: Document me
|
||||
|
||||
| Method name | Return type | Description |
|
||||
|-------------|-------------|---------------------------------------|
|
||||
| `clone()` | `Statement` | Returns the deeply cloned `Statement` |
|
||||
|
|
|
@ -2,6 +2,13 @@
|
|||
|
||||
The _meta processor_ is a mechanism that acts somewhat like a _shim_ (something you shove in-between two things) between the _parser_ and the _typechecker_. Therefore because the parser provides us with an AST tree rooted in a `Module` of which is then passed to the type checker it would imply that the place where the meta processor fits in is something that _consumes the AST tree_, applies manipulations to its nodes or completely replaces some, and then finally returns to let the type checker begin its process.
|
||||
|
||||
Examples of things which require AST manipulation are:
|
||||
|
||||
1. Type aliases
|
||||
* `size_t` and `ssize_t` need to be resolved to their concrete types
|
||||
2. Macros
|
||||
* Macros such as `sizeof(<type>)` need to be replaced with a `NumberLiteral` with the value that is equal to the bit-width (in bytes) of the type `<type>`
|
||||
|
||||
### Meta API
|
||||
|
||||
There are some core interfaces which various `Statement`(s) (parser nodes) can implement in order to be able to be manipulated by the meta-processor, we describe these in this section. These are all defined in `source/tlang/compiler/symbols/mcro.d`.
|
||||
|
@ -60,4 +67,13 @@ TODO: Add an example of it being used here please
|
|||
|
||||
### the `MetaProcessor`
|
||||
|
||||
TODO: Document me
|
||||
The `MetaProcessor` is the actual processing facility which can apply different types of AST manipulations to a given `Container`. It is run prior to type checking but after parsing. This makes sense as we want to do AST node manipulation _just_ after the parse tree has been constructed, then we can pass the changed program to the `TypeChecker` and it wouldn't know any different. For all the type checker knows, this is just the original program.
|
||||
|
||||
|
||||
TODO: Document me
|
||||
|
||||
|
||||
|
||||
| Method name | Return type | Description |
|
||||
|------------------|--------------|---------------------------------------------|
|
||||
| `clone()` | `Statement` | Returns the deeply cloned `Statement` |
|
Loading…
Reference in New Issue