Spicy
Public Member Functions | List of all members
spicy::detail::codegen::production::While Class Reference

#include <while.h>

Inheritance diagram for spicy::detail::codegen::production::While:
spicy::detail::codegen::ProductionBase spicy::trait::isNonTerminal spicy::trait::isProduction

Public Member Functions

 While (const std::string &symbol, Expression e, Production body, const Location &l=location::None)
 
 While (const std::string &symbol, Production body, const Location &l=location::None)
 
const auto & expression () const
 
const auto & body () const
 
void preprocessLookAhead (Grammar *grammar)
 
const production::LookAheadlookAheadProduction () const
 
std::vector< std::vector< Production > > rhss () const
 
std::optional< spicy::Typetype () const
 
bool nullable () const
 
bool eodOk () const
 
bool atomic () const
 
std::string render () const
 
- Public Member Functions inherited from spicy::detail::codegen::ProductionBase
 ProductionBase (std::string symbol, Location l=location::None)
 
bool hasSize () const
 
const Locationlocation () const
 
const std::string & symbol () const
 
void setSymbol (const std::string &s)
 
std::optional< Expression > filter () const
 
void setFilter (const Expression &filter)
 
std::optional< Expression > sink () const
 
void setSink (const Expression &sink)
 
const production::Metameta () const
 
void setMeta (production::Meta m)
 
std::shared_ptr< production::Meta_metaInstance () const
 
void _setMetaInstance (std::shared_ptr< production::Meta > m)
 

Detailed Description

A production executing as long as either a given boolean expression evaluates to true, or, if no expression is provided, as determined by look-ahead symbols.

Constructor & Destructor Documentation

◆ While() [1/2]

spicy::detail::codegen::production::While::While ( const std::string &  symbol,
Expression  e,
Production  body,
const Location l = location::None 
)
inline

Constructor for a while-loop using an expression as the condition for termination.

◆ While() [2/2]

production::While::While ( const std::string &  symbol,
Production  body,
const Location l = location::None 
)

Constructor for a while-loop using look-ahead as the condition for termination. When using this constructor, preprocessLookAhead() must later be called with the grammar that the production has been inserted into.

Member Function Documentation

◆ body()

const auto& spicy::detail::codegen::production::While::body ( ) const
inline

Returns the body production as passed into any of the constructors.

◆ expression()

const auto& spicy::detail::codegen::production::While::expression ( ) const
inline

Returns the loop expression if passed into the corresponding constructor.

◆ lookAheadProduction()

const production::LookAhead& spicy::detail::codegen::production::While::lookAheadProduction ( ) const
inline

For a look-ahead loop, returns the internally generated LookAhead production that's being used for generating the code to terminate the loop. The production's 1st alternative corresponds to the case of terminating the loop, the 2nd alternative corresponds to executing the loop body. This method must be called only after preprocessLookAhead().

◆ preprocessLookAhead()

void production::While::preprocessLookAhead ( Grammar grammar)

Prepares the internal grammar representation for a look-ahead based loop. Must be called (only) when the corresponding constructor was used.

Parameters
grammargrammar that while-production is being part of.

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