|
HAL
v4.5.0-254-g8f9f6a423
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
|
Classes | |
| struct | Token |
| Token refers to a token identifier and accompanied data. More... | |
Enumerations | |
| enum class | ParserType { Liberty , Standard , LibertyNoSpace } |
| ParserType refers to the parser identifier. More... | |
| enum class | TokenType { And , Not , NotSuffix , Or , Xor , Eq , Question , Colon , Add , Sub , Mul , Variable , Constant , BracketOpen , BracketClose } |
| TokenType refers to a token identifier for a Boolean function string. More... | |
Functions | |
| Result< std::vector< Token > > | parse_with_standard_grammar (const std::string &expression, const std::map< std::string, u16 > &var_sizes={}) |
| Result< std::vector< Token > > | parse_with_liberty_grammar (const std::string &expression, const std::map< std::string, u16 > &var_sizes={}) |
| 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) |
| std::ostream & | operator<< (std::ostream &os, const Token &token) |
Contains the tokenizer and the parsers that translate a string into a Boolean function.
|
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 133 of file parser_types.cpp.
| Result< std::vector< Token > > hal::BooleanFunctionParser::parse_with_liberty_grammar | ( | const std::string & | expression, |
| const std::map< std::string, u16 > & | var_sizes = {} |
||
| ) |
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. |
| [in] | var_sizes | - Optional map from variable name to bit-width; variables not in the map default to 1 bit. |
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, |
| const std::map< std::string, u16 > & | var_sizes = {} |
||
| ) |
Parses a Boolean function from a string representation into its tokens.
| [in] | expression | - Boolean function string. |
| [in] | var_sizes | - Optional map from variable name to bit-width; variables not in the map default to 1 bit. |
Definition at line 13 of file parser_standard.cpp.
References hal::BooleanFunctionParser::Token::Add(), hal::BooleanFunctionParser::Token::And(), hal::BooleanFunctionParser::Token::BracketClose(), hal::BooleanFunctionParser::Token::BracketOpen(), hal::BooleanFunctionParser::Token::Colon(), hal::BooleanFunctionParser::Token::Constant(), hal::BooleanFunctionParser::Token::Eq(), ERR, hal::BooleanFunctionParser::Token::Mul(), name, hal::BooleanFunctionParser::Token::Not(), OK, hal::BooleanFunctionParser::Token::Or(), hal::BooleanFunctionParser::Token::Question(), hal::BooleanFunctionParser::Token::Sub(), 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 186 of file parser_types.cpp.
References Add, And, BracketClose, BracketOpen, Colon, Constant, Eq, ERR, Mul, Not, hal::BooleanFunctionParser::Token::Not(), NotSuffix, OK, Or, hal::output, Question, Sub, 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 297 of file parser_types.cpp.
References hal::BooleanFunction::NodeType::Add, Add, hal::BooleanFunction::NodeType::And, And, hal::BooleanFunction::build(), Colon, hal::BooleanFunction::Node::Constant(), Constant, hal::BooleanFunction::NodeType::Eq, Eq, ERR, ERR_APPEND, hal::BooleanFunction::NodeType::Ite, hal::BooleanFunction::NodeType::Mul, Mul, hal::BooleanFunction::NodeType::Not, Not, hal::BooleanFunction::Node::Operation(), hal::BooleanFunction::NodeType::Or, Or, Question, hal::BooleanFunction::NodeType::Sub, Sub, hal::BooleanFunction::Node::Variable(), Variable, hal::BooleanFunction::NodeType::Xor, and Xor.
Referenced by hal::BooleanFunction::from_string().