![]() |
Spicy
|
#include <parser-builder.h>
Public Member Functions | |
ParserState (const type::Unit &unit, const Grammar &grammar, Expression data, Expression cur) | |
ParserState (const ParserState &other)=default | |
ParserState (ParserState &&other)=default | |
ParserState & | operator= (const ParserState &other)=default |
ParserState & | operator= (ParserState &&other)=default |
void | printDebug (const std::shared_ptr< hilti::builder::Builder > &b) const |
Public Attributes | |
std::reference_wrapper< const type::Unit > | unit |
ID | unit_id |
bool | needs_look_ahead |
Expression | self |
Expression | data |
Expression | cur |
std::optional< Expression > | ncur |
Expression | trim |
Expression | lahead = look_ahead::None |
Expression | lahead_end |
LiteralMode | literal_mode = LiteralMode::Default |
std::optional< Expression > | captures |
Maintains access to parser state during code generation. The generated parsing code needs to carry various pieces of state through the logic (e.g., the curren input data). This struct records the expressions that arte holding the current state variables. To change same state (e.g., to temporarily parse different input) one typically creates a copy of the current struct instance and then pushed that onto parser generator's state stack. To change it back, one pops that struct from the stack.
void ParserState::printDebug | ( | const std::shared_ptr< hilti::builder::Builder > & | b | ) | const |
Generates code that prints a representation of the state to the spicy-verbose
debug stream.
block | bock to add the generated code to |
std::optional<Expression> spicy::detail::codegen::ParserState::captures |
Target for storing extracted capture groups; set only when needed & desired.
Expression spicy::detail::codegen::ParserState::cur |
If set, expression referencing a new cur
to set after parsin the current rule.
Expression spicy::detail::codegen::ParserState::data |
Expression referencing the current view inside 'data'.
Expression spicy::detail::codegen::ParserState::lahead = look_ahead::None |
Expression with the current look-ahead symbol, or look_ahead::None
if none. Look ahead-symbols are of type look_ahead::Type
.
Expression spicy::detail::codegen::ParserState::lahead_end |
Expression with a iterator pointing to the end of the current look-ahead symbol. Only well-defined if lahead is set.
LiteralMode spicy::detail::codegen::ParserState::literal_mode = LiteralMode::Default |
Mode for parsing literals.
bool spicy::detail::codegen::ParserState::needs_look_ahead |
True if the current grammar needs look-ahead tracking. Expression referencing the current parse object.
Expression spicy::detail::codegen::ParserState::self |
Expression referencing the stream instance we're working on.
Expression spicy::detail::codegen::ParserState::trim |
Boolean expression indicating whether the input data can be trimmed once consumed.
std::reference_wrapper<const type::Unit> spicy::detail::codegen::ParserState::unit |
Unit type that's currently being compiled.
ID spicy::detail::codegen::ParserState::unit_id |
Type name of unit type tha's currently being compiled.