From eac94e99bf60cd94a51ff0c9bf491a84ea964c4a Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 5 Jan 2016 02:21:08 -0500 Subject: [PATCH] LR0: Now copies lists of grammar rules and terminals --- src/LR0.cpp | 14 +++++++++++++- src/LR0.h | 4 +++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/LR0.cpp b/src/LR0.cpp index 3d0d0e96..0aaf8109 100644 --- a/src/LR0.cpp +++ b/src/LR0.cpp @@ -42,8 +42,10 @@ LR0::LR0 () // - Recursively create and expand all the other states void LR0::initialize (const Grammar& grammar) { - // Obtain the augmented grammar. + // Save important grammar information. _augmented = grammar.augmented (); + _rules = grammar.rules (); + _terminals = grammar.terminals (); if (_debug) { @@ -57,6 +59,16 @@ void LR0::initialize (const Grammar& grammar) std::cout << "\n"; } + std::cout << "\n"; + std::cout << "Rules\n"; + for (auto& r : _rules) + std::cout << " " << r << "\n"; + + std::cout << "\n"; + std::cout << "Terminals\n"; + for (auto& t : _terminals) + std::cout << " " << t << "\n"; + std::cout << "\n"; } diff --git a/src/LR0.h b/src/LR0.h index 402bf968..74523637 100644 --- a/src/LR0.h +++ b/src/LR0.h @@ -75,8 +75,10 @@ private: void createParseTable (States&); private: - // Copy of the augmented grammar. + // Copy of the grammar details. std::vector > _augmented; + std::vector _rules; + std::vector _terminals; // state column result // | | |