Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
storm::parser::ExpressionParser Class Reference

#include <ExpressionParser.h>

Inheritance diagram for storm::parser::ExpressionParser:
Collaboration diagram for storm::parser::ExpressionParser:

Public Member Functions

 ExpressionParser (storm::expressions::ExpressionManager const &manager, qi::symbols< char, uint_fast64_t > const &invalidIdentifiers_=qi::symbols< char, uint_fast64_t >(), bool enableErrorHandling=true, bool allowBacktracking=false)
 Creates an expression parser.
 
 ~ExpressionParser ()
 
 ExpressionParser (ExpressionParser const &other)=delete
 
ExpressionParseroperator= (ExpressionParser const &other)=delete
 
void setIdentifierMapping (qi::symbols< char, storm::expressions::Expression > const *identifiers_)
 Sets an identifier mapping that is used to determine valid variables in the expression.
 
void setIdentifierMapping (std::unordered_map< std::string, storm::expressions::Expression > const &identifierMapping)
 Sets an identifier mapping that is used to determine valid variables in the expression.
 
void unsetIdentifierMapping ()
 Unsets a previously set identifier mapping.
 
void setAcceptDoubleLiterals (bool flag)
 Sets whether double literals are to be accepted or not.
 
storm::expressions::Expression parseFromString (std::string const &expressionString, bool ignoreError=false) const
 Parses an expression from the given string.
 

Detailed Description

Definition at line 36 of file ExpressionParser.h.

Constructor & Destructor Documentation

◆ ExpressionParser() [1/2]

storm::parser::ExpressionParser::ExpressionParser ( storm::expressions::ExpressionManager const &  manager,
qi::symbols< char, uint_fast64_t > const &  invalidIdentifiers_ = qi::symbols<char, uint_fast64_t>(),
bool  enableErrorHandling = true,
bool  allowBacktracking = false 
)

Creates an expression parser.

Initially the parser is set to a mode in which it will not generate the actual expressions but only perform a syntax check and return the expression "false". To make the parser generate the actual expressions, a mapping of valid identifiers to their expressions need to be provided later.

Parameters
managerThe manager responsible for the expressions.
invalidIdentifiers_A symbol table of identifiers that are to be rejected.
enableErrorHandlingEnables error handling within the parser. Note that this should should be set to true when using the parser as the top level parser.
allowBacktrackingA flag that indicates whether or not the parser is supposed to backtrack beyond points it would typically allow. This can, for example, be used to prevent errors if the outer grammar also parses boolean conjuncts that are erroneously consumed by the expression parser.

Enable this for debugging purposes. debug(expression); debug(iteExpression); debug(orExpression); debug(andExpression); debug(equalityExpression); debug(relativeExpression); debug(plusExpression); debug(multiplicationExpression); debug(infixPowerModuloExpression); debug(unaryExpression); debug(atomicExpression); debug(literalExpression); debug(identifierExpression);

Definition at line 42 of file ExpressionParser.cpp.

◆ ~ExpressionParser()

storm::parser::ExpressionParser::~ExpressionParser ( )

Definition at line 296 of file ExpressionParser.cpp.

◆ ExpressionParser() [2/2]

storm::parser::ExpressionParser::ExpressionParser ( ExpressionParser const &  other)
delete

Member Function Documentation

◆ operator=()

ExpressionParser & storm::parser::ExpressionParser::operator= ( ExpressionParser const &  other)
delete

◆ parseFromString()

storm::expressions::Expression storm::parser::ExpressionParser::parseFromString ( std::string const &  expressionString,
bool  ignoreError = false 
) const

Parses an expression from the given string.

Parameters
ignoreErrorIf set, no exception is thrown upon a parser error. The returned expression will be uninitialized.

Definition at line 323 of file ExpressionParser.cpp.

◆ setAcceptDoubleLiterals()

void storm::parser::ExpressionParser::setAcceptDoubleLiterals ( bool  flag)

Sets whether double literals are to be accepted or not.

Parameters
flagIf set to true, double literals are accepted.

Definition at line 312 of file ExpressionParser.cpp.

◆ setIdentifierMapping() [1/2]

void storm::parser::ExpressionParser::setIdentifierMapping ( qi::symbols< char, storm::expressions::Expression > const *  identifiers_)

Sets an identifier mapping that is used to determine valid variables in the expression.

The mapped-to expressions will be substituted wherever the key value appears in the parsed expression. After setting this, the parser will generate expressions.

Parameters
identifiers_A pointer to a mapping from identifiers to expressions.

Definition at line 300 of file ExpressionParser.cpp.

◆ setIdentifierMapping() [2/2]

void storm::parser::ExpressionParser::setIdentifierMapping ( std::unordered_map< std::string, storm::expressions::Expression > const &  identifierMapping)

Sets an identifier mapping that is used to determine valid variables in the expression.

The mapped-to expressions will be substituted wherever the key value appears in the parsed expression. After setting this, the parser will generate expressions.

Parameters
identifierMappingA mapping from identifiers to expressions.

Definition at line 304 of file ExpressionParser.cpp.

◆ unsetIdentifierMapping()

void storm::parser::ExpressionParser::unsetIdentifierMapping ( )

Unsets a previously set identifier mapping.

This will make the parser not generate expressions any more but merely check for syntactic correctness of an expression.

Definition at line 308 of file ExpressionParser.cpp.


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