From b3eef3f95958a33003c88a7b64ed2ed02d425ec0 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Wed, 6 Jan 2016 10:31:14 -0500 Subject: [PATCH] LR0: The artificial terminal "$" is now autoamtically included --- src/LR0.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/LR0.cpp b/src/LR0.cpp index 09b81bb9..9874df0e 100644 --- a/src/LR0.cpp +++ b/src/LR0.cpp @@ -179,15 +179,17 @@ void LR0::closeState (States& states, const int state) const //////////////////////////////////////////////////////////////////////////////// void LR0::createParseTable (States& states) { + // Add artificial end-point. + _terminals.push_back ("$"); + // First size the tables: // - Create a row for every state // - Create a column for every terminal in the _actions table // - Create a column for every rule in the _goto table for (unsigned int state = 0; state < states.size (); ++state) { - // Create a column for every terminal, plus "$". + // Create a column for every terminal. _actions.push_back ({}); - _actions[state]["$"] = ""; for (auto& terminal : _terminals) _actions[state][terminal] = "";