mupp 1.1.0
Loading...
Searching...
No Matches
mupp::PAnnotation< Iterator > Struct Template Reference

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.
 

Detailed Description

template<typename Iterator>
struct mupp::PAnnotation< Iterator >

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.

Template Parameters
Iteratorthe iterator type for traversing the source code (typically std::string::const_iterator)

Definition at line 60 of file PAnnotation.hpp.

Constructor & Destructor Documentation

◆ PAnnotation()

template<typename Iterator>
mupp::PAnnotation< Iterator >::PAnnotation ( std::vector< Iterator > & iters)
inline

Constructor that initializes the annotation handler.

Parameters
itersreference to vector that will store iterator positions for each annotated AST node

Definition at line 69 of file PAnnotation.hpp.

Member Function Documentation

◆ operator()() [1/2]

template<typename Iterator>
void mupp::PAnnotation< Iterator >::operator() ( ast::assignment & ast,
Iterator pos ) const
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.

Parameters
astreference to the assignment AST node to annotate
positerator pointing to the assignment's position in the source code

Definition at line 153 of file PAnnotation.hpp.

◆ operator()() [2/2]

template<typename Iterator>
void mupp::PAnnotation< Iterator >::operator() ( ast::operand & ast,
Iterator pos ) const
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.

Parameters
astreference to the operand AST node to annotate
positerator pointing to the operand's position in the source code

Definition at line 138 of file PAnnotation.hpp.

Member Data Documentation

◆ iters

template<typename Iterator>
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.


The documentation for this struct was generated from the following file: