mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
LR0: Color-coded the parser table
This commit is contained in:
parent
ab2eb68d7c
commit
1f1cd34134
1 changed files with 13 additions and 2 deletions
15
src/LR0.cpp
15
src/LR0.cpp
|
@ -242,10 +242,21 @@ std::string LR0::dump () const
|
|||
t.set (row, col++, state);
|
||||
|
||||
for (auto& terminal : _terminals)
|
||||
t.set (row, col++, _actions[state].at (terminal));
|
||||
{
|
||||
auto data = _actions[state].at (terminal);
|
||||
Color color (data[0] == 'r' ? "white on red" :
|
||||
data[0] == 's' ? "black on yellow" :
|
||||
data[0] == 'a' ? "white on green" :
|
||||
"");
|
||||
t.set (row, col++, data, color);
|
||||
}
|
||||
|
||||
for (auto& rule : _rules)
|
||||
t.set (row, col++, _goto[state].at (rule));
|
||||
{
|
||||
auto data = _goto[state].at (rule);
|
||||
Color color (data != "" ? "black on yellow" : "");
|
||||
t.set (row, col++, data, color);
|
||||
}
|
||||
}
|
||||
|
||||
out << t.render ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue