HAL
hal::BooleanFunctionParser::Token Struct Reference

Token refers to a token identifier and accompanied data. More...

#include <parser.h>

Collaboration diagram for hal::BooleanFunctionParser::Token:
Collaboration graph

Public Member Functions

 Token (TokenType _type, std::tuple< std::string, u16 > variable, std::vector< BooleanFunction::Value > constant)
 Construct a new initialized Token. More...
 
unsigned precedence (const ParserType &type) const
 
bool is (TokenType type) const
 
std::string to_string () const
 

Static Public Member Functions

static Token And ()
 
static Token Not ()
 
static Token NotSuffix ()
 
static Token Or ()
 
static Token Xor ()
 
static Token Variable (std::string name, u16 size)
 
static Token Constant (std::vector< BooleanFunction::Value > value)
 
static Token BracketOpen ()
 
static Token BracketClose ()
 

Public Attributes

TokenType type
 refers to the underlying token type identifier More...
 
std::tuple< std::string, u16variable {}
 optional value and bit-size in case token is a variable More...
 
std::vector< BooleanFunction::Valueconstant {}
 optional value in case token is a constant More...
 

Friends

std::ostream & operator<< (std::ostream &os, const Token &token)
 

Detailed Description

Token refers to a token identifier and accompanied data.

Definition at line 61 of file parser.h.

Constructor & Destructor Documentation

◆ Token()

hal::BooleanFunctionParser::Token::Token ( TokenType  _type,
std::tuple< std::string, u16 variable,
std::vector< BooleanFunction::Value constant 
)

Construct a new initialized Token.

Parameters
[in]_type- The type of the token.
[in]variable- A variable name and bit-size in case the token type is Variable.
[in]constant- A constant value in case the token type is Constant.

Definition at line 133 of file parser_types.cpp.

Referenced by And(), BracketClose(), BracketOpen(), Constant(), Not(), NotSuffix(), Or(), Variable(), and Xor().

Member Function Documentation

◆ And()

Token hal::BooleanFunctionParser::Token::And ( )
static

Creates an AND token.

Returns
The AND token.

Definition at line 11 of file parser_types.cpp.

References hal::BooleanFunctionParser::And, and Token().

Referenced by hal::BooleanFunctionParser::parse_with_liberty_grammar(), and hal::BooleanFunctionParser::parse_with_standard_grammar().

◆ BracketClose()

Token hal::BooleanFunctionParser::Token::BracketClose ( )
static

Creates an BracketClose token.

Returns
The BracketClose token.

Definition at line 51 of file parser_types.cpp.

References hal::BooleanFunctionParser::BracketClose, and Token().

Referenced by hal::BooleanFunctionParser::parse_with_liberty_grammar(), and hal::BooleanFunctionParser::parse_with_standard_grammar().

◆ BracketOpen()

Token hal::BooleanFunctionParser::Token::BracketOpen ( )
static

Creates an BracketOpen token.

Returns
The BracketOpen token.

Definition at line 46 of file parser_types.cpp.

References hal::BooleanFunctionParser::BracketOpen, and Token().

Referenced by hal::BooleanFunctionParser::parse_with_liberty_grammar(), and hal::BooleanFunctionParser::parse_with_standard_grammar().

◆ Constant()

Token hal::BooleanFunctionParser::Token::Constant ( std::vector< BooleanFunction::Value value)
static

Creates an Constant token.

Parameters
[in]value- The (multi-bit) value of the constant.
Returns
The Constant token.

Definition at line 41 of file parser_types.cpp.

References hal::BooleanFunctionParser::Constant, constant, and Token().

Referenced by hal::BooleanFunctionParser::parse_with_liberty_grammar(), and hal::BooleanFunctionParser::parse_with_standard_grammar().

◆ is()

bool hal::BooleanFunctionParser::Token::is ( TokenType  type) const

Short-hand implementation to check for a token type.

Parameters
[in]typeToken type.
Returns
true in case instance has the same token type, false otherwise.

Definition at line 85 of file parser_types.cpp.

References type.

◆ Not()

Token hal::BooleanFunctionParser::Token::Not ( )
static

◆ NotSuffix()

Token hal::BooleanFunctionParser::Token::NotSuffix ( )
static

Creates an NOT_SUFFIX token.

Returns
The NOT_SUFFIX token.

Definition at line 21 of file parser_types.cpp.

References hal::BooleanFunctionParser::NotSuffix, and Token().

Referenced by hal::BooleanFunctionParser::parse_with_liberty_grammar().

◆ Or()

Token hal::BooleanFunctionParser::Token::Or ( )
static

Creates an OR token.

Returns
The OR token.

Definition at line 26 of file parser_types.cpp.

References hal::BooleanFunctionParser::Or, and Token().

Referenced by hal::BooleanFunctionParser::parse_with_liberty_grammar(), and hal::BooleanFunctionParser::parse_with_standard_grammar().

◆ precedence()

unsigned hal::BooleanFunctionParser::Token::precedence ( const ParserType type) const

Returns the precedence of a token.

Parameters
[in]typeThe parser type identifier.
Returns
An unsigned predecene value between 2 and 4.

Definition at line 56 of file parser_types.cpp.

References hal::BooleanFunctionParser::And, hal::BooleanFunctionParser::Liberty, hal::BooleanFunctionParser::Not, hal::BooleanFunctionParser::NotSuffix, hal::BooleanFunctionParser::Or, control::parser, hal::BooleanFunctionParser::Standard, and hal::BooleanFunctionParser::Xor.

◆ to_string()

std::string hal::BooleanFunctionParser::Token::to_string ( ) const

Convert the token to its string representation.

Returns
The string representation of the token.

Definition at line 126 of file parser_types.cpp.

◆ Variable()

Token hal::BooleanFunctionParser::Token::Variable ( std::string  name,
u16  size 
)
static

Creates an Variable token.

Parameters
[in]name- The name of the variable.
[in]size- The bit-size of the variable.
Returns
The Variable token.

Definition at line 36 of file parser_types.cpp.

References name, Token(), and hal::BooleanFunctionParser::Variable.

Referenced by hal::BooleanFunctionParser::parse_with_liberty_grammar(), and hal::BooleanFunctionParser::parse_with_standard_grammar().

◆ Xor()

Token hal::BooleanFunctionParser::Token::Xor ( )
static

Creates an XOR token.

Returns
The XOR token.

Definition at line 31 of file parser_types.cpp.

References Token(), and hal::BooleanFunctionParser::Xor.

Referenced by hal::BooleanFunctionParser::parse_with_liberty_grammar(), and hal::BooleanFunctionParser::parse_with_standard_grammar().

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Token token 
)
friend

Outputs a token to the given output stream.

Parameters
[in]os- The output stream.
[in]token- The token to be output.
Returns
The output stream.

Definition at line 90 of file parser_types.cpp.

Member Data Documentation

◆ constant

std::vector<BooleanFunction::Value> hal::BooleanFunctionParser::Token::constant {}

optional value in case token is a constant

Definition at line 72 of file parser.h.

Referenced by Constant().

◆ type

TokenType hal::BooleanFunctionParser::Token::type

refers to the underlying token type identifier

Definition at line 68 of file parser.h.

Referenced by is().

◆ variable

std::tuple<std::string, u16> hal::BooleanFunctionParser::Token::variable {}

optional value and bit-size in case token is a variable

Definition at line 70 of file parser.h.


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