Stores and manages grammar symbols, including their classification and special markers. More...
#include <symbol_table.hpp>
Public Member Functions | |
void | PutSymbol (const std::string &identifier, bool isTerminal) |
Adds a non-terminal symbol to the symbol table. | |
bool | In (const std::string &s) const |
Checks if a symbol exists in the symbol table. | |
bool | IsTerminal (const std::string &s) const |
Checks if a symbol is a terminal. | |
bool | IsTerminalWthoEol (const std::string &s) const |
Checks if a symbol is a terminal excluding EOL. | |
Public Attributes | |
std::string | EOL_ {"$"} |
End-of-line symbol used in parsing, initialized as "$". | |
std::string | EPSILON_ {"EPSILON"} |
Epsilon symbol, representing empty transitions, initialized as "EPSILON". | |
std::unordered_map< std::string, symbol_type > | st_ |
Main symbol table, mapping identifiers to a pair of symbol type and its regex. | |
std::unordered_set< std::string > | terminals_ {EOL_} |
Set of all terminal symbols (including EOL). | |
std::unordered_set< std::string > | terminals_wtho_eol_ {} |
Set of terminal symbols excluding the EOL symbol ($). | |
std::unordered_set< std::string > | non_terminals_ |
Set of all non-terminal symbols. | |
Stores and manages grammar symbols, including their classification and special markers.
This structure holds information about all terminals and non-terminals used in a grammar, as well as special symbols such as EPSILON and the end-of-line marker ($). It supports symbol classification, membership checks, and filtered views such as terminals excluding $.
bool SymbolTable::In | ( | const std::string & | s | ) | const |
Checks if a symbol exists in the symbol table.
s | Symbol identifier to search. |
bool SymbolTable::IsTerminal | ( | const std::string & | s | ) | const |
Checks if a symbol is a terminal.
s | Symbol identifier to check. |
bool SymbolTable::IsTerminalWthoEol | ( | const std::string & | s | ) | const |
Checks if a symbol is a terminal excluding EOL.
s | Symbol identifier to check. |
void SymbolTable::PutSymbol | ( | const std::string & | identifier, |
bool | isTerminal ) |
Adds a non-terminal symbol to the symbol table.
identifier | Name of the symbol. |
isTerminal | True if the identifier is a terminal symbol |
std::string SymbolTable::EOL_ {"$"} |
End-of-line symbol used in parsing, initialized as "$".
std::string SymbolTable::EPSILON_ {"EPSILON"} |
Epsilon symbol, representing empty transitions, initialized as "EPSILON".
std::unordered_set<std::string> SymbolTable::non_terminals_ |
Set of all non-terminal symbols.
std::unordered_map<std::string, symbol_type> SymbolTable::st_ |
Main symbol table, mapping identifiers to a pair of symbol type and its regex.
std::unordered_set<std::string> SymbolTable::terminals_ {EOL_} |
Set of all terminal symbols (including EOL).
std::unordered_set<std::string> SymbolTable::terminals_wtho_eol_ {} |
Set of terminal symbols excluding the EOL symbol ($).