33#ifndef _PANNOTATION_HPP_
34#define _PANNOTATION_HPP_
37#include <boost/variant/apply_visitor.hpp>
38#include <boost/type_traits/is_base_of.hpp>
39#include <boost/mpl/bool.hpp>
59 template <
typename Iterator>
98 this->
dispatch(x, boost::is_base_of<ast::tagged, T>());
109 template <
typename T>
123 template <
typename T>
140 int id =
iters.size();
141 iters.push_back(pos);
155 int id =
iters.size();
156 iters.push_back(pos);
boost::variant< nil, double, variable, boost::recursive_wrapper< function >, boost::recursive_wrapper< power >, boost::recursive_wrapper< unary >, boost::recursive_wrapper< expression > > operand
Variant type representing any operand in an expression.
Helper struct to set ID tags on AST nodes.
int id
The ID to assign to tagged AST nodes.
void dispatch(T &x, boost::mpl::false_) const
No-op handler for non-tagged AST nodes.
set_id(int id)
Constructor that stores the ID to be assigned.
void dispatch(T &x, boost::mpl::true_) const
Assigns ID to tagged AST nodes.
void operator()(T &x) const
Dispatches to the appropriate handler based on node type.
void operator()(ast::assignment &ast, Iterator pos) const
Annotates an assignment AST node with its source position.
std::vector< Iterator > & iters
Reference to vector storing iterator positions indexed by AST node IDs.
void operator()(ast::operand &ast, Iterator pos) const
Annotates an operand AST node with its source position.
PAnnotation(std::vector< Iterator > &iters)
Constructor that initializes the annotation handler.
Represents an assignment statement.