From 6d7b38a03ba37dcc2f0617c3898401346228822f Mon Sep 17 00:00:00 2001 From: Nathan Braswell Date: Sun, 28 Jul 2013 19:45:08 -0400 Subject: [PATCH] More work towards RNGLR. First, NodeTree is now a template. Second, I've started writing the actual GLR parser and GSS and other things, but am still in the first write process. --- CMakeLists.txt | 2 +- include/GraphStructuredStack.h | 23 ++++++ include/NodeTree.h | 138 +++++++++++++++++++++++++++++++-- include/Parser.h | 4 +- include/RNGLRParser.h | 17 ++++ include/Symbol.h | 10 +-- main.cpp | 3 +- src/GraphStructuredStack.cpp | 41 ++++++++++ src/NodeTree.cpp | 106 ------------------------- src/Parser.cpp | 12 +-- src/RNGLRParser.cpp | 116 +++++++++++++++++++++++++++ src/RegEx.cpp | 26 +++---- src/Symbol.cpp | 6 +- src/Table.cpp | 2 +- 14 files changed, 360 insertions(+), 146 deletions(-) create mode 100644 include/GraphStructuredStack.h create mode 100644 include/RNGLRParser.h create mode 100644 src/GraphStructuredStack.cpp delete mode 100644 src/NodeTree.cpp create mode 100644 src/RNGLRParser.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index bb81182..87dff70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(Kraken) set( MY_INCLUDES ${PROJECT_SOURCE_DIR}/include) -set( MY_SOURCES main.cpp src/Parser.cpp src/ParseAction.cpp src/ParseRule.cpp src/Symbol.cpp src/StringReader.cpp src/NodeTree.cpp src/State.cpp src/util.cpp src/Lexer.cpp src/RegEx.cpp src/RegExState.cpp src/Table.cpp ) +set( MY_SOURCES main.cpp src/Parser.cpp src/ParseAction.cpp src/ParseRule.cpp src/Symbol.cpp src/StringReader.cpp src/State.cpp src/util.cpp src/Lexer.cpp src/RegEx.cpp src/RegExState.cpp src/Table.cpp ) include_directories( ${MY_INCLUDES} ) diff --git a/include/GraphStructuredStack.h b/include/GraphStructuredStack.h new file mode 100644 index 0000000..38ad704 --- /dev/null +++ b/include/GraphStructuredStack.h @@ -0,0 +1,23 @@ +#include +#include +#include "GSSNode.h" + +#ifndef GRAPH_STRUCTURED_STACK +#define GRAPH_STRUCTURED_STACK + +class GraphStructuredStack { + public: + GraphStructuredStack(); + ~GraphStructuredStack(); + GSSNode* newNode(int stateNum); + void addToFrontier(int frontier, GSSNode* node); + bool inFrontier(int frontier, int state); + bool frontierIsEmpty(int frontier); + bool frontierHasAccState(int frontier); + std::vector* getReachable(GSSNode* start, int lenght); + bool hasEdge(GSSNode* start, GSSNode* end); + void addEdge(GSSNode* start, GSSNode* end); + private: + std::vector*> gss; + // +}; diff --git a/include/NodeTree.h b/include/NodeTree.h index edeec53..fc713f0 100644 --- a/include/NodeTree.h +++ b/include/NodeTree.h @@ -6,19 +6,20 @@ #endif #include -#include +//#include #include #include #include //Circular references -class Symbol; +//class Symbol; +template class NodeTree { public: NodeTree(); - NodeTree(std::string name, Symbol* inSymbol); + NodeTree(std::string name, T inData); ~NodeTree(); void setParent(NodeTree* parent); @@ -34,8 +35,8 @@ class NodeTree { std::string getName(); void setName(std::string); - Symbol* getSymbol(); - void setSymbol(Symbol* symbol); + T getData(); + void setData(T data); int size(); std::string DOTGraphString(); @@ -44,7 +45,7 @@ class NodeTree { std::string DOTGraphStringHelper(); std::string getDOTName(); std::string name; - Symbol* symbol; + T data; NodeTree* parent; std::vector children; @@ -52,4 +53,129 @@ class NodeTree { int id; }; +template + +int NodeTree::idCounter; + +template +NodeTree::NodeTree() { + parent = NULL; + name = "UnnamedNode"; + data = NULL; + + id = idCounter++; +} + +template +NodeTree::NodeTree(std::string name, T inData) { + parent = NULL; + data = NULL; + this->name = name; + this->data = inData; + id = idCounter++; +} + +template +NodeTree::~NodeTree() { + children.clear(); +} + +template +void NodeTree::setParent(NodeTree* parent) { + if (this->parent != NULL) { + this->parent->removeChild(this); + } + this->parent = parent; +} + +template +NodeTree* NodeTree::getParent() { + return parent; +} + +template +void NodeTree::addChild(NodeTree* child) { + if (findChild(child) == -1) + children.push_back(child); +} + +template +int NodeTree::findChild(NodeTree* child) { + for (int i = 0; i < children.size(); i++) { + if (children[i] == child) { + return i; + } + } + return -1; +} + +template +void NodeTree::removeChild(int index) { + children[index] = NULL; + children.erase(children.begin()+index); +} + +template +void NodeTree::removeChild(NodeTree* child) { + int index = findChild(child); + if (index != 0) { + removeChild(index); + } +} + +template +int NodeTree::size() { + int count = 0; + for (int i = 0; i < children.size(); i++) { + count += children[i]->size(); + } + return 1+count; +} + +template +NodeTree* NodeTree::get(int index) { + return children[index]; +} + +template +std::string NodeTree::getName() { + return name; +} + +template +void NodeTree::setName(std::string name) { + this->name = name; +} + +template +T NodeTree::getData() { + return data; +} + +template +void NodeTree::setData(T data) { + this->data = data; +} + +template +std::string NodeTree::DOTGraphString() { + return( "digraph Kraken { \n" + DOTGraphStringHelper() + "}"); +} + +template +std::string NodeTree::DOTGraphStringHelper() { + std::string ourDOTRelation = ""; + for (int i = 0; i < children.size(); i++) { + ourDOTRelation += getDOTName() + " -> " + children[i]->getDOTName() + ";\n" + children[i]->DOTGraphStringHelper(); + } + return(ourDOTRelation); +} + +template +std::string NodeTree::getDOTName() { + if (data != NULL) + return "\"" + name + "-" + data->toString() + "_" + intToString(id) + "\""; //Note that terminals already have a quote in the front of their name, so we don't need to add one + return "\"" + name + "_" + intToString(id) + "\""; +} + #endif \ No newline at end of file diff --git a/include/Parser.h b/include/Parser.h index 1ef1000..f23f542 100644 --- a/include/Parser.h +++ b/include/Parser.h @@ -33,7 +33,7 @@ class Parser { int stateNum(State* state); std::string stateSetToString(); - NodeTree* parseInput(std::string inputString); + NodeTree* parseInput(std::string inputString); std::string grammerToString(); std::string grammerToDOT(); @@ -60,7 +60,7 @@ class Parser { std::stack symbolStack; Symbol* getOrAddSymbol(std::string symbolString, bool isTerminal); - NodeTree* reduceTreeCombine(Symbol* newSymbol, std::vector &symbols); + NodeTree* reduceTreeCombine(Symbol* newSymbol, std::vector &symbols); }; #endif \ No newline at end of file diff --git a/include/RNGLRParser.h b/include/RNGLRParser.h new file mode 100644 index 0000000..750606f --- /dev/null +++ b/include/RNGLRParser.h @@ -0,0 +1,17 @@ + +#include + +class RNGLRParser { + public: + parseInput(std::string inputString); + reducer(int i); + shifter(int i); + private: + Lexer lexer; + std::vector input; + GraphStructuredStack gss; + //start node, lefthand side of the reduction, reduction length + std::queue, int > toReduce; + //Node coming from, state going to + std::queue< std::pair > toShift; +}; diff --git a/include/Symbol.h b/include/Symbol.h index 54e6a88..cc75b8b 100644 --- a/include/Symbol.h +++ b/include/Symbol.h @@ -11,26 +11,26 @@ #include //Circular references -class NodeTree; +//class NodeTree; class Symbol { public: Symbol(std::string name, bool isTerminal); Symbol(std::string name, bool isTerminal, std::string value); - Symbol(std::string name, bool isTerminal, NodeTree* tree); + Symbol(std::string name, bool isTerminal, NodeTree* tree); ~Symbol(); bool const operator==(const Symbol &other); std::string getName(); std::string toString(); Symbol* clone(); - void setSubTree(NodeTree* tree); - NodeTree* getSubTree(); + void setSubTree(NodeTree* tree); + NodeTree* getSubTree(); bool isTerminal(); private: std::string name; std::string value; bool terminal; - NodeTree* subTree; + NodeTree* subTree; }; #endif \ No newline at end of file diff --git a/main.cpp b/main.cpp index c5c26a8..2f92f76 100644 --- a/main.cpp +++ b/main.cpp @@ -1,4 +1,5 @@ #include "NodeTree.h" +#include "Symbol.h" #include "Lexer.h" #include "Parser.h" #include @@ -64,7 +65,7 @@ int main(int argc, char* argv[]) { std::cout << "\n\n\n\n\n\n\n\n\n\nParsing" << std::endl; std::cout << programInputFileString << std::endl; - NodeTree* parseTree = parser.parseInput(programInputFileString); + NodeTree* parseTree = parser.parseInput(programInputFileString); if (parseTree) { std::cout << parseTree->DOTGraphString() << std::endl; diff --git a/src/GraphStructuredStack.cpp b/src/GraphStructuredStack.cpp new file mode 100644 index 0000000..6a22c46 --- /dev/null +++ b/src/GraphStructuredStack.cpp @@ -0,0 +1,41 @@ +#include "GraphStructuredStack.h" + +GraphStructuredStack::GraphStructuredStack() { + // +} + +GraphStructuredStack::~GraphStructuredStack() { + // +} + +GSSNode* GraphStructuredStack::newNode(int stateNum) { + // +} + +void GraphStructuredStack::addToFrontier(int frontier, GSSNode* node) { + // +} + +bool GraphStructuredStack::inFrontier(int frontier, int state) { + // +} + +bool GraphStructuredStack::frontierIsEmpty(int frontier) { + // +} + +bool GraphStructuredStack::frontierHasAccState(int frontier) { + // +} + +std::vector* GraphStructuredStack::getReachable(GSSNode* start, int lenght) { + // +} + +bool GraphStructuredStack::hasEdge(GSSNode* start, GSSNode* end) { + // +} + +void GraphStructuredStack::addEdge(GSSNode* start, GSSNode* end) { + // +} \ No newline at end of file diff --git a/src/NodeTree.cpp b/src/NodeTree.cpp deleted file mode 100644 index bc54d8e..0000000 --- a/src/NodeTree.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include "NodeTree.h" - -int NodeTree::idCounter; - -NodeTree::NodeTree() { - parent = NULL; - name = "UnnamedNode"; - symbol = NULL; - - id = idCounter++; -} - -NodeTree::NodeTree(std::string name, Symbol* inSymbol) { - parent = NULL; - symbol = NULL; - this->name = name; - this->symbol = inSymbol; - id = idCounter++; -} - -NodeTree::~NodeTree() { - children.clear(); -} - -void NodeTree::setParent(NodeTree* parent) { - if (this->parent != NULL) { - this->parent->removeChild(this); - } - this->parent = parent; -} - -NodeTree* NodeTree::getParent() { - return parent; -} - -void NodeTree::addChild(NodeTree* child) { - if (findChild(child) == -1) - children.push_back(child); -} - -int NodeTree::findChild(NodeTree* child) { - for (int i = 0; i < children.size(); i++) { - if (children[i] == child) { - return i; - } - } - return -1; -} - -void NodeTree::removeChild(int index) { - children[index] = NULL; - children.erase(children.begin()+index); -} - -void NodeTree::removeChild(NodeTree* child) { - int index = findChild(child); - if (index != 0) { - removeChild(index); - } -} - -int NodeTree::size() { - int count = 0; - for (int i = 0; i < children.size(); i++) { - count += children[i]->size(); - } - return 1+count; -} - -NodeTree* NodeTree::get(int index) { - return children[index]; -} - -std::string NodeTree::getName() { - return name; -} - -void NodeTree::setName(std::string name) { - this->name = name; -} - -Symbol* NodeTree::getSymbol() { - return symbol; -} - -void NodeTree::setSymbol(Symbol* symbol) { - this->symbol = symbol; -} - -std::string NodeTree::DOTGraphString() { - return( "digraph Kraken { \n" + DOTGraphStringHelper() + "}"); -} - -std::string NodeTree::DOTGraphStringHelper() { - std::string ourDOTRelation = ""; - for (int i = 0; i < children.size(); i++) { - ourDOTRelation += getDOTName() + " -> " + children[i]->getDOTName() + ";\n" + children[i]->DOTGraphStringHelper(); - } - return(ourDOTRelation); -} - -std::string NodeTree::getDOTName() { - if (symbol != NULL) - return "\"" + name + "-" + symbol->toString() + "_" + intToString(id) + "\""; //Note that terminals already have a quote in the front of their name, so we don't need to add one - return "\"" + name + "_" + intToString(id) + "\""; -} \ No newline at end of file diff --git a/src/Parser.cpp b/src/Parser.cpp index 406e90f..6d3e60d 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -74,7 +74,6 @@ void Parser::loadGrammer(std::string grammerInputString) { } std::vector* Parser::firstSet(Symbol* token) { - //std::cout << "Simple first set for " << token->toString() << std::endl; std::vector avoidList; return firstSet(token, avoidList); } @@ -84,11 +83,8 @@ std::vector* Parser::firstSet(Symbol* token, std::vector &avoi for (std::vector::size_type i = 0; i < avoidList.size(); i++) if (*(avoidList[i]) == *token) { return new std::vector(); - //std::cout << "Avoiding firstSet for " << token->toString() << std::endl; } avoidList.push_back(token); - //std::cout << "Cpx first set for " << token->toString() << std::endl; - //std::cout << "Doing first set for " << token->toString() << std::endl; std::vector* first = new std::vector(); //First, if the symbol is a terminal, than it's first set is just itself. if (token->isTerminal()) { @@ -314,7 +310,7 @@ std::string Parser::tableToString() { return table.toString(); } -NodeTree* Parser::parseInput(std::string inputString) { +NodeTree* Parser::parseInput(std::string inputString) { lexer.setInput(inputString); Symbol* token = lexer.next(); ParseAction* action; @@ -370,11 +366,11 @@ NodeTree* Parser::parseInput(std::string inputString) { } } -NodeTree* Parser::reduceTreeCombine(Symbol* newSymbol, std::vector &symbols) { - NodeTree* newTree = new NodeTree(newSymbol->getName(), newSymbol); +NodeTree* Parser::reduceTreeCombine(Symbol* newSymbol, std::vector &symbols) { + NodeTree* newTree = new NodeTree(newSymbol->getName(), newSymbol); for (std::vector::size_type i = 0; i < symbols.size(); i++) { if (symbols[i]->isTerminal()) - newTree->addChild(new NodeTree(symbols[i]->getName(), symbols[i])); + newTree->addChild(new NodeTree(symbols[i]->getName(), symbols[i])); else newTree->addChild(symbols[i]->getSubTree()); } diff --git a/src/RNGLRParser.cpp b/src/RNGLRParser.cpp new file mode 100644 index 0000000..e4748ed --- /dev/null +++ b/src/RNGLRParser.cpp @@ -0,0 +1,116 @@ + +RNGLRParser::parseInput(std::string inputString) { + + //Check for no tokens + if (inputString == "") { + if (table.get(0,EOFSymbol)->action == ParseAction::REDUCE) + std::cout << "Accepted!" << std::endl; + else + std::cout << "Rejected, no input (with no accepting state)" << std::endl; + return; + } + + lexer.setInput(inputString); + //Now fully lex our input because this algorithm was designed in that manner and simplifies this first implementation. + //It could be converted to on-line later. + Symbol* currentToken = lexer.next(); + input.push_back(currentToken); + while (*currentToken != *EOFToken) { + currentToken = lexer.next(); + input.push_back(currentToken); + } + + //Frontier 0, new node with state 0 + GSSNode* v0 = gss.newNode(0); + gss.addToFrontier(0,v0); + + std::vector firstActions = table.get(0, input[0]); + for (std::vector::size_type i = 0; i < firstActions.size(); i++) { + if (firstActions[i]->action == ParseAction::SHIFT) + toShift.push_back(std::make_pair(v0,firstActions[i]->toState())); + else if (firstActions[i]->action == ParseAction::REDUCE && firstActions[i]->reduceRule->getRightSide()->size() == 0) { + toReduce.push_back(std::make_pair(std::make_pair(v0, firstActions[i]->reduceRule->getLeftSide()), 0)); + } + } + + for (int i = 0; i < input.size(); i++) { + if (gss.frontierIsEmpty(i)) + break; + while (toReduce.size() != 0) + reducer(i); + shifter(i); + } + if (gss.frontierHasAccSt(input.size()-1)) + std::cout << "Accepted!" << std::endl; + else + std::cout << "Rejected!" << std::endl; + return; +} + +RNGLRParser::reducer(int i) { + std::pair< std::pair, int > reduction = toReduce.front(); + int pathLength = reduction.second > 0 : reduction.second -1 ? 0; + std::vector* reachable = gss.getReachable(reduction.first.first, pathLength); + for (std::vector::size_type j = 0; j < reachable->size(); j++) { + GSSNode* currentReached = (*reachable)[j]; + int toState = table.getShift(currentReached->state(), reduction.first.second); + GSSNode* toStateNode = gss.inFrontier(i, toState); + if (toStateNode) { + if (!gss.hasEdge(toStateNode, currentReached)) { + gss.addEdge(toStateNode, currentReached); + if (reduction.second != 0) { + //Do all non null reductions + } + } + } else { + toStateNode = gss.newNode(toState); + gss.addToFrontier(i, toStateNode); + gss.addEdge(toStateNode, currentReached); + + std::vector actions = table.get(toState, input[i+1]); + for (std::vector::size_type k = 0; k < actions.size(); k++) { + //Shift + if (actions[k]->action == ParseAction::SHIFT) + nextShifts.push_back(std::make_pair(toStateNode, actions[k]->shiftState)); + else if (actions[k]->action == ParseAction::REDUCE && actions[k]->reduceRule()->size() != 0) + toReduce.push_back(std::make_pair(std::make_pair(currentReached, actions[k]->reduceRule->getLeftSide()), actions[k]->reduceRule->size())); + else (actions[k]->action == ParseAction::REDUCE && actions[k]->reduceRule()->size() == 0) + toReduce.push_back(std::make_pair(std::make_pair(toStateNode, actions[k]->reduceRule->getLeftSide()), actions[k]->reduceRule->size())); + } + + } + } +} + +RNGLRParser::shifter(int i) { + if (i != input.length()-1) { + std::queue nextShifts; + while (!toShift.empty()) { + std::pair shift = toShift.front(); + GSSNode* shiftTo = gss.inFrontier(i+1, shift.second); + if (shiftTo) { + gss.addEdge(shiftTo, shift.first); + std::vector actions = table.get(shift.second, input[i+2]); + for (std::vector::size_type j = 0; j < actions.size(); j++) { + if (actions[j]->action == ParseAction::REDUCE && actions[j]->reduceRule->size() != 0) + toReduce.push_back(std::make_pair(std::make_pair(shift.first, actions[j]->reduceRule->getLeftSide()), actions[j]->reduceRule->size())); + } + } else { + shiftTo = gss.newNode(shift.second); + gss.addToFrontier(i+1, shiftTo); + gss.addEdge(shiftTo, shift.first); + std::vector actions = table.get(shift.toState(), input[i+2]); + for (std::vector::size_type j = 0; j < actions.size(); j++) { + //Shift + if (actions[j]->action == ParseAction::SHIFT) + nextShifts.push_back(std::make_pair(shiftTo, actions[j]->shiftState)); + else if (actions[j]->action == ParseAction::REDUCE && actions[j]->reduceRule()->size() != 0) + toReduce.push_back(std::make_pair(std::make_pair(shift.first, actions[j]->reduceRule->getLeftSide()), actions[j]->reduceRule->size())); + else (actions[j]->action == ParseAction::REDUCE && actions[j]->reduceRule()->size() == 0) + toReduce.push_back(std::make_pair(std::make_pair(shiftTo, actions[j]->reduceRule->getLeftSide()), actions[j]->reduceRule->size())); + } + } + } + toShift = nextShifts; + } +} \ No newline at end of file diff --git a/src/RegEx.cpp b/src/RegEx.cpp index 92c6b84..40b740f 100644 --- a/src/RegEx.cpp +++ b/src/RegEx.cpp @@ -17,7 +17,7 @@ void RegEx::construct() { switch (pattern[i]) { case '*': { - std::cout << "Star at " << i << " in " << pattern << std::endl; + //std::cout << "Star at " << i << " in " << pattern << std::endl; // for (std::vector::size_type j = 0; j < currentStates.size(); j++) // for (std::vector::size_type k = 0; k < currentStates.size(); k++) // currentStates[j]->addNext(currentStates[k]); @@ -28,7 +28,7 @@ void RegEx::construct() { break; case '+': { - std::cout << "Plus at " << i << " in " << pattern << std::endl; + //std::cout << "Plus at " << i << " in " << pattern << std::endl; //OtherThingy //current->addNext(current); // for (std::vector::size_type j = 0; j < currentStates.size(); j++) @@ -39,14 +39,14 @@ void RegEx::construct() { break; case '?': { - std::cout << "Question at " << i << " in " << pattern << std::endl; + //std::cout << "Question at " << i << " in " << pattern << std::endl; //add all previous states to current states to enable skipping over the questioned item currentStates.insert(currentStates.end(), previousStates.begin(), previousStates.end()); } break; case '|': { - std::cout << "Alternation at " << i << " in " << pattern << std::endl; + //std::cout << "Alternation at " << i << " in " << pattern << std::endl; //alternation alternating = true; } @@ -54,7 +54,7 @@ void RegEx::construct() { break; case '(': { - std::cout << "Begin peren at " << i << " in " << pattern << std::endl; + //std::cout << "Begin peren at " << i << " in " << pattern << std::endl; //perentheses //Create a peren node with an inner empty node RegExState* next = new RegExState(new RegExState()); @@ -88,13 +88,13 @@ void RegEx::construct() { currentStates.clear(); currentStates.push_back(next->getInner()); } - std::cout << "Peren is " << next << " Inner is " << currentStates[0] << " = " << next->getInner() << std::endl; + //std::cout << "Peren is " << next << " Inner is " << currentStates[0] << " = " << next->getInner() << std::endl; } break; case ')': { - std::cout << "End peren at " << i << " in " << pattern << std::endl; + //std::cout << "End peren at " << i << " in " << pattern << std::endl; //perentheses //Pop off the states that will now be the previous states and the peren node which will now be the current node std::pair, std::vector > savedPair = perenStack.top(); @@ -113,19 +113,19 @@ void RegEx::construct() { case '\\': { i++; - std::cout << "Escape! Escaping: " << pattern[i] << std::endl; + //std::cout << "Escape! Escaping: " << pattern[i] << std::endl; //Ahh, it's escaping a special character, so fall through to the default. } default: { - std::cout << "Regular" << std::endl; + //std::cout << "Regular" << std::endl; //Ahh, it's regular RegExState* next = new RegExState(pattern[i]); //If we're alternating, add next as the next for each previous state, and add self to currentStates if (alternating) { for (std::vector::size_type j = 0; j < previousStates.size(); j++) { previousStates[j]->addNext(next); - std::cout << "Adding " << next << ", which is " << pattern[i] << " to " << previousStates[j] << std::endl; + //std::cout << "Adding " << next << ", which is " << pattern[i] << " to " << previousStates[j] << std::endl; } currentStates.push_back(next); alternating = false; @@ -134,7 +134,7 @@ void RegEx::construct() { //previous states, and add ourself as the new current state. for (std::vector::size_type j = 0; j < currentStates.size(); j++) { currentStates[j]->addNext(next); - std::cout << "Adding " << next << ", which is " << pattern[i] << " to " << currentStates[j] << std::endl; + //std::cout << "Adding " << next << ", which is " << pattern[i] << " to " << currentStates[j] << std::endl; } previousStates.clear(); previousStates = currentStates; @@ -150,7 +150,7 @@ void RegEx::construct() { } void RegEx::deperenthesize() { - std::cout << "About to de-perenthesize " << begin->toString() << std::endl; + //std::cout << "About to de-perenthesize " << begin->toString() << std::endl; //Now go through and expand the peren nodes to regular nodes std::vector processedStates; @@ -224,7 +224,7 @@ void RegEx::deperenthesize() { } } } - std::cout << "Finished de-perenthesization " << begin->toString() << std::endl; + //std::cout << "Finished de-perenthesization " << begin->toString() << std::endl; } RegEx::~RegEx() { diff --git a/src/Symbol.cpp b/src/Symbol.cpp index 29f759b..17a2f2b 100644 --- a/src/Symbol.cpp +++ b/src/Symbol.cpp @@ -14,7 +14,7 @@ Symbol::Symbol(std::string name, bool isTerminal, std::string value) { this->value = value; } -Symbol::Symbol(std::string name, bool isTerminal, NodeTree* tree) { +Symbol::Symbol(std::string name, bool isTerminal, NodeTree* tree) { this->name = name; this->terminal = isTerminal; this->subTree = tree; @@ -40,11 +40,11 @@ Symbol* Symbol::clone() { return new Symbol(name, terminal, subTree); } -void Symbol::setSubTree(NodeTree* tree) { +void Symbol::setSubTree(NodeTree* tree) { subTree = tree; } -NodeTree* Symbol::getSubTree() { +NodeTree* Symbol::getSubTree() { return subTree; } diff --git a/src/Table.cpp b/src/Table.cpp index a68a936..bf1a4b8 100644 --- a/src/Table.cpp +++ b/src/Table.cpp @@ -112,4 +112,4 @@ std::string Table::toString() { concat += "\n"; } return(concat); -} \ No newline at end of file +}