|
mupp 1.1.0
|
The PAnnotation struct links AST nodes to source code positions. More...
#include <PAnnotation.hpp>
Classes | |
| struct | set_id |
| Helper struct to set ID tags on AST nodes. More... | |
Public Member Functions | |
| PAnnotation (std::vector< Iterator > &iters) | |
| Constructor that initializes the annotation handler. | |
| void | operator() (ast::operand &ast, Iterator pos) const |
| Annotates an operand AST node with its source position. | |
| void | operator() (ast::assignment &ast, Iterator pos) const |
| Annotates an assignment AST node with its source position. | |
Public Attributes | |
| std::vector< Iterator > & | iters |
| Reference to vector storing iterator positions indexed by AST node IDs. | |
The PAnnotation struct links AST nodes to source code positions.
The annotation handler associates each AST node with its corresponding iterator position in the source code. This mapping enables accurate error reporting during semantic analysis and compilation by allowing the error handler to pinpoint the exact location of errors in the source text.
The annotation is performed after successful parsing but before semantic analysis, integrated with the Spirit X3 parser.
| Iterator | the iterator type for traversing the source code (typically std::string::const_iterator) |
Definition at line 60 of file PAnnotation.hpp.
|
inline |
Constructor that initializes the annotation handler.
| iters | reference to vector that will store iterator positions for each annotated AST node |
Definition at line 69 of file PAnnotation.hpp.
|
inline |
Annotates an assignment AST node with its source position.
Stores the iterator position and assigns a unique ID to the left-hand side variable of the assignment.
| ast | reference to the assignment AST node to annotate |
| pos | iterator pointing to the assignment's position in the source code |
Definition at line 153 of file PAnnotation.hpp.
|
inline |
Annotates an operand AST node with its source position.
Stores the iterator position and assigns a unique ID to the operand node by applying the set_id visitor to handle different operand variant types.
| ast | reference to the operand AST node to annotate |
| pos | iterator pointing to the operand's position in the source code |
Definition at line 138 of file PAnnotation.hpp.
| std::vector<Iterator>& mupp::PAnnotation< Iterator >::iters |
Reference to vector storing iterator positions indexed by AST node IDs.
Definition at line 63 of file PAnnotation.hpp.