Merge lp:~oontvoo/akiban-sql-parser/optional_semi into lp:~akiban-technologies/akiban-sql-parser/trunk

Proposed by Vy Nguyen
Status: Rejected
Rejected by: Vy Nguyen
Proposed branch: lp:~oontvoo/akiban-sql-parser/optional_semi
Merge into: lp:~akiban-technologies/akiban-sql-parser/trunk
Diff against target: 244 lines (+127/-4)
14 files modified
src/main/javacc/SQLGrammar.jj (+15/-3)
src/test/resources/com/akiban/sql/parser/alter-table-1.error (+1/-0)
src/test/resources/com/akiban/sql/parser/alter-table-2.error (+2/-1)
src/test/resources/com/akiban/sql/parser/mysql-1x.error (+1/-0)
src/test/resources/com/akiban/sql/parser/mysql-2x.error (+1/-0)
src/test/resources/com/akiban/sql/parser/mysql-4x.error (+1/-0)
src/test/resources/com/akiban/sql/parser/test-no-semi-2.expected (+32/-0)
src/test/resources/com/akiban/sql/parser/test-no-semi-2.sql (+1/-0)
src/test/resources/com/akiban/sql/parser/test-semi-1.expected (+32/-0)
src/test/resources/com/akiban/sql/parser/test-semi-1.sql (+1/-0)
src/test/resources/com/akiban/sql/parser/test-semi-3.expected (+32/-0)
src/test/resources/com/akiban/sql/parser/test-semi-3.sql (+2/-0)
src/test/resources/com/akiban/sql/unparser/multiple/multiple-4.expected (+3/-0)
src/test/resources/com/akiban/sql/unparser/multiple/multiple-4.sql (+3/-0)
To merge this branch: bzr merge lp:~oontvoo/akiban-sql-parser/optional_semi
Reviewer Review Type Date Requested Status
Akiban Technologies Pending
Review via email: mp+154448@code.launchpad.net

Description of the change

allow optional semicolon at the end

To post a comment you must log in.
299. By Vy Nguyen

more tests with and without SEMI at the end

300. By Vy Nguyen

rename misleading test

Revision history for this message
Nathan Williams (nwilliams) wrote :

The grammar and API already provide for this in the existing via Statement/parseStatement and StatementList/parseStatements.

I don't think conflating the two at this level adds much benefit.

Revision history for this message
Vy Nguyen (oontvoo) wrote :

Ah, Ok, I'm not insisting on this change. I wasn't aware that you could allow the semicolon with the current parser?

Unmerged revisions

300. By Vy Nguyen

rename misleading test

299. By Vy Nguyen

more tests with and without SEMI at the end

298. By Vy Nguyen

clean up

297. By Vy Nguyen

rewrite conditions to avoid warnings

296. By Vy Nguyen

add lookahead to disallow duplicate SEMI

295. By Vy Nguyen

add lookahead to disallow duplicate SEMI

294. By Vy Nguyen

add tests

293. By Vy Nguyen

allow optional SEMI at the end

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/main/javacc/SQLGrammar.jj'
2--- src/main/javacc/SQLGrammar.jj 2013-02-25 00:17:53 +0000
3+++ src/main/javacc/SQLGrammar.jj 2013-03-20 17:29:21 +0000
4@@ -2909,7 +2909,7 @@
5 StatementNode statementNode;
6 }
7 {
8- statementNode = StatementPart(null) <EOF>
9+ statementNode = StatementPart(null) [<SEMICOLON>] <EOF>
10 {
11 return statementNode;
12 }
13@@ -2922,8 +2922,20 @@
14 }
15 {
16 statementListElement(list, tokenHolder)
17- ( <SEMICOLON> [ statementListElement(list, tokenHolder) ] )*
18- <EOF>
19+(
20+ LOOKAHEAD ( {getToken(1).kind != EOF && getToken(2).kind != EOF } )
21+ (
22+ (
23+ <SEMICOLON>[statementListElement(list, tokenHolder)]
24+ )*
25+ <EOF>
26+ )
27+ |
28+ (
29+ [<SEMICOLON>]
30+ <EOF>
31+ )
32+)
33 }
34
35 void
36
37=== modified file 'src/test/resources/com/akiban/sql/parser/alter-table-1.error'
38--- src/test/resources/com/akiban/sql/parser/alter-table-1.error 2012-11-30 19:02:16 +0000
39+++ src/test/resources/com/akiban/sql/parser/alter-table-1.error 2013-03-20 17:29:21 +0000
40@@ -3,4 +3,5 @@
41 <EOF>
42 "cascade" ...
43 "restrict" ...
44+ ";" ...
45
46\ No newline at end of file
47
48=== modified file 'src/test/resources/com/akiban/sql/parser/alter-table-2.error'
49--- src/test/resources/com/akiban/sql/parser/alter-table-2.error 2012-11-30 19:02:16 +0000
50+++ src/test/resources/com/akiban/sql/parser/alter-table-2.error 2013-03-20 17:29:21 +0000
51@@ -1,4 +1,5 @@
52 com.akiban.sql.parser.SQLParserException: Encountered " "," ", "" at line 1, column 25.
53-Was expecting:
54+Was expecting one of:
55 <EOF>
56+ ";" ...
57
58\ No newline at end of file
59
60=== modified file 'src/test/resources/com/akiban/sql/parser/mysql-1x.error'
61--- src/test/resources/com/akiban/sql/parser/mysql-1x.error 2012-05-16 00:15:22 +0000
62+++ src/test/resources/com/akiban/sql/parser/mysql-1x.error 2013-03-20 17:29:21 +0000
63@@ -20,4 +20,5 @@
64 "offset" ...
65 "limit" ...
66 "," ...
67+ ";" ...
68
69\ No newline at end of file
70
71=== modified file 'src/test/resources/com/akiban/sql/parser/mysql-2x.error'
72--- src/test/resources/com/akiban/sql/parser/mysql-2x.error 2012-05-16 00:15:22 +0000
73+++ src/test/resources/com/akiban/sql/parser/mysql-2x.error 2013-03-20 17:29:21 +0000
74@@ -20,4 +20,5 @@
75 "offset" ...
76 "limit" ...
77 "," ...
78+ ";" ...
79
80\ No newline at end of file
81
82=== modified file 'src/test/resources/com/akiban/sql/parser/mysql-4x.error'
83--- src/test/resources/com/akiban/sql/parser/mysql-4x.error 2012-05-16 00:15:22 +0000
84+++ src/test/resources/com/akiban/sql/parser/mysql-4x.error 2013-03-20 17:29:21 +0000
85@@ -17,4 +17,5 @@
86 "with" ...
87 "offset" ...
88 "limit" ...
89+ ";" ...
90
91\ No newline at end of file
92
93=== added file 'src/test/resources/com/akiban/sql/parser/test-no-semi-2.expected'
94--- src/test/resources/com/akiban/sql/parser/test-no-semi-2.expected 1970-01-01 00:00:00 +0000
95+++ src/test/resources/com/akiban/sql/parser/test-no-semi-2.expected 2013-03-20 17:29:21 +0000
96@@ -0,0 +1,32 @@
97+com.akiban.sql.parser.CursorNode@4253c155
98+name: null
99+updateMode: UNSPECIFIED
100+statementType: SELECT
101+resultSet:
102+ com.akiban.sql.parser.SelectNode@8b9d578
103+ isDistinct: false
104+ resultColumns:
105+ com.akiban.sql.parser.ResultColumnList@606dbdc1
106+
107+ [0]:
108+ com.akiban.sql.parser.ResultColumn@44c4fb5c
109+ exposedName: null
110+ name: null
111+ tableName: null
112+ isDefaultColumn: false
113+ type: null
114+ expression:
115+ com.akiban.sql.parser.BinaryArithmeticOperatorNode@60527849
116+ operator: +
117+ methodName: plus
118+ type: null
119+ leftOperand:
120+ com.akiban.sql.parser.NumericConstantNode@46573206
121+ value: 2
122+ type: INTEGER NOT NULL
123+ rightOperand:
124+ com.akiban.sql.parser.NumericConstantNode@6954bfe
125+ value: 3
126+ type: INTEGER NOT NULL
127+ fromList:
128+ com.akiban.sql.parser.FromList@33b01412
129\ No newline at end of file
130
131=== added file 'src/test/resources/com/akiban/sql/parser/test-no-semi-2.sql'
132--- src/test/resources/com/akiban/sql/parser/test-no-semi-2.sql 1970-01-01 00:00:00 +0000
133+++ src/test/resources/com/akiban/sql/parser/test-no-semi-2.sql 2013-03-20 17:29:21 +0000
134@@ -0,0 +1,1 @@
135+SELECT 2 + 3
136
137=== added file 'src/test/resources/com/akiban/sql/parser/test-semi-1.expected'
138--- src/test/resources/com/akiban/sql/parser/test-semi-1.expected 1970-01-01 00:00:00 +0000
139+++ src/test/resources/com/akiban/sql/parser/test-semi-1.expected 2013-03-20 17:29:21 +0000
140@@ -0,0 +1,32 @@
141+com.akiban.sql.parser.CursorNode@4253c155
142+name: null
143+updateMode: UNSPECIFIED
144+statementType: SELECT
145+resultSet:
146+ com.akiban.sql.parser.SelectNode@8b9d578
147+ isDistinct: false
148+ resultColumns:
149+ com.akiban.sql.parser.ResultColumnList@606dbdc1
150+
151+ [0]:
152+ com.akiban.sql.parser.ResultColumn@44c4fb5c
153+ exposedName: null
154+ name: null
155+ tableName: null
156+ isDefaultColumn: false
157+ type: null
158+ expression:
159+ com.akiban.sql.parser.BinaryArithmeticOperatorNode@60527849
160+ operator: +
161+ methodName: plus
162+ type: null
163+ leftOperand:
164+ com.akiban.sql.parser.NumericConstantNode@46573206
165+ value: 2
166+ type: INTEGER NOT NULL
167+ rightOperand:
168+ com.akiban.sql.parser.NumericConstantNode@6954bfe
169+ value: 3
170+ type: INTEGER NOT NULL
171+ fromList:
172+ com.akiban.sql.parser.FromList@33b01412
173\ No newline at end of file
174
175=== added file 'src/test/resources/com/akiban/sql/parser/test-semi-1.sql'
176--- src/test/resources/com/akiban/sql/parser/test-semi-1.sql 1970-01-01 00:00:00 +0000
177+++ src/test/resources/com/akiban/sql/parser/test-semi-1.sql 2013-03-20 17:29:21 +0000
178@@ -0,0 +1,1 @@
179+SELECT 2 + 3;
180\ No newline at end of file
181
182=== added file 'src/test/resources/com/akiban/sql/parser/test-semi-3.expected'
183--- src/test/resources/com/akiban/sql/parser/test-semi-3.expected 1970-01-01 00:00:00 +0000
184+++ src/test/resources/com/akiban/sql/parser/test-semi-3.expected 2013-03-20 17:29:21 +0000
185@@ -0,0 +1,32 @@
186+com.akiban.sql.parser.CursorNode@65bbd743
187+name: null
188+updateMode: UNSPECIFIED
189+statementType: SELECT
190+resultSet:
191+ com.akiban.sql.parser.SelectNode@f31a3e3
192+ isDistinct: false
193+ resultColumns:
194+ com.akiban.sql.parser.ResultColumnList@3fe93e0
195+
196+ [0]:
197+ com.akiban.sql.parser.ResultColumn@3e9e592c
198+ exposedName: null
199+ name: null
200+ tableName: null
201+ isDefaultColumn: false
202+ type: null
203+ expression:
204+ com.akiban.sql.parser.BinaryArithmeticOperatorNode@df077d2
205+ operator: +
206+ methodName: plus
207+ type: null
208+ leftOperand:
209+ com.akiban.sql.parser.NumericConstantNode@264a8324
210+ value: 2
211+ type: INTEGER NOT NULL
212+ rightOperand:
213+ com.akiban.sql.parser.NumericConstantNode@65e7c41f
214+ value: 3
215+ type: INTEGER NOT NULL
216+ fromList:
217+ com.akiban.sql.parser.FromList@52fd037d
218\ No newline at end of file
219
220=== added file 'src/test/resources/com/akiban/sql/parser/test-semi-3.sql'
221--- src/test/resources/com/akiban/sql/parser/test-semi-3.sql 1970-01-01 00:00:00 +0000
222+++ src/test/resources/com/akiban/sql/parser/test-semi-3.sql 2013-03-20 17:29:21 +0000
223@@ -0,0 +1,2 @@
224+SELECT 2 + 3
225+;
226\ No newline at end of file
227
228=== added file 'src/test/resources/com/akiban/sql/unparser/multiple/multiple-4.expected'
229--- src/test/resources/com/akiban/sql/unparser/multiple/multiple-4.expected 1970-01-01 00:00:00 +0000
230+++ src/test/resources/com/akiban/sql/unparser/multiple/multiple-4.expected 2013-03-20 17:29:21 +0000
231@@ -0,0 +1,3 @@
232+[0]: SELECT (3 + 3);
233+[1]: SELECT (4 + 6);
234+[2]: SELECT (6 + 3);
235\ No newline at end of file
236
237=== added file 'src/test/resources/com/akiban/sql/unparser/multiple/multiple-4.sql'
238--- src/test/resources/com/akiban/sql/unparser/multiple/multiple-4.sql 1970-01-01 00:00:00 +0000
239+++ src/test/resources/com/akiban/sql/unparser/multiple/multiple-4.sql 2013-03-20 17:29:21 +0000
240@@ -0,0 +1,3 @@
241+SELECT 3 + 3;
242+SELECT 4 + 6;
243+SELECT 6 + 3;
244\ No newline at end of file

Subscribers

People subscribed via source and target branches

to all changes: