@@ -5193,101 +5193,109 @@ JsonFunction JsonFunction() : {
5193
5193
Column column = null;
5194
5194
JsonKeyValuePair keyValuePair;
5195
5195
5196
+ Object key = null;
5196
5197
Expression expression = null;
5197
5198
JsonFunctionExpression functionExpression;
5198
5199
5199
5200
}
5200
5201
{
5201
5202
(
5202
- (
5203
- ( <K_JSON_OBJECT>
5204
- "(" { result.setType( JsonFunctionType.OBJECT ); }
5205
- (
5203
+ ( <K_JSON_OBJECT>
5204
+ "(" { result.setType( JsonFunctionType.OBJECT ); }
5205
+ (
5206
+ // SQL2016 compliant Syntax
5207
+ LOOKAHEAD(2) (
5208
+ LOOKAHEAD(2) (
5209
+ "KEY" { usingKeyKeyword = true; } ( keyToken = <S_CHAR_LITERAL> { key = keyToken.image; } | key = Column() )
5210
+ )
5211
+ |
5212
+ keyToken = <S_CHAR_LITERAL> { key = keyToken.image; }
5213
+ |
5214
+ key = Column()
5215
+ )
5216
+
5217
+ ( LOOKAHEAD(2)
5218
+ ( ":" | "," { result.setType( JsonFunctionType.POSTGRES_OBJECT ); } | "VALUE" { usingValueKeyword = true; } )
5206
5219
(
5207
- // SQL2016 compliant Syntax
5208
- (
5209
- [ "KEY" { usingKeyKeyword = true; } ]
5210
- keyToken = <S_CHAR_LITERAL>
5220
+ expression = Expression()
5221
+ )
5222
+ [ <K_FORMAT> <K_JSON> { usingFormatJason = true; } ]
5223
+ )?
5224
+ {
5225
+ if (expression !=null) {
5226
+ keyValuePair = new JsonKeyValuePair( key, expression, usingKeyKeyword, usingValueKeyword );
5227
+ keyValuePair.setUsingFormatJson( usingFormatJason );
5228
+ result.add(keyValuePair);
5229
+ } else {
5230
+ result.setType( JsonFunctionType.POSTGRES_OBJECT );
5231
+ keyValuePair = new JsonKeyValuePair( key, null, false, false );
5232
+ result.add(keyValuePair);
5233
+ }
5234
+ }
5211
5235
5212
- ( LOOKAHEAD(2)
5213
- ( ":" | "," { result.setType( JsonFunctionType.POSTGRES_OBJECT ); } | "VALUE" { usingValueKeyword = true; } )
5214
- (
5215
- expression = Expression()
5216
- )
5217
- [ <K_FORMAT> <K_JSON> { usingFormatJason = true; } ]
5218
- )? {
5219
- if (expression !=null) {
5220
- keyValuePair = new JsonKeyValuePair( keyToken.image, expression, usingKeyKeyword, usingValueKeyword );
5221
- keyValuePair.setUsingFormatJson( usingFormatJason );
5222
- result.add(keyValuePair);
5223
- } else {
5224
- result.setType( JsonFunctionType.POSTGRES_OBJECT );
5225
- keyValuePair = new JsonKeyValuePair( keyToken.image, null, false, false );
5226
- result.add(keyValuePair);
5227
- }
5228
- }
5229
-
5230
- // --- Next Elements
5231
- ( "," { usingKeyKeyword = false; usingValueKeyword = false; }
5232
- [ "KEY" { usingKeyKeyword = true; } ]
5233
- keyToken = <S_CHAR_LITERAL>
5234
- ( ":" | "," { result.setType( JsonFunctionType.MYSQL_OBJECT ); } | "VALUE" { usingValueKeyword = true; } )
5235
- (
5236
- expression = Expression() { keyValuePair = new JsonKeyValuePair( keyToken.image, expression, usingKeyKeyword, usingValueKeyword ); result.add(keyValuePair); }
5237
- )
5238
- [ <K_FORMAT> <K_JSON> { keyValuePair.setUsingFormatJson( true ); } ]
5239
- )*
5236
+ // --- Next Elements
5237
+ ( "," { usingKeyKeyword = false; usingValueKeyword = false; }
5238
+ (
5239
+ LOOKAHEAD(2) (
5240
+ "KEY" { usingKeyKeyword = true; } ( keyToken = <S_CHAR_LITERAL> { key = keyToken.image; } | key = Column() )
5240
5241
)
5241
- )?
5242
+ |
5243
+ keyToken = <S_CHAR_LITERAL> { key = keyToken.image; }
5244
+ |
5245
+ key = Column()
5246
+ )
5247
+ ( ":" | "," { result.setType( JsonFunctionType.MYSQL_OBJECT ); } | "VALUE" { usingValueKeyword = true; } )
5248
+ expression = Expression() { keyValuePair = new JsonKeyValuePair( key, expression, usingKeyKeyword, usingValueKeyword ); result.add(keyValuePair); }
5249
+ [ <K_FORMAT> <K_JSON> { keyValuePair.setUsingFormatJson( true ); } ]
5250
+ )*
5251
+ )?
5242
5252
5243
- [
5244
- (
5245
- <K_NULL> <K_ON> <K_NULL> { result.setOnNullType( JsonAggregateOnNullType.NULL ); }
5246
- )
5247
- |
5248
- (
5249
- <K_ABSENT> <K_ON> <K_NULL> { result.setOnNullType( JsonAggregateOnNullType.ABSENT ); }
5250
- )
5251
- ]
5253
+ [
5254
+ (
5255
+ <K_NULL> <K_ON> <K_NULL> { result.setOnNullType( JsonAggregateOnNullType.NULL ); }
5256
+ )
5257
+ |
5258
+ (
5259
+ <K_ABSENT> <K_ON> <K_NULL> { result.setOnNullType( JsonAggregateOnNullType.ABSENT ); }
5260
+ )
5261
+ ]
5252
5262
5253
- [
5254
- (
5255
- <K_WITH> <K_UNIQUE> <K_KEYS> { result.setUniqueKeysType( JsonAggregateUniqueKeysType.WITH ); }
5256
- )
5257
- |
5258
- (
5259
- <K_WITHOUT> <K_UNIQUE> <K_KEYS> { result.setUniqueKeysType( JsonAggregateUniqueKeysType.WITHOUT ); }
5260
- )
5261
- ]
5263
+ [
5264
+ (
5265
+ <K_WITH> <K_UNIQUE> <K_KEYS> { result.setUniqueKeysType( JsonAggregateUniqueKeysType.WITH ); }
5266
+ )
5267
+ |
5268
+ (
5269
+ <K_WITHOUT> <K_UNIQUE> <K_KEYS> { result.setUniqueKeysType( JsonAggregateUniqueKeysType.WITHOUT ); }
5270
+ )
5271
+ ]
5272
+ ")"
5273
+ )
5274
+ |
5275
+ (
5276
+ <K_JSON_ARRAY> { result.setType( JsonFunctionType.ARRAY ); }
5277
+ "("
5278
+ (
5279
+ LOOKAHEAD(2) (
5280
+ <K_NULL> <K_ON> <K_NULL> { result.setOnNullType( JsonAggregateOnNullType.NULL ); }
5262
5281
)
5263
- ")"
5264
- )
5265
- |
5266
- (
5267
- <K_JSON_ARRAY> { result.setType( JsonFunctionType.ARRAY ); }
5268
- "("
5282
+ |
5283
+ expression=Expression() { functionExpression = new JsonFunctionExpression( expression ); result.add( functionExpression ); }
5284
+
5285
+ [ LOOKAHEAD(2) <K_FORMAT> <K_JSON> { functionExpression.setUsingFormatJson( true ); } ]
5269
5286
(
5270
- LOOKAHEAD(2) (
5271
- <K_NULL> <K_ON> <K_NULL> { result.setOnNullType( JsonAggregateOnNullType.NULL ); }
5272
- )
5273
- |
5287
+ ","
5274
5288
expression=Expression() { functionExpression = new JsonFunctionExpression( expression ); result.add( functionExpression ); }
5275
-
5276
5289
[ LOOKAHEAD(2) <K_FORMAT> <K_JSON> { functionExpression.setUsingFormatJson( true ); } ]
5277
- (
5278
- ","
5279
- expression=Expression() { functionExpression = new JsonFunctionExpression( expression ); result.add( functionExpression ); }
5280
- [ LOOKAHEAD(2) <K_FORMAT> <K_JSON> { functionExpression.setUsingFormatJson( true ); } ]
5281
- )*
5282
5290
)*
5291
+ )*
5283
5292
5284
- [
5285
- <K_ABSENT> <K_ON> <K_NULL> { result.setOnNullType( JsonAggregateOnNullType.ABSENT ); }
5286
- ]
5293
+ [
5294
+ <K_ABSENT> <K_ON> <K_NULL> { result.setOnNullType( JsonAggregateOnNullType.ABSENT ); }
5295
+ ]
5287
5296
5288
- ")"
5289
- )
5290
- )
5297
+ ")"
5298
+ )
5291
5299
)
5292
5300
5293
5301
{
@@ -5298,6 +5306,7 @@ JsonFunction JsonFunction() : {
5298
5306
JsonAggregateFunction JsonAggregateFunction() : {
5299
5307
JsonAggregateFunction result = new JsonAggregateFunction();
5300
5308
Token token;
5309
+ Object key;
5301
5310
Expression expression;
5302
5311
List<OrderByElement> expressionOrderByList = null;
5303
5312
@@ -5312,10 +5321,32 @@ JsonAggregateFunction JsonAggregateFunction() : {
5312
5321
(
5313
5322
( <K_JSON_OBJECTAGG>
5314
5323
"(" { result.setType( JsonFunctionType.OBJECT ); }
5315
- [ "KEY" { result.setUsingKeyKeyword( true ); } ]
5316
- ( token = <DT_ZONE> | token = <S_DOUBLE> | token = <S_LONG> | token = <S_HEX> | token = <S_CHAR_LITERAL> | token = <S_IDENTIFIER> | token = <S_QUOTED_IDENTIFIER> ) { result.setKey( token.image ); }
5317
- ( ":" | "VALUE" {result.setUsingValueKeyword( true ); } )
5318
- ( token = <S_IDENTIFIER> | token = <S_QUOTED_IDENTIFIER> ) { result.setValue( token.image ); }
5324
+ (
5325
+ LOOKAHEAD(2) (
5326
+ "KEY" { result.setUsingKeyKeyword( true ); }
5327
+ (
5328
+ ( token = <DT_ZONE> | token = <S_DOUBLE> | token = <S_LONG> | token = <S_HEX> | token = <S_CHAR_LITERAL> )
5329
+ {
5330
+ key = token.image;
5331
+ }
5332
+ |
5333
+ key = Column()
5334
+ )
5335
+ )
5336
+ |
5337
+ ( token = <DT_ZONE> | token = <S_DOUBLE> | token = <S_LONG> | token = <S_HEX> | token = <S_CHAR_LITERAL> )
5338
+ {
5339
+ key = token.image;
5340
+ }
5341
+ |
5342
+ key = Column()
5343
+ )
5344
+ {
5345
+ result.setKey( key );
5346
+ }
5347
+
5348
+ ( ":" | "," { result.setType( JsonFunctionType.MYSQL_OBJECT ); } | "VALUE" {result.setUsingValueKeyword( true ); } )
5349
+ expression = Expression() { result.setValue( expression ); }
5319
5350
5320
5351
[ <K_FORMAT> <K_JSON> { result.setUsingFormatJson( true ); } ]
5321
5352
0 commit comments