Added in structure for tree transformations.
This commit is contained in:
17
src/ASTData.cpp
Normal file
17
src/ASTData.cpp
Normal 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
13
src/ASTTransformation.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include "ASTTransformation.h"
|
||||
|
||||
ASTTransformation::ASTTransformation() {
|
||||
//
|
||||
}
|
||||
|
||||
ASTTransformation::~ASTTransformation() {
|
||||
//
|
||||
}
|
||||
|
||||
virtual NodeTree<Symbol*>* ASTTransformation::transform(NodeTree<ASTData>* from) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,8 @@ std::string ParseAction::actionToString(ActionType action) {
|
||||
case REJECT:
|
||||
return "reject";
|
||||
break;
|
||||
default:
|
||||
return "INVALID PARSE ACTION";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user