4#include <unordered_map>
31 const std::unordered_map<std::string, std::vector<production>>&
43 void SetAxiom(
const std::string& axiom);
69 const std::string& arg)
const;
90 const std::vector<std::string>& consequent);
102 std::vector<std::string>
Split(
const std::string& s);
108 std::unordered_map<std::string, std::vector<production>>
g_;
std::vector< std::string > production
Represents the right-hand side of a grammar rule.
Definition grammar.hpp:17
void SetAxiom(const std::string &axiom)
Sets the axiom (entry point) of the grammar.
Definition grammar.cpp:32
std::vector< std::pair< const std::string, production > > FilterRulesByConsequent(const std::string &arg) const
Filters grammar rules that contain a specific token in their consequent.
Definition grammar.cpp:45
bool HasEmptyProduction(const std::string &antecedent) const
Checks if a given antecedent has an empty production.
Definition grammar.cpp:37
std::string axiom_
The axiom or entry point of the grammar.
Definition grammar.hpp:113
void Debug() const
Prints the current grammar structure to standard output.
Definition grammar.cpp:61
SymbolTable st_
Symbol table of the grammar.
Definition grammar.hpp:118
void AddProduction(const std::string &antecedent, const std::vector< std::string > &consequent)
Adds a production rule to the grammar and updates the symbol table.
Definition grammar.cpp:78
std::unordered_map< std::string, std::vector< production > > g_
Stores the grammar rules with each antecedent mapped to a list of productions.
Definition grammar.hpp:108
std::vector< std::string > Split(const std::string &s)
Splits a string into grammar symbols using the current symbol table.
Definition grammar.cpp:83
Stores and manages grammar symbols, including their classification and special markers.
Definition symbol_table.hpp:26