Parsnip
parsing library
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
Parsnip::ValueEvaluator Class Referenceabstract

Evaluate a value/fill-in field. More...

#include <parsnip_evaluate.h>

Inheritance diagram for Parsnip::ValueEvaluator:
Parsnip::Evaluator Parsnip::IntegerEvaluator Parsnip::RealEvaluator Parsnip::StringEvaluator Parsnip::RawRemainderEvaluator Parsnip::RegExEvaluator

Public Member Functions

virtual bool operator== (const Evaluator &other) const override
 Check if two evaluators are the same.
 
virtual void convertToOptionEvaluator () override
 Make any changes to the parse tree to convert it to an options evaluator.
 
virtual SchemaBasegetSchema () const =0
 
virtual void constructSchema (const DictionarySchema &scheme, const Schema::OptionSchemas &option_schemas, const SchemaIntegratorCallback &integrator) const override
 Construct a schema from an evaluator tree.
 
 Evaluator ()=default
 
 Evaluator (Evaluator *original)
 Upgrade an evaluator.
 
- Public Member Functions inherited from Parsnip::Evaluator
 Evaluator (Evaluator *original)
 Upgrade an evaluator.
 
int evaluate (ArgvCursor *cursor, Parsnip::Data &result_dict)
 Evaluate a token in the command line, and recurse if there is more to go.
 
bool operator!= (const Evaluator &other) const
 

Static Public Member Functions

static void construct (EvaluatorRef &parser, const ArgvCursor &cursor, CommandId id, Parser *parent_parser, std::string name, std::string keywords)
 Construct a value/fill-in token handler.
 
- Static Public Member Functions inherited from Parsnip::Evaluator
static void construct (EvaluatorRef &evaluator, const ArgvCursor &cursor, CommandId id, Parser *parent_parser)
 Construct token handler from the token in a parsing definition.
 

Protected Member Functions

virtual EvaluatorgetNextEvaluator (const StringType &value) const override
 Determine if and how to evaluate additional command line tokens.
 
- Protected Member Functions inherited from Parsnip::Evaluator
void setCommandId (CommandId id)
 Set the command ID in an evaluator.
 
virtual Parsnip::Data evaluateToken (class ArgvCursor *cursor) const =0
 Evaluate command line tokens.
 

Protected Attributes

EvaluatorRef next_evaluator
 
- Protected Attributes inherited from Parsnip::Evaluator
CommandId command_id {NoCommand}
 If this completes a command, the command ID.
 
std::string name
 If not empty, the name by which this value shall be accessed.
 

Additional Inherited Members

- Public Types inherited from Parsnip::Evaluator
using StringType = std::string
 
using CommandId = int
 
- Static Protected Member Functions inherited from Parsnip::Evaluator
static void set_name (EvaluatorRef &target, const std::string &name)
 Assign a name by which to store values for value evaluators.
 

Detailed Description

Evaluate a value/fill-in field.

Member Function Documentation

◆ construct()

void Parsnip::ValueEvaluator::construct ( EvaluatorRef &  parser,
const ArgvCursor cursor,
CommandId  id,
Parser parent_parser,
std::string  name,
std::string  format 
)
static

Construct a value/fill-in token handler.

Construct token handler accepting a fixed list of values from the parsing definition.

Parameters
parserSee Evaluator::construct
cursorSee Evaluator::construct
idSee Evaluator::construct
parent_parserThe containing parser, with previously constructed option parsers that may be referenced.
nameThe name by which to access the selected keyword.
formatFormat and range details for numbers. Construct a value/fill-in token handler

◆ constructSchema()

void Parsnip::ValueEvaluator::constructSchema ( const DictionarySchema schema,
const Schema::OptionSchemas &  option_schemas,
const SchemaIntegratorCallback &  integrator 
) const
overridevirtual

Construct a schema from an evaluator tree.

This function depth-first searches the evaluation tree, calling the integrator function at leaf nodes and other valid statement endpoints.

Parameters
schemaThe schema, as constructed from the parse tree root.
option_schemasSchemas for option parsers that may be needed.
integratorAn integrator that merges various statement patterns into a complete schema.
Exceptions
NoSuchKeyA necessary option schema was not found.
SchemaConflictStatement definitions generate schema inconsistencies.

Implements Parsnip::Evaluator.

◆ convertToOptionEvaluator()

void Parsnip::ValueEvaluator::convertToOptionEvaluator ( )
overridevirtual

Make any changes to the parse tree to convert it to an options evaluator.

Implements Parsnip::Evaluator.

◆ Evaluator()

Parsnip::Evaluator::Evaluator ( Evaluator original)

Upgrade an evaluator.

The original must be a TerminatorEvaluator; other type should never be upgraded. Herein we initialize the new evaluator with the relevant bits.

◆ getNextEvaluator()

Evaluator * Parsnip::ValueEvaluator::getNextEvaluator ( const StringType &  token) const
overrideprotectedvirtual

Determine if and how to evaluate additional command line tokens.

Parameters
tokenThe current token being evaluated.
Returns
The evaluator for the next token, or nullptr if evaluation is complete.

Implements Parsnip::Evaluator.

◆ operator==()

bool Parsnip::ValueEvaluator::operator== ( const Evaluator other) const
overridevirtual

Check if two evaluators are the same.

Subclasses should override this to check their details.

Parameters
otherAnother evaluator to which to compare.

Reimplemented from Parsnip::Evaluator.

Reimplemented in Parsnip::RegExEvaluator, Parsnip::IntegerEvaluator, and Parsnip::RealEvaluator.


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