3#include <unordered_map>
7enum symbol_type { NO_TERMINAL, TERMINAL };
11 inline static std::string
EOL_{
"$"};
19 inline static std::unordered_map<std::string,
20 std::pair<symbol_type, std::string>>
24 inline static std::unordered_map<std::string, unsigned long>
token_types_{
32 inline static std::vector<unsigned long>
order_{1};
35 inline static unsigned long i_{2};
46 static void PutSymbol(
const std::string& identifier,
47 const std::string& regex);
54 static void PutSymbol(
const std::string& identifier);
62 static bool In(
const std::string& s);
78 static std::string
GetValue(
const std::string& terminal);
92 static void SetEol(
const std::string& eol);
Definition symbol_table.hpp:9
static std::string GetValue(const std::string &terminal)
Retrieves the regex pattern for a terminal symbol.
Definition symbol_table.cpp:18
static void PutSymbol(const std::string &identifier, const std::string ®ex)
Adds a terminal symbol with its associated regex to the symbol table.
Definition symbol_table.cpp:6
static std::unordered_map< unsigned long, std::string > token_types_r_
Reverse mapping from integer token IDs back to symbols.
Definition symbol_table.hpp:28
static std::unordered_map< std::string, std::pair< symbol_type, std::string > > st_
Main symbol table, mapping identifiers to a pair of symbol type and its regex.
Definition symbol_table.hpp:21
static unsigned long i_
Current index for assigning new token IDs, starting from 2.
Definition symbol_table.hpp:35
static bool IsTerminal(const std::string &s)
Checks if a symbol is a terminal.
Definition symbol_table.cpp:34
static bool In(const std::string &s)
Checks if a symbol exists in the symbol table.
Definition symbol_table.cpp:30
static std::vector< unsigned long > order_
Tracks insertion order of token types.
Definition symbol_table.hpp:32
static std::unordered_map< std::string, unsigned long > token_types_
Token types, mapping each symbol to a unique integer ID.
Definition symbol_table.hpp:24
static std::string EPSILON_
Epsilon symbol, representing empty transitions, initialized as "EPSILON".
Definition symbol_table.hpp:15
static std::string EOL_
End-of-line symbol used in parsing, initialized as "$".
Definition symbol_table.hpp:11
static void Debug()
Prints all symbols and their properties in the symbol table.
Definition symbol_table.cpp:22
static void SetEol(const std::string &eol)
Sets the end-of-line symbol.
Definition symbol_table.cpp:38