[parser] parse until eof (#367)

This commit is contained in:
Tanner
2019-07-01 20:30:46 +08:00
committed by Ti Chi Robot
parent 84d13adf9e
commit d2debf2fdf
2 changed files with 15 additions and 13 deletions

View File

@ -211,9 +211,11 @@ func (s *Scanner) Lex(v *yySymType) int {
case quotedIdentifier:
tok = identifier
}
if tok == unicode.ReplacementChar && s.r.eof() {
return 0
if tok == unicode.ReplacementChar {
return invalid
}
return tok
}

View File

@ -356,18 +356,18 @@ func (s *testLexerSuite) TestSQLModeANSIQuotes(c *C) {
func (s *testLexerSuite) TestIllegal(c *C) {
table := []testCaseItem{
{"'", 0},
{"'fu", 0},
{"'\\n", 0},
{"'\\", 0},
{"'", invalid},
{"'fu", invalid},
{"'\\n", invalid},
{"'\\", invalid},
{fmt.Sprintf("%c", 0), invalid},
{"`", 0},
{`"`, 0},
{"@`", 0},
{"@'", 0},
{`@"`, 0},
{"@@`", 0},
{"@@global.`", 0},
{"`", invalid},
{`"`, invalid},
{"@`", invalid},
{"@'", invalid},
{`@"`, invalid},
{"@@`", invalid},
{"@@global.`", invalid},
}
runTest(c, table)
}