diff --git a/src/Grammar.cpp b/src/Grammar.cpp index e44ab6c4..28fab208 100644 --- a/src/Grammar.cpp +++ b/src/Grammar.cpp @@ -189,17 +189,18 @@ std::vector > Grammar::augmented () const std::string Grammar::dump () const { std::stringstream out; + out << "Grammar\n"; for (auto& rule : _rules) { // Indicate the start Rule. - if (rule.first == _start) - out << "▶ "; - - out << rule.first << ":\n"; + out << " " << (rule.first == _start ? "▶" : " ") << " " << rule.first << ": "; + int count = 0; for (auto& production : rule.second) { - out << " "; + if (count) + out << "| "; + for (auto& token : production) { out << token._token; @@ -208,7 +209,7 @@ std::string Grammar::dump () const out << " "; } - out << "\n"; + ++count; } out << "\n";