diff --git a/include/GraphStructuredStack.h b/include/GraphStructuredStack.h index e5bac15..7f10039 100644 --- a/include/GraphStructuredStack.h +++ b/include/GraphStructuredStack.h @@ -1,7 +1,9 @@ #include #include #include +#include #include "NodeTree.h" +#include "Symbol.h" #include "util.h" #ifndef GRAPH_STRUCTURED_STACK @@ -27,7 +29,7 @@ class GraphStructuredStack { std::string toString(); private: std::vector*>*> gss; - std::map*, NodeTree*>, NodeTree edges; + std::map< std::pair< NodeTree*, NodeTree* >, NodeTree* > edges; }; #endif diff --git a/include/NodeTree.h b/include/NodeTree.h index 3993269..dab3bca 100644 --- a/include/NodeTree.h +++ b/include/NodeTree.h @@ -115,7 +115,7 @@ void NodeTree::addChild(NodeTree* child) { template void NodeTree::addChildren(std::vector*>* children) { - for (std::vector*>::size_type i = 0; i < children->size(); i++) + for (typename std::vector*>::size_type i = 0; i < children->size(); i++) addChild((*children)[i]); } @@ -145,7 +145,7 @@ void NodeTree::removeChild(NodeTree* child) { template void NodeTree::clearChildren() { - for (std::vector::size_type i = 0; i < children.size(); i++) + for (typename std::vector::size_type i = 0; i < children.size(); i++) children[i] = NULL; children.clear(); } diff --git a/include/RNGLRParser.h b/include/RNGLRParser.h index 2bf0b1e..ccf3d34 100644 --- a/include/RNGLRParser.h +++ b/include/RNGLRParser.h @@ -3,9 +3,11 @@ #include #include +#include #include #include #include "Parser.h" +#include "Symbol.h" #include "GraphStructuredStack.h" class RNGLRParser: public Parser { @@ -45,7 +47,7 @@ class RNGLRParser: public Parser { int nullablePartsIndex; NodeTree* label; } ; - std::queue toReduce; + std::queue toReduce; //Node coming from, state going to std::queue< std::pair*, int> > toShift; std::vector*, int> > SPPFStepNodes; diff --git a/src/GraphStructuredStack.cpp b/src/GraphStructuredStack.cpp index 4cbd42d..a125dcc 100644 --- a/src/GraphStructuredStack.cpp +++ b/src/GraphStructuredStack.cpp @@ -34,10 +34,10 @@ NodeTree* GraphStructuredStack::inFrontier(int frontier, int state) { int GraphStructuredStack::getContainingFrontier(NodeTree* node) { for (std::vector*>*>::size_type i = 0; i < gss.size(); i++) { - if (frontierIsEmpty(frontier)) + if (frontierIsEmpty(i)) continue; for (std::vector*>::size_type j = 0; j < gss[i]->size(); j++) { - if (*((*(gss[i]))[j]) == *node) + if ((*(gss[i]))[j] == node) return i; } } @@ -96,9 +96,9 @@ void GraphStructuredStack::recursivePathFind(NodeTree* start, int length, s paths->push_back(currentPath); return; } - std::vector*>* children = start->getChildren(); - for (std::vector*>::size_type i = 0; i < children->size(); i++) { - recursivePathFind((*children)[i], length-1, currentPath, paths); + std::vector*> children = start->getChildren(); + for (std::vector*>::size_type i = 0; i < children.size(); i++) { + recursivePathFind(children[i], length-1, currentPath, paths); } } @@ -108,10 +108,10 @@ bool GraphStructuredStack::hasEdge(NodeTree* start, NodeTree* end) { } NodeTree* GraphStructuredStack::getEdge(NodeTree* start, NodeTree* end) { - return edges.get(std::make_pair(start, end), NULL); + return edges[std::make_pair(start, end)]; } -void GraphStructuredStack::addEdge(NodeTree* start, NodeTree* end, NodeTree edge) { +void GraphStructuredStack::addEdge(NodeTree* start, NodeTree* end, NodeTree* edge) { start->addChild(end); end->addParent(start); edges[std::make_pair(start, end)] = edge;