#include <offset_stack_guard.h>
cttl::input
positions.
UniverseT
cttl::const_edge
or cttl::edge
.
Class offset_stack_guard uses CTTL offset management mechanism to keep track of input positions which represent significant logical positions of the input language constructs.
Usage
std::stack< size_t > xml_offset_stack;
size_t xml_grammar( universe_T& universe_ )
{
offset_stack_guard< universe_T > error_info( this->xml_offset_stack, universe_.first );
// ...
}
void show_error( universe_T& universe_ ) { size_t offset = offset_stack_guard< universe_T >::offset( universe_, xml_offset_stack.top() ); // ... }
show_error()
function remains generic enough to report correct offsets, since the stack is properly unwound by destructors of each offset guard object when nested grammar rule calls return.
Definition at line 93 of file offset_stack_guard.h.
Public Member Functions | |
offset_stack_guard (std::stack< size_t > &offset_stack_, node_T &node_) | |
Constructs and initializes the object. | |
~offset_stack_guard () | |
Destructor removes stack identity of the offset managed by this object. | |
void | operator= (offset_stack_guard< UniverseT > const &) const |
Assignment does nothing. | |
Static Public Member Functions | |
size_t | offset (UniverseT const &universe_, size_t stack_identity_) |
Returns curent offset for the specified stack identity. | |
Protected Types | |
typedef UniverseT::offset_manager_T | offset_guard_T |
Defines type of offset management class provided by the universe. | |
typedef UniverseT::node_T | node_T |
Defines node type of the universe. | |
Protected Attributes | |
offset_guard_T | m_offset_manager |
Instance of offset manager. | |
std::stack< size_t > & | m_offset_stack |
Reference to the stack of managed identities, maintained by this guard. |
|
Defines node type of the universe.
Definition at line 100 of file offset_stack_guard.h. |
|
Defines type of offset management class provided by the universe.
Definition at line 97 of file offset_stack_guard.h. |
|
Constructs and initializes the object.
Definition at line 114 of file offset_stack_guard.h. |
|
Destructor removes stack identity of the offset managed by this object.
Definition at line 123 of file offset_stack_guard.h. |
|
Returns curent offset for the specified stack identity.
Definition at line 129 of file offset_stack_guard.h. |
|
Assignment does nothing.
Definition at line 135 of file offset_stack_guard.h. |
|
Instance of offset manager.
Definition at line 104 of file offset_stack_guard.h. |
|
Reference to the stack of managed identities, maintained by this guard.
Definition at line 107 of file offset_stack_guard.h. |