Added ability to add commits the Kraken grammer file. Started work on class traits and else statements.

This commit is contained in:
Nathan Braswell
2014-07-06 23:42:25 -07:00
parent 91a68ac2b1
commit 46b9fc8b7f
8 changed files with 57 additions and 14 deletions

View File

@@ -503,8 +503,10 @@ NodeTree<ASTData>* ASTTransformation::transform(NodeTree<Symbol>* from, NodeTree
}
// //Set the value of this function call
if (newNode->getDataRef()->valueType == NULL && rhs->getDataRef()->valueType)
newNode->getDataRef()->valueType = rhs->getDataRef()->valueType;
if (newNode->getDataRef()->valueType == NULL && rhs->getDataRef()->valueType) {
std::cout << "The value type from doFunction was null! (for " << functionCallName << ")" << std::endl;
newNode->getDataRef()->valueType = rhs->getDataRef()->valueType;
}
//else
// newNode->getDataRef()->valueType = NULL;
std::cout << "function call to " << functionCallName << " - " << newNode->getName() << " is now " << newNode->getDataRef()->valueType << std::endl;
@@ -754,7 +756,7 @@ NodeTree<ASTData>* ASTTransformation::doFunction(NodeTree<ASTData>* scope, std::
else
newType->increaseIndirection();
newNode->getDataRef()->valueType = newType, std::cout << "Operator " + lookup << " is altering indirection "<< std::endl;
newNode->getDataRef()->valueType = newType, std::cout << "Operator " + lookup << " is altering indirection from " << oldTypes[0].toString() << " to " << newType->toString() << std::endl;
} else {
newNode->getDataRef()->valueType = function->getDataRef()->valueType, std::cout << "Some other ||" << lookup << "||" << std::endl;
}

View File

@@ -36,7 +36,7 @@ Importer::Importer(Parser* parserIn, std::vector<std::string> includePaths) {
collapseSymbols.push_back(Symbol("if_comp_pred", false));
collapseSymbols.push_back(Symbol("declaration_block", false));
collapseSymbols.push_back(Symbol("type_list", false));
collapseSymbols.push_back(Symbol("identifier_list", false));
collapseSymbols.push_back(Symbol("template_param_list", false));
}
Importer::~Importer() {

View File

@@ -32,10 +32,22 @@ Symbol Parser::getOrAddSymbol(std::string symbolString, bool isTerminal) {
void Parser::loadGrammer(std::string grammerInputString) {
reader.setString(grammerInputString);
std::string currToken = reader.word();
std::string currToken = reader.word(false); //Don't truncate so we can find the newline correctly (needed for comments)
while(currToken != "") {
//Load the left of the rule
//First, if this starts with a '#', skip this
if (currToken.front() == '#') {
//If this line is more than one token long, eat it
std::cout << "Ate: " << currToken << std::endl;
if (currToken.back() != '\n')
std::cout << "Eating " << reader.line() << " b/c grammer comment" << std::endl;
currToken = reader.word(false);
continue;
}
if (currToken.back() == '\n' || currToken.back() == ' ' || currToken.back() == '\t')
currToken.erase(currToken.size()-1);
//Load the left of the rule
ParseRule* currentRule = new ParseRule();
Symbol leftSide = getOrAddSymbol(currToken, false); //Left handle is never a terminal
currentRule->setLeftHandle(leftSide);
@@ -76,7 +88,7 @@ void Parser::loadGrammer(std::string grammerInputString) {
loadedGrammer.push_back(currentRule);
//Get next token
currToken = reader.word();
currToken = reader.word(false);
}
//std::cout << "Parsed!\n";