Fix lexer for empty input.
This commit is contained in:
parent
077fae50af
commit
3b482c1c73
3 changed files with 17 additions and 2 deletions
|
|
@ -148,7 +148,9 @@ bool SqlLexer::nextBasicToken(int &startpos, int &length, BasicTokenType &tokent
|
||||||
// m_state = LexerState::InBlockComment;
|
// m_state = LexerState::InBlockComment;
|
||||||
// }
|
// }
|
||||||
else if (c == QChar::Null) {
|
else if (c == QChar::Null) {
|
||||||
break;
|
length = 0;
|
||||||
|
tokentype = BasicTokenType::End;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else if (c == '$') {
|
else if (c == '$') {
|
||||||
return parseDollarQuote(startpos, length, tokentype, out);
|
return parseDollarQuote(startpos, length, tokentype, out);
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ public:
|
||||||
SqlToken nextBasicToken()
|
SqlToken nextBasicToken()
|
||||||
{
|
{
|
||||||
SqlToken token;
|
SqlToken token;
|
||||||
token.ok = !nextBasicToken(token.startPos, token.length, token.tokenType, token.out);
|
token.ok = nextBasicToken(token.startPos, token.length, token.tokenType, token.out);
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,19 @@
|
||||||
|
|
||||||
using namespace testing;
|
using namespace testing;
|
||||||
|
|
||||||
|
TEST(SqlLexer, emptyInput)
|
||||||
|
{
|
||||||
|
QString input;
|
||||||
|
SqlLexer lexer(input, LexerState::Null);
|
||||||
|
|
||||||
|
int startpos, length;
|
||||||
|
BasicTokenType tokentype;
|
||||||
|
QString out;
|
||||||
|
lexer.nextBasicToken(startpos, length, tokentype, out);
|
||||||
|
|
||||||
|
ASSERT_THAT(startpos, Eq(0));
|
||||||
|
ASSERT_THAT(tokentype, Eq(BasicTokenType::End));
|
||||||
|
}
|
||||||
|
|
||||||
TEST(SqlLexer, lexer)
|
TEST(SqlLexer, lexer)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue