File tree Expand file tree Collapse file tree 4 files changed +82
-1
lines changed
Expand file tree Collapse file tree 4 files changed +82
-1
lines changed Original file line number Diff line number Diff line change @@ -217,6 +217,10 @@ func (l *Lexer) consumeString() error {
217217
218218func (l * Lexer ) skipComments () {
219219 for ! l .isEOF () {
220+ l .skipSpace ()
221+ if ! l .peekOk (0 ) {
222+ return
223+ }
220224 switch l .peekN (0 ) {
221225 case '-' :
222226 if l .peekOk (1 ) && l .peekN (1 ) == '-' {
@@ -253,7 +257,6 @@ func (l *Lexer) peekToken() (*Token, error) {
253257}
254258
255259func (l * Lexer ) consumeToken () error {
256- l .skipSpace ()
257260 // clear last token
258261 l .lastToken = nil
259262 l .skipComments ()
Original file line number Diff line number Diff line change 1+ -- Origin SQL:
2+ select
3+ -- first line
4+ -- second line
5+ *
6+ from
7+ t0
8+
9+ -- Format SQL:
10+
11+ SELECT
12+ *
13+ FROM
14+ t0;
Original file line number Diff line number Diff line change 1+ [
2+ {
3+ "SelectPos" : 0 ,
4+ "StatementEnd" : 61 ,
5+ "With" : null ,
6+ "Top" : null ,
7+ "SelectColumns" : {
8+ "ListPos" : 48 ,
9+ "ListEnd" : 48 ,
10+ "HasDistinct" : false ,
11+ "Items" : [
12+ {
13+ "Name" : " *" ,
14+ "QuoteType" : 0 ,
15+ "NamePos" : 48 ,
16+ "NameEnd" : 48
17+ }
18+ ]
19+ },
20+ "From" : {
21+ "FromPos" : 50 ,
22+ "Expr" : {
23+ "Table" : {
24+ "TablePos" : 59 ,
25+ "TableEnd" : 61 ,
26+ "Alias" : null ,
27+ "Expr" : {
28+ "Database" : null ,
29+ "Table" : {
30+ "Name" : " t0" ,
31+ "QuoteType" : 1 ,
32+ "NamePos" : 59 ,
33+ "NameEnd" : 61
34+ }
35+ },
36+ "HasFinal" : false
37+ },
38+ "StatementEnd" : 61 ,
39+ "SampleRatio" : null ,
40+ "HasFinal" : false
41+ }
42+ },
43+ "ArrayJoin" : null ,
44+ "Window" : null ,
45+ "Prewhere" : null ,
46+ "Where" : null ,
47+ "GroupBy" : null ,
48+ "WithTotal" : false ,
49+ "Having" : null ,
50+ "OrderBy" : null ,
51+ "LimitBy" : null ,
52+ "Limit" : null ,
53+ "Settings" : null ,
54+ "UnionAll" : null ,
55+ "UnionDistinct" : null ,
56+ "Except" : null
57+ }
58+ ]
Original file line number Diff line number Diff line change 1+ select
2+ -- first line
3+ -- second line
4+ *
5+ from
6+ t0
You can’t perform that action at this time.
0 commit comments