From 0a9e1f729976785fb4d7a8f1325e38c26fee2d22 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 26 Dec 2015 14:08:13 -0500 Subject: [PATCH] Grammar: MAde ::dump output more compact, because this is going to get large --- src/Grammar.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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";