Fixed a lot of bugs. Actually gets through the entire experimental grammer. (A largeish experimental grammer for Kraken written to continue testing and to really start language development.

This commit is contained in:
Nathan Braswell
2013-07-10 23:50:53 -04:00
parent 1c85e3693e
commit f84657f1ed
10 changed files with 151 additions and 60 deletions

View File

@@ -67,7 +67,37 @@ std::string StringReader::getTokens(std::vector<std::string> stop_chars, bool tr
}
if (rd_string[str_pos] == '\"') {
found_pos = rd_string.find("\"", str_pos+1);
//See if we have an even or odd number of backslashes (that is, this quote is not or is escaped)
int numBackslashes = 0;
int countBack = 1;
while (str_pos-countBack >= 0 && rd_string[str_pos-countBack] == '\\') {
numBackslashes++;
countBack++;
}
//If the quote is not escaped
if (numBackslashes % 2 == 0) {
//Find the next quote
found_pos = rd_string.find("\"", str_pos+1);
//Check to see if the quote is escaped
numBackslashes = 0;
countBack = 1;
while (found_pos-countBack >= 0 && rd_string[found_pos-countBack] == '\\') {
numBackslashes++;
countBack++;
}
//While the quote is escaped
while (numBackslashes % 2 == 1) {
//find the next quote
found_pos = rd_string.find("\"", found_pos+1);
//Check to see if it's escaped
numBackslashes = 0;
countBack = 1;
while (found_pos-countBack >= 0 && rd_string[found_pos-countBack] == '\\') {
numBackslashes++;
countBack++;
}
}
}
}
if (found_pos == str_pos) //We are at the endline