LR0: Now copies lists of grammar rules and terminals

This commit is contained in:
Paul Beckingham 2016-01-05 02:21:08 -05:00
parent 04ce6a8b91
commit eac94e99bf
2 changed files with 16 additions and 2 deletions

View file

@ -42,8 +42,10 @@ LR0::LR0 ()
// - Recursively create and expand all the other states
void LR0::initialize (const Grammar& grammar)
{
// Obtain the augmented grammar.
// Save important grammar information.
_augmented = grammar.augmented ();
_rules = grammar.rules ();
_terminals = grammar.terminals ();
if (_debug)
{
@ -57,6 +59,16 @@ void LR0::initialize (const Grammar& grammar)
std::cout << "\n";
}
std::cout << "\n";
std::cout << "Rules\n";
for (auto& r : _rules)
std::cout << " " << r << "\n";
std::cout << "\n";
std::cout << "Terminals\n";
for (auto& t : _terminals)
std::cout << " " << t << "\n";
std::cout << "\n";
}

View file

@ -75,8 +75,10 @@ private:
void createParseTable (States&);
private:
// Copy of the augmented grammar.
// Copy of the grammar details.
std::vector <std::vector <std::string>> _augmented;
std::vector <std::string> _rules;
std::vector <std::string> _terminals;
// state column result
// | | |