mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
LR0: Implemented Item::dump
This commit is contained in:
parent
66504d5dfc
commit
ef087a7b35
2 changed files with 23 additions and 0 deletions
22
src/LR0.cpp
22
src/LR0.cpp
|
@ -175,3 +175,25 @@ bool LR0::Item::advance ()
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string LR0::Item::dump () const
|
||||
{
|
||||
std::stringstream out;
|
||||
|
||||
for (unsigned int i = 0; i < _rule.size (); ++i)
|
||||
{
|
||||
if (i)
|
||||
out << " ";
|
||||
|
||||
if (i == _cursor)
|
||||
out << "● ";
|
||||
|
||||
out << _rule[i];
|
||||
}
|
||||
|
||||
if (_cursor >= _rule.size ())
|
||||
out << " ●";
|
||||
|
||||
return out.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -45,6 +45,7 @@ public:
|
|||
public:
|
||||
Item (const std::vector <std::string>&);
|
||||
bool advance ();
|
||||
std::string dump () const;
|
||||
|
||||
private:
|
||||
std::vector <std::string> _rule;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue