|
|
using | TokenID = unsigned long |
|
| static void | PutSymbol (const std::string &identifier, const std::string ®ex) |
| | Adds a terminal symbol with its associated regex to the symbol table.
|
| static void | PutSymbol (const std::string &identifier) |
| | Adds a non-terminal symbol to the symbol table.
|
| static bool | In (TokenID id) |
| | Checks if a symbol exists in the symbol table.
|
|
static bool | In (const std::string &identifier) |
| static bool | IsTerminal (TokenID id) |
| | Checks if a symbol is a terminal.
|
| static std::string | GetValue (TokenID id) |
| | Retrieves the regex pattern for a terminal symbol.
|
|
static const std::string & | ToString (TokenID id) |
| | Convert a token ID to its identifier string.
|
|
static TokenID | ToID (const std::string &identifier) |
| | Retrieve the token ID for a given identifier string.
|
| static void | Debug () |
| | Prints all symbols and their properties in the symbol table.
|
|
|
static TokenID | INVALID_TOKEN {0} |
|
static TokenID | EOF_ID {1} |
|
static TokenID | EPSILON_ID {2} |
|
static TokenID | next_id_ {3} |
|
static std::string | EOF_ {"<<EOF>>"} |
| | End-of-line symbol used in parsing, initialized as "EOF".
|
|
static std::string | EPSILON_ {"<<EPSILON>>"} |
| | Epsilon symbol, representing empty transitions, initialized as "EPSILON".
|
| static std::vector< std::pair< symbol_type, std::string > > | st_ |
| | Symbol table indexed by token ID storing type and regex.
|
| static std::unordered_map< std::string, TokenID > | lookup_ |
| | Mapping from identifier to token ID.
|
|
static std::vector< std::string > | names_ {"", EOF_, EPSILON_} |
| | Reverse mapping from token ID to identifier.
|
|
static std::vector< TokenID > | order_ {EOF_ID} |
| | Tracks insertion order of terminal token types.
|
◆ Debug()
| void symbol_table::Debug |
( |
| ) |
|
|
static |
Prints all symbols and their properties in the symbol table.
Outputs the symbol table for debugging purposes.
◆ GetValue()
| std::string symbol_table::GetValue |
( |
TokenID | id | ) |
|
|
static |
Retrieves the regex pattern for a terminal symbol.
- Parameters
-
| terminal | Terminal symbol identifier. |
- Returns
- Regex pattern associated with the terminal symbol.
◆ In()
| bool symbol_table::In |
( |
TokenID | id | ) |
|
|
static |
Checks if a symbol exists in the symbol table.
- Parameters
-
| s | Symbol identifier to search. |
- Returns
- true if the symbol is present, otherwise false.
◆ IsTerminal()
| bool symbol_table::IsTerminal |
( |
TokenID | id | ) |
|
|
static |
Checks if a symbol is a terminal.
- Parameters
-
| s | Symbol identifier to check. |
- Returns
- true if the symbol is terminal, otherwise false.
◆ PutSymbol() [1/2]
| void symbol_table::PutSymbol |
( |
const std::string & | identifier | ) |
|
|
static |
Adds a non-terminal symbol to the symbol table.
- Parameters
-
| identifier | Name of the non-terminal symbol. |
◆ PutSymbol() [2/2]
| void symbol_table::PutSymbol |
( |
const std::string & | identifier, |
|
|
const std::string & | regex ) |
|
static |
Adds a terminal symbol with its associated regex to the symbol table.
Updates the token type mappings and tracks insertion order.
- Parameters
-
| identifier | Name of the terminal symbol. |
| regex | Regular expression representing the terminal symbol. |
◆ lookup_
| std::unordered_map<std::string, TokenID> symbol_table::lookup_ |
|
inlinestatic |
Initial value:{
static std::string EOF_
End-of-line symbol used in parsing, initialized as "EOF".
Definition symbol_table.hpp:19
static std::string EPSILON_
Epsilon symbol, representing empty transitions, initialized as "EPSILON".
Definition symbol_table.hpp:23
Mapping from identifier to token ID.
◆ st_
| std::vector<std::pair<symbol_type, std::string> > symbol_table::st_ |
|
inlinestatic |
Initial value:{
{META, ""},
{TERMINAL, ""},
{META, ""},
}
Symbol table indexed by token ID storing type and regex.
The documentation for this struct was generated from the following files: