SyntaxTutor
Educational app designed to help compiler students understand LL(1) and SLR(1) parsing algorithms.
 
Loading...
Searching...
No Matches
SymbolTable Struct Reference

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_typest_
 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.
 

Detailed Description

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 $.

Member Function Documentation

◆ In()

bool SymbolTable::In ( const std::string & s) const

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 SymbolTable::IsTerminal ( const std::string & s) const

Checks if a symbol is a terminal.

Parameters
sSymbol identifier to check.
Returns
true if the symbol is terminal, otherwise false.
Here is the caller graph for this function:

◆ IsTerminalWthoEol()

bool SymbolTable::IsTerminalWthoEol ( const std::string & s) const

Checks if a symbol is a terminal excluding EOL.

Parameters
sSymbol identifier to check.
Returns
true if the symbol is terminal, otherwise false.

◆ PutSymbol()

void SymbolTable::PutSymbol ( const std::string & identifier,
bool isTerminal )

Adds a non-terminal symbol to the symbol table.

Parameters
identifierName of the symbol.
isTerminalTrue if the identifier is a terminal symbol
Here is the caller graph for this function:

Member Data Documentation

◆ EOL_

std::string SymbolTable::EOL_ {"$"}

End-of-line symbol used in parsing, initialized as "$".

◆ EPSILON_

std::string SymbolTable::EPSILON_ {"EPSILON"}

Epsilon symbol, representing empty transitions, initialized as "EPSILON".

◆ non_terminals_

std::unordered_set<std::string> SymbolTable::non_terminals_

Set of all non-terminal symbols.

◆ st_

std::unordered_map<std::string, symbol_type> SymbolTable::st_
Initial value:
std::string EOL_
End-of-line symbol used in parsing, initialized as "$".
Definition symbol_table.hpp:28
std::string EPSILON_
Epsilon symbol, representing empty transitions, initialized as "EPSILON".
Definition symbol_table.hpp:32
@ TERMINAL
Definition symbol_table.hpp:15

Main symbol table, mapping identifiers to a pair of symbol type and its regex.

◆ terminals_

std::unordered_set<std::string> SymbolTable::terminals_ {EOL_}

Set of all terminal symbols (including EOL).

◆ terminals_wtho_eol_

std::unordered_set<std::string> SymbolTable::terminals_wtho_eol_ {}

Set of terminal symbols excluding the EOL symbol ($).


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