![]() |
HAL
|
Classes | |
struct | Token |
Token refers to a token identifier and accompanied data. More... | |
Enumerations | |
enum class | ParserType { Liberty , Standard } |
ParserType refers to the parser identifier. More... | |
enum class | TokenType { And , Not , NotSuffix , Or , Xor , Variable , Constant , BracketOpen , BracketClose } |
TokenType refers to a token identifier for a Boolean function string. More... | |
Functions | |
Result< std::vector< Token > > | parse_with_liberty_grammar (const std::string &expression) |
Result< std::vector< Token > > | parse_with_standard_grammar (const std::string &expression) |
std::ostream & | operator<< (std::ostream &os, const Token &token) |
Result< std::vector< Token > > | reverse_polish_notation (std::vector< Token > &&tokens, const std::string &expression, const ParserType &parser) |
Result< BooleanFunction > | translate (std::vector< Token > &&tokens, const std::string &expression) |
|
strong |
|
strong |
TokenType refers to a token identifier for a Boolean function string.
std::ostream& hal::BooleanFunctionParser::operator<< | ( | std::ostream & | os, |
const Token & | token | ||
) |
Outputs a token to the given output stream.
[in] | os | - The output stream. |
[in] | token | - The token to be output. |
Definition at line 90 of file parser_types.cpp.
Result< std::vector< Token > > hal::BooleanFunctionParser::parse_with_liberty_grammar | ( | const std::string & | expression | ) |
Parses a Boolean function from a string representation into its tokens based on the data format defined for Liberty, see Liberty user guide.
[in] | expression | - Boolean function string. |
Definition at line 13 of file parser_liberty.cpp.
References hal::BooleanFunctionParser::Token::And(), hal::BooleanFunctionParser::Token::BracketClose(), hal::BooleanFunctionParser::Token::BracketOpen(), hal::BooleanFunctionParser::Token::Constant(), ERR, name, hal::BooleanFunctionParser::Token::Not(), hal::BooleanFunctionParser::Token::NotSuffix(), OK, hal::BooleanFunctionParser::Token::Or(), hal::BooleanFunctionParser::Token::Variable(), and hal::BooleanFunctionParser::Token::Xor().
Referenced by hal::BooleanFunction::from_string().
Result< std::vector< Token > > hal::BooleanFunctionParser::parse_with_standard_grammar | ( | const std::string & | expression | ) |
Parses a Boolean function from a string representation into its tokens.
[in] | expression | - Boolean function string. |
Definition at line 13 of file parser_standard.cpp.
References hal::BooleanFunctionParser::Token::And(), hal::BooleanFunctionParser::Token::BracketClose(), hal::BooleanFunctionParser::Token::BracketOpen(), hal::BooleanFunctionParser::Token::Constant(), ERR, name, hal::BooleanFunctionParser::Token::Not(), OK, hal::BooleanFunctionParser::Token::Or(), hal::BooleanFunctionParser::Token::Variable(), and hal::BooleanFunctionParser::Token::Xor().
Referenced by hal::BooleanFunction::from_string().
Result< std::vector< Token > > hal::BooleanFunctionParser::reverse_polish_notation | ( | std::vector< Token > && | tokens, |
const std::string & | expression, | ||
const ParserType & | parser | ||
) |
Transforms a list of tokens in infix notation (e.g., "A & B") into the reverse polish notation notation (e.g., "A B &") that allows for an easy translation into the AST data structure.
In order to translate between the different notations, we leverage the well-known Shunting Yard algorithm, see wikipedia for an example: https://en.wikipedia.org/wiki/Shunting-yard_algorithm
[in] | tokens | - List of tokens in infix notation. |
[in] | expression | - Expression string. |
[in] | parser | - Parser identifier |
Definition at line 137 of file parser_types.cpp.
References And, BracketClose, BracketOpen, Constant, ERR, Not, hal::BooleanFunctionParser::Token::Not(), NotSuffix, OK, Or, hal::output, control::parser, Variable, and Xor.
Referenced by hal::BooleanFunction::from_string().
Result< BooleanFunction > hal::BooleanFunctionParser::translate | ( | std::vector< Token > && | tokens, |
const std::string & | expression | ||
) |
Translates a list of tokens (in reverse-polish notation form) into a list of BooleanFunction nodes that are then assembled into a Boolean function.
[in] | tokens | - List of tokens. |
[in] | expression | - Expression string. |
Definition at line 214 of file parser_types.cpp.
References hal::BooleanFunction::NodeType::And, And, hal::BooleanFunction::build(), hal::BooleanFunction::Node::Constant(), Constant, ERR, ERR_APPEND, hal::BooleanFunction::NodeType::Not, Not, hal::BooleanFunction::Node::Operation(), hal::BooleanFunction::NodeType::Or, Or, hal::BooleanFunction::Node::Variable(), Variable, hal::BooleanFunction::NodeType::Xor, and Xor.
Referenced by hal::BooleanFunction::from_string().