24#include <unordered_map>
25#include <unordered_set>
45 using ll1_table = std::unordered_map<
46 std::string, std::unordered_map<std::string, std::vector<production>>>;
106 void First(std::span<const std::string> rule,
107 std::unordered_set<std::string>& result);
162 std::unordered_set<std::string>
Follow(
const std::string& arg);
185 std::unordered_set<std::string>
187 const std::vector<std::string>& consequent);
197 std::unordered_map<std::string, std::unordered_set<std::string>>
201 std::unordered_map<std::string, std::unordered_set<std::string>>
void ComputeFollowSets()
Computes the FOLLOW sets for all non-terminal symbols in the grammar. The FOLLOW set of a non-termina...
Definition ll1_parser.cpp:133
std::unordered_set< std::string > Follow(const std::string &arg)
Computes the FOLLOW set for a given non-terminal symbol in the grammar.
Definition ll1_parser.cpp:186
ll1_table ll1_t_
The LL(1) parsing table, mapping non-terminals and terminals to productions.
Definition ll1_parser.hpp:191
void ComputeFirstSets()
Computes the FIRST sets for all non-terminal symbols in the grammar.
Definition ll1_parser.cpp:102
std::unordered_set< std::string > PredictionSymbols(const std::string &antecedent, const std::vector< std::string > &consequent)
Computes the prediction symbols for a given production rule.
Definition ll1_parser.cpp:194
bool CreateLL1Table()
Creates the LL(1) parsing table for the grammar.
Definition ll1_parser.cpp:36
Grammar gr_
Grammar object associated with this parser.
Definition ll1_parser.hpp:194
std::unordered_map< std::string, std::unordered_set< std::string > > first_sets_
FIRST sets for each non-terminal in the grammar.
Definition ll1_parser.hpp:198
std::unordered_map< std::string, std::unordered_set< std::string > > follow_sets_
FOLLOW sets for each non-terminal in the grammar.
Definition ll1_parser.hpp:202
void First(std::span< const std::string > rule, std::unordered_set< std::string > &result)
Calculates the FIRST set for a given production rule in a grammar.
Definition ll1_parser.cpp:63
Represents a context-free grammar, including its rules, symbol table, and starting symbol.
Definition grammar.hpp:46