LL1Checker 5.0
“Tool for verifying LL(1) grammars and validating input strings.”
Loading...
Searching...
No Matches
symbol_table Struct Reference

Public Types

using TokenID = unsigned long

Static Public Member Functions

static void PutSymbol (const std::string &identifier, const std::string &regex)
 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 Public Attributes

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.

Member Function Documentation

◆ 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
terminalTerminal 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
sSymbol 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
sSymbol 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
identifierName 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
identifierName of the terminal symbol.
regexRegular expression representing the terminal symbol.

Member Data Documentation

◆ lookup_

std::unordered_map<std::string, TokenID> symbol_table::lookup_
inlinestatic
Initial value:
{
{EOF_, EOF_ID}, {EPSILON_, EPSILON_ID}}
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: