Skip to content

Commit bffba8d

Browse files
authored
fix: Multiple Partiql and Amazon Ion textual notation fixes (#4686)
* Bug fixes & improvements to Ion mode - Changes symbols to `storage` type instead of `constant` - Bug fix for some edge cases around annotations - Bug fixes for some edge cases around strings better * Bug fixes & improvements to PartiQL mode - Rearranges rule order so punctuation fallback doesn't clobber collections - Bug fixes for collection types - Bug fixes for some edge cases around strings better - Bug fix for embedded ion rule end token type
1 parent 33cf1c6 commit bffba8d

File tree

7 files changed

+221
-184
lines changed

7 files changed

+221
-184
lines changed

demo/kitchen-sink/docs/ion.ion

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Comment
77
[1,2,3,45 /*TODO: should be 42, obviously*/, 2016-04-21T08:10:46Z, 2016-04-21T08:10:46-08:00, 2016-04-21, 2016, 0x5, 0b0110]
88
(5 7 1 3 [
99
'a', 'b',
10-
null, null.int, null.bool, null.list
10+
null, null.int, null.bool, null.list,
1111
true, false,
1212
nan, -inf, +inf,
1313
"str",
@@ -33,15 +33,15 @@ states::{
3333

3434
// https://amzn.github.io/ion-docs/docs/spec.html#string
3535
string: rules::[
36-
match::{
36+
match :: {
3737
regex: "(\\\")((?:\\\\\"|[^\"])*)(\\\")",
3838
token: ['string.dblq.punc.start', 'string.dblq', 'string.dblq.punc.end']
3939
},
4040
push::{
4141
regex: "\'{3}",
4242
token: 'string.trpq.punc.start',
4343
states: rules::[
44-
pop::{
44+
pop :: {
4545
regex: "\'{3}",
4646
token: 'string.trpq.punc.end',
4747
},
@@ -58,7 +58,7 @@ states::{
5858
*/
5959
}
6060
{
61-
"json": {
61+
"json": {
6262
"compatibility": true,
6363
"open sourced": "2016-04-21T08:10:46Z",
6464
"foo": 9,

demo/kitchen-sink/docs/partiql.partiql

+2-5
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
line
44
comment */
55

6-
SELECT a, b, c FROM stuff s INNER CROSS JOIN @s WHERE f(s) -- comment
6+
SELECT "a", b, c FROM stuff s INNER CROSS JOIN @s WHERE f(s) -- comment
77
-- comment
8-
SELECT "a", b FROM stuff s, @s WHERE f(s)
98

109
SELECT VALUE {'sensor': s.sensor,
1110
'readings': (SELECT VALUE l.co
@@ -30,6 +29,7 @@ FROM `[{'a':1, 'b':1}, {'a':2}, "foo"]` AS x
3029

3130
SELECT VALUE {v.a: v.b, v.c: v.d}
3231
FROM <<{'a':'same', 'b':1, 'c':'same', 'd':2}>> AS v
32+
WHERE v.b
3333

3434
SELECT u.id, feedbackId, commentId, upvoteId
3535
FROM users as u, u.feedbacks as feedback at feedbackId
@@ -52,9 +52,6 @@ SELECT (
5252

5353
SELECT SUM(AVG(n)) FROM <<numbers, numbers>> AS n
5454

55-
SELECT VALUES v.a
56-
FROM [{'a':1, 'b':true}, {'a':2, 'b':null}, {'a':3}] v
57-
WHERE v.b
5855

5956
SELECT attributeId, COUNT(*) as the_count
6057
FROM repeating_things

lib/ace/mode/_test/tokens_ion.json

+27-18
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@
6262
],[
6363
["punctuation.definition.list.begin.ion","punctuation.definition.sexp.begin.ion"],
6464
["text.ion"," "],
65-
["constant.other.symbol.quoted.ion","'a'"],
65+
["storage.type.symbol.quoted.ion","'a'"],
6666
["punctuation.definition.list.separator.ion",","],
6767
["text.ion"," "],
68-
["constant.other.symbol.quoted.ion","'b'"],
68+
["storage.type.symbol.quoted.ion","'b'"],
6969
["punctuation.definition.list.separator.ion",","]
7070
],[
7171
["punctuation.definition.list.begin.ion","punctuation.definition.sexp.begin.ion"],
@@ -163,7 +163,8 @@
163163
"start"
164164
],[
165165
"punctuation.definition.struct.begin.ion",
166-
["variable.language.annotation.ion","states::"],
166+
["variable.language.annotation.ion","states"],
167+
["punctuation.definition.annotation.ion","::"],
167168
["punctuation.definition.struct.begin.ion","{"]
168169
],[
169170
"punctuation.definition.struct.begin.ion",
@@ -175,13 +176,15 @@
175176
["constant.other.symbol.identifier.ion","root"],
176177
["punctuation.definition.struct.separator.ion",":"],
177178
["text.ion"," "],
178-
["variable.language.annotation.ion","rules::"],
179+
["variable.language.annotation.ion","rules"],
180+
["punctuation.definition.annotation.ion","::"],
179181
["punctuation.definition.list.begin.ion","["]
180182
],[
181183
["punctuation.definition.list.begin.ion","punctuation.definition.struct.begin.ion"],
182184
["text.ion"," "],
183-
["variable.language.annotation.ion","include::"],
184-
["constant.other.symbol.quoted.ion","'value'"]
185+
["variable.language.annotation.ion","include"],
186+
["punctuation.definition.annotation.ion","::"],
187+
["storage.type.symbol.quoted.ion","'value'"]
185188
],[
186189
"punctuation.definition.struct.begin.ion",
187190
["text.ion"," "],
@@ -199,12 +202,14 @@
199202
["constant.other.symbol.identifier.ion","string"],
200203
["punctuation.definition.struct.separator.ion",":"],
201204
["text.ion"," "],
202-
["variable.language.annotation.ion","rules::"],
205+
["variable.language.annotation.ion","rules"],
206+
["punctuation.definition.annotation.ion","::"],
203207
["punctuation.definition.list.begin.ion","["]
204208
],[
205209
["punctuation.definition.struct.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.struct.begin.ion"],
206210
["text.ion"," "],
207-
["variable.language.annotation.ion","match::"],
211+
["variable.language.annotation.ion","match"],
212+
["punctuation.definition.annotation.ion","::"],
208213
["punctuation.definition.struct.begin.ion","{"]
209214
],[
210215
["punctuation.definition.struct.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.struct.begin.ion"],
@@ -223,13 +228,13 @@
223228
["punctuation.definition.struct.separator.ion",":"],
224229
["text.ion"," "],
225230
["punctuation.definition.list.begin.ion","["],
226-
["constant.other.symbol.quoted.ion","'string.dblq.punc.start'"],
231+
["storage.type.symbol.quoted.ion","'string.dblq.punc.start'"],
227232
["punctuation.definition.list.separator.ion",","],
228233
["text.ion"," "],
229-
["constant.other.symbol.quoted.ion","'string.dblq'"],
234+
["storage.type.symbol.quoted.ion","'string.dblq'"],
230235
["punctuation.definition.list.separator.ion",","],
231236
["text.ion"," "],
232-
["constant.other.symbol.quoted.ion","'string.dblq.punc.end'"],
237+
["storage.type.symbol.quoted.ion","'string.dblq.punc.end'"],
233238
["punctuation.definition.list.end.ion","]"]
234239
],[
235240
["punctuation.definition.list.begin.ion","punctuation.definition.struct.begin.ion"],
@@ -239,7 +244,8 @@
239244
],[
240245
["punctuation.definition.struct.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.struct.begin.ion"],
241246
["text.ion"," "],
242-
["variable.language.annotation.ion","push::"],
247+
["variable.language.annotation.ion","push"],
248+
["punctuation.definition.annotation.ion","::"],
243249
["punctuation.definition.struct.begin.ion","{"]
244250
],[
245251
["punctuation.definition.struct.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.struct.begin.ion"],
@@ -257,20 +263,22 @@
257263
["constant.other.symbol.identifier.ion","token"],
258264
["punctuation.definition.struct.separator.ion",":"],
259265
["text.ion"," "],
260-
["constant.other.symbol.quoted.ion","'string.trpq.punc.start'"],
266+
["storage.type.symbol.quoted.ion","'string.trpq.punc.start'"],
261267
["punctuation.definition.struct.separator.ion",","]
262268
],[
263269
["punctuation.definition.list.begin.ion","punctuation.definition.struct.begin.ion","punctuation.definition.struct.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.struct.begin.ion"],
264270
["text.ion"," "],
265271
["constant.other.symbol.identifier.ion","states"],
266272
["punctuation.definition.struct.separator.ion",":"],
267273
["text.ion"," "],
268-
["variable.language.annotation.ion","rules::"],
274+
["variable.language.annotation.ion","rules"],
275+
["punctuation.definition.annotation.ion","::"],
269276
["punctuation.definition.list.begin.ion","["]
270277
],[
271278
["punctuation.definition.struct.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.struct.begin.ion","punctuation.definition.struct.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.struct.begin.ion"],
272279
["text.ion"," "],
273-
["variable.language.annotation.ion","pop::"],
280+
["variable.language.annotation.ion","pop"],
281+
["punctuation.definition.annotation.ion","::"],
274282
["punctuation.definition.struct.begin.ion","{"]
275283
],[
276284
["punctuation.definition.struct.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.struct.begin.ion","punctuation.definition.struct.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.struct.begin.ion"],
@@ -288,7 +296,7 @@
288296
["constant.other.symbol.identifier.ion","token"],
289297
["punctuation.definition.struct.separator.ion",":"],
290298
["text.ion"," "],
291-
["constant.other.symbol.quoted.ion","'string.trpq.punc.end'"],
299+
["storage.type.symbol.quoted.ion","'string.trpq.punc.end'"],
292300
["punctuation.definition.struct.separator.ion",","]
293301
],[
294302
["punctuation.definition.list.begin.ion","punctuation.definition.struct.begin.ion","punctuation.definition.struct.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.struct.begin.ion"],
@@ -298,7 +306,8 @@
298306
],[
299307
["punctuation.definition.struct.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.struct.begin.ion","punctuation.definition.struct.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.struct.begin.ion"],
300308
["text.ion"," "],
301-
["variable.language.annotation.ion","match::"],
309+
["variable.language.annotation.ion","match"],
310+
["punctuation.definition.annotation.ion","::"],
302311
["punctuation.definition.struct.begin.ion","{"]
303312
],[
304313
["punctuation.definition.struct.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.struct.begin.ion","punctuation.definition.struct.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.struct.begin.ion"],
@@ -316,7 +325,7 @@
316325
["constant.other.symbol.identifier.ion","token"],
317326
["punctuation.definition.struct.separator.ion",":"],
318327
["text.ion"," "],
319-
["constant.other.symbol.quoted.ion","'string.trpq'"]
328+
["storage.type.symbol.quoted.ion","'string.trpq'"]
320329
],[
321330
["punctuation.definition.list.begin.ion","punctuation.definition.struct.begin.ion","punctuation.definition.struct.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.list.begin.ion","punctuation.definition.struct.begin.ion"],
322331
["text.ion"," "],

0 commit comments

Comments
 (0)