Added in structure for tree transformations.

This commit is contained in:
Nathan Braswell
2013-09-26 15:16:58 -04:00
parent 7cfdc1e66b
commit 0110672f50
11 changed files with 192 additions and 6 deletions

17
src/ASTData.cpp Normal file
View File

@@ -0,0 +1,17 @@
#include "ASTData.h"
ASTData::ASTData(ASTType type, ValueType valueType) {
this->type = type;
this->valueType = valueType;
this->symbol = NULL;
}
ASTData::ASTData(ASTType type, Symbol* symbol, ValueType valueType) {
this->type = type;
this->valueType = valueType;
this->symbol = symbol;
}
ASTData::~ASTData() {
}

13
src/ASTTransformation.cpp Normal file
View File

@@ -0,0 +1,13 @@
#include "ASTTransformation.h"
ASTTransformation::ASTTransformation() {
//
}
ASTTransformation::~ASTTransformation() {
//
}
virtual NodeTree<Symbol*>* ASTTransformation::transform(NodeTree<ASTData>* from) {
return NULL;
}

View File

@@ -65,6 +65,9 @@ NodeTree<Symbol*>* LALRParser::parseInput(std::string inputString) {
std::cout << "REJECTED Symbol was " << token->toString() << std::endl;
return(NULL);
break;
default:
std::cout << "INVALID PARSE ACTION!" << std::endl;
break;
}
}
}

View File

@@ -48,6 +48,8 @@ std::string ParseAction::actionToString(ActionType action) {
case REJECT:
return "reject";
break;
default:
return "INVALID PARSE ACTION";
}
}

View File

@@ -270,7 +270,7 @@ bool RNGLRParser::belongsToFamily(NodeTree<Symbol*>* node, std::vector<NodeTree<
bool containsOne = false;
for (std::vector<NodeTree<Symbol*>*>::size_type j = 0; j < children.size(); j++) {
//Not sure where null comes from. For right now, just check to be sure we don't segfault
if ((*nodes)[i] == children[j] || (*nodes)[i] != NULL && children[j] != NULL && (*(*nodes)[i]) == *(children[j])) {
if ((*nodes)[i] == children[j] || ( (*nodes)[i] != NULL && children[j] != NULL && (*(*nodes)[i]) == *(children[j]) )) {
containsOne = true;
break;
}