Fix what looks like an off-by-one error in RegEx::longestMatch()'s lastMatch calculation, and a corresponding +1 in code using longestMatch, and add a test.

This commit is contained in:
Jason Orendorff
2013-10-26 23:29:23 -07:00
parent 7859b29725
commit d2d38e2516
4 changed files with 17 additions and 5 deletions

View File

@@ -40,8 +40,8 @@ Symbol Lexer::next() {
}
}
if (longestRegEx != NULL) {
std::string eatenString = input.substr(currentPosition, longestMatch+1);
currentPosition += longestMatch + 1;
std::string eatenString = input.substr(currentPosition, longestMatch);
currentPosition += longestMatch;
//std::cout << "Current at is \"" << input.substr(currentPosition,input.length()-1) << "\" currentPos is " << currentPosition <<std::endl;
return Symbol(longestRegEx->getPattern(), true, eatenString);
} else {