6#include <unordered_map>
7#include <unordered_set>
27 using ll1_table = std::unordered_map<
28 std::string, std::unordered_map<std::string, std::vector<production>>>;
88 void First(std::span<const std::string> rule,
89 std::unordered_set<std::string>& result);
146 std::unordered_set<std::string>
Follow(
const std::string& arg);
170 std::unordered_set<std::string>
172 const std::vector<std::string>& consequent);
182 std::unordered_map<std::string, std::unordered_set<std::string>>
186 std::unordered_map<std::string, std::unordered_set<std::string>>
void ComputeFollowSets()
Computes the FOLLOW sets for all non-terminal symbols in the grammar.
Definition ll1_parser.cpp:115
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:168
ll1_table ll1_t_
The LL(1) parsing table, mapping non-terminals and terminals to productions.
Definition ll1_parser.hpp:176
void ComputeFirstSets()
Computes the FIRST sets for all non-terminal symbols in the grammar.
Definition ll1_parser.cpp:84
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:176
bool CreateLL1Table()
Creates the LL(1) parsing table for the grammar.
Definition ll1_parser.cpp:18
Grammar gr_
Grammar object associated with this parser.
Definition ll1_parser.hpp:179
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:183
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:187
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:45
Represents a context-free grammar, including its rules, symbol table, and starting symbol.
Definition grammar.hpp:27