mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
LR0: Added ::dump method to display intermediate parsing table
This commit is contained in:
parent
26e0a472ac
commit
ad5f1e4fd7
2 changed files with 37 additions and 0 deletions
36
src/LR0.cpp
36
src/LR0.cpp
|
@ -132,3 +132,39 @@ std::string LR0::dump () const
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string LR0::dump (std::vector <std::vector <std::string>>& augmented, States& states) const
|
||||
{
|
||||
std::stringstream out;
|
||||
|
||||
for (unsigned int c = 0; c < states.size (); ++c)
|
||||
{
|
||||
out << " [" << c << "] ";
|
||||
|
||||
for (unsigned int i = 0; i < states[c].size (); ++i)
|
||||
{
|
||||
if (i)
|
||||
out << " ";
|
||||
|
||||
out << augmented[states[c][i]._rule][0]
|
||||
<< " "
|
||||
<< augmented[states[c][i]._rule][1];
|
||||
|
||||
for (unsigned int t = 2; t < augmented[states[c][i]._rule].size (); t++)
|
||||
{
|
||||
if ((int)t - 2 == states[c][i]._cursor)
|
||||
out << " .";
|
||||
|
||||
out << " " << augmented[states[c][i]._rule][t];
|
||||
}
|
||||
|
||||
out << "\n";
|
||||
}
|
||||
|
||||
out << "\n";
|
||||
}
|
||||
|
||||
out << "\n";
|
||||
return out.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -60,6 +60,7 @@ protected:
|
|||
|
||||
private:
|
||||
bool expandNonTerminals (std::vector <std::vector <std::string>>&, std::vector <std::pair <int, int>>&);
|
||||
std::string dump (std::vector <std::vector <std::string>>&, States&) const;
|
||||
|
||||
private:
|
||||
// state column result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue