Fix the non-working Lexer test.

This commit is contained in:
Nathan Braswell
2013-11-03 20:36:18 -05:00
parent 77f2b0a3e5
commit d5512ec78e

View File

@@ -45,8 +45,8 @@ Symbol Lexer::next() {
//std::cout << "Current at is \"" << input.substr(currentPosition) << "\" currentPos is " << currentPosition <<std::endl; //std::cout << "Current at is \"" << input.substr(currentPosition) << "\" currentPos is " << currentPosition <<std::endl;
return Symbol(longestRegEx->getPattern(), true, eatenString); return Symbol(longestRegEx->getPattern(), true, eatenString);
} else { } else {
std::cout << "Found no applicable regex" << std::endl; // std::cout << "Found no applicable regex" << std::endl;
std::cout << "Remaining is ||" << input.substr(currentPosition) << "||" << std::endl; // std::cout << "Remaining is ||" << input.substr(currentPosition) << "||" << std::endl;
return Symbol("$INVALID$", true); return Symbol("$INVALID$", true);
} }
} }
@@ -89,7 +89,7 @@ void Lexer::test() {
lex.setInput("blah"); lex.setInput("blah");
s = lex.next(); s = lex.next();
assert(s.getName() == "a|b" && s.getValue() == "b"); assert(s.getName() == "a|b" && s.getValue() == "b");
assert(lex.next() == Symbol()); assert(lex.next() == Symbol("$INVALID$", true));
} }
// Lexer can consume all the input at once. // Lexer can consume all the input at once.