Spicy
Public Member Functions | Public Attributes | List of all members
spicy::detail::codegen::ParserState Struct Reference

#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
 
ParserStateoperator= (const ParserState &other)=default
 
ParserStateoperator= (ParserState &&other)=default
 
void printDebug (const std::shared_ptr< hilti::builder::Builder > &b) const
 

Public Attributes

std::reference_wrapper< const type::Unitunit
 
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
 
Expression error
 

Detailed Description

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 current input data). This struct records the expressions that are 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.

Member Function Documentation

◆ printDebug()

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.

Parameters
blockbock to add the generated code to

Member Data Documentation

◆ captures

std::optional<Expression> spicy::detail::codegen::ParserState::captures

Target for storing extracted capture groups; set only when needed & desired.

◆ cur

Expression spicy::detail::codegen::ParserState::cur

If set, expression referencing a new cur to set after parsing the current rule.

◆ data

Expression spicy::detail::codegen::ParserState::data

Expression referencing the current view inside 'data'.

◆ error

Expression spicy::detail::codegen::ParserState::error

Expression holding the last parse error if any. This field is set only in sync or trial mode.

◆ lahead

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.

◆ lahead_end

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.

◆ literal_mode

LiteralMode spicy::detail::codegen::ParserState::literal_mode = LiteralMode::Default

Mode for parsing literals.

◆ needs_look_ahead

bool spicy::detail::codegen::ParserState::needs_look_ahead

True if the current grammar needs look-ahead tracking. Expression referencing the current parse object.

◆ self

Expression spicy::detail::codegen::ParserState::self

Expression referencing the stream instance we're working on.

◆ trim

Expression spicy::detail::codegen::ParserState::trim

Boolean expression indicating whether the input data can be trimmed once consumed.

◆ unit

std::reference_wrapper<const type::Unit> spicy::detail::codegen::ParserState::unit

Unit type that's currently being compiled.

◆ unit_id

ID spicy::detail::codegen::ParserState::unit_id

Type name of unit type that is currently being compiled.


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