Skip to content

Commit

Permalink
parser: database.ReservedKeyword as identifier & clean up (pingcap#2027)
Browse files Browse the repository at this point in the history
1. fix a bug test.desc can't be used as identifier, which is valid in mysql
2. introduce ReservedKeyword in parser.y and clean up
3. fix mysql client "use `select`;" can't work
4. refine lexer's special comment mode pos line/offset
  • Loading branch information
tiancaiamao authored Nov 19, 2016
1 parent 4d988fb commit 2f47f24
Show file tree
Hide file tree
Showing 4 changed files with 364 additions and 336 deletions.
4 changes: 3 additions & 1 deletion parser/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (s *Scanner) Lex(v *yySymType) int {
return toHex(s, v, lit)
case bitLit:
return toBit(s, v, lit)
case userVar, sysVar, database, currentUser, replace, cast, sysDate, currentTs, currentTime, currentDate, curDate, utcDate, extract, repeat, secondMicrosecond, minuteMicrosecond, minuteSecond, hourMicrosecond, hourMinute, hourSecond, dayMicrosecond, dayMinute, daySecond, dayHour, yearMonth, ifKwd, left, convert:
case userVar, sysVar, cast, sysDate, curDate, extract:
v.item = lit
return tok
case null:
Expand Down Expand Up @@ -137,6 +137,8 @@ func (s *Scanner) scan() (tok int, pos Pos, lit string) {
tok, pos, lit = specialComment.scan()
if tok != 0 {
// return the specialComment scan result as the result
pos.Line += s.r.p.Line
pos.Offset += s.r.p.Col
return
}
// leave specialComment scan mode after all stream consumed.
Expand Down
Loading

0 comments on commit 2f47f24

Please sign in to comment.