mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
LR0: Now copies lists of grammar rules and terminals
This commit is contained in:
parent
04ce6a8b91
commit
eac94e99bf
2 changed files with 16 additions and 2 deletions
14
src/LR0.cpp
14
src/LR0.cpp
|
@ -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";
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
// | | |
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue