@@ -166,6 +166,7 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */
166
166
| <K_ALIGN:"ALIGN">
167
167
| <K_ALL:"ALL">
168
168
| <K_ALTER:"ALTER">
169
+ | <K_ALWAYS:"ALWAYS">
169
170
| <K_ANALYZE:"ANALYZE">
170
171
| <K_AND:"AND">
171
172
| <K_ANY:"ANY">
@@ -188,6 +189,7 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */
188
189
| <K_BIT:"BIT">
189
190
| <K_BLOBSTORAGE:"BLOBSTORAGE">
190
191
| <K_BLOCK: "BLOCK">
192
+ | <K_BOOLEAN:"BOOLEAN">
191
193
| <K_BOTH:"BOTH">
192
194
| <K_BROWSE:"BROWSE">
193
195
| <K_BY:"BY">
@@ -225,6 +227,7 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */
225
227
| <K_COSTS: "COSTS">
226
228
| <K_COUNT: "COUNT">
227
229
| <K_CREATE:"CREATE">
230
+ | <K_CREATED:"CREATED">
228
231
| <K_CROSS:"CROSS">
229
232
| <K_CSV:"CSV">
230
233
| <K_CURRENT: "CURRENT">
@@ -240,6 +243,7 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */
240
243
| <K_DEFERRABLE : "DEFERRABLE">
241
244
| <K_DELAYED : "DELAYED">
242
245
| <K_DELETE:"DELETE">
246
+ | <K_DELIMIT : "DELIMIT">
243
247
| <K_DELIMITER : "DELIMITER">
244
248
| <K_DESC:"DESC">
245
249
| <K_DESCRIBE:"DESCRIBE">
@@ -279,6 +283,7 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */
279
283
| <K_EXTEND:"EXTEND">
280
284
| <K_EXTENDED:"EXTENDED">
281
285
| <K_EXTRACT:"EXTRACT">
286
+ | <K_EXPORT:"EXPORT">
282
287
| <K_FBV:"FBV">
283
288
| <K_FETCH:"FETCH">
284
289
| <K_ISOLATION:("UR" | "RS" | "RR" | "CS")>
@@ -380,7 +385,9 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */
380
385
| <K_MINVALUE:"MINVALUE">
381
386
| <K_MODIFY: "MODIFY">
382
387
| <K_MOVEMENT: "MOVEMENT">
388
+ | <K_NAMES:"NAMES">
383
389
| <K_NATURAL:"NATURAL">
390
+ | <K_NEVER:"NEVER">
384
391
| <K_NEXT:"NEXT">
385
392
| <K_NEXTVAL: ( (("NEXTVAL")((" ")+("FOR"))?) | ( ("NEXT")(" ")+("VALUE") (" ")+("FOR") ) )>
386
393
| <K_NO:"NO">
@@ -874,6 +881,8 @@ Statement SingleStatement() :
874
881
stm = PurgeStatement()
875
882
|
876
883
stm = Import()
884
+ |
885
+ stm = Export()
877
886
)
878
887
{ return stm; }
879
888
}
@@ -1091,6 +1100,28 @@ LikeClause LikeClause(): {
1091
1100
}
1092
1101
}
1093
1102
1103
+ Export Export() #Export: {
1104
+ Export export = new Export();
1105
+ Table table;
1106
+ ParenthesedExpressionList<Column> columns;
1107
+ ParenthesedSelect select;
1108
+ ExportIntoItem exportIntoItem;
1109
+ } {
1110
+ <K_EXPORT>
1111
+ (
1112
+ table = Table() { export.setTable(table); }
1113
+ [ columns = ParenthesedColumnList() { impt.setColumns(columns); } ]
1114
+ | select = ParenthesedSelect() { export.setSelect(select); }
1115
+ )
1116
+
1117
+ <K_INTO>
1118
+ exportIntoItem = ExportIntoItem() { export.setExportIntoItem(exportIntoItem); }
1119
+
1120
+ {
1121
+ return export;
1122
+ }
1123
+ }
1124
+
1094
1125
Import Import() #Import: {
1095
1126
Import impt = new Import();
1096
1127
Table table;
@@ -1160,6 +1191,22 @@ List<ImportColumn> ImportColumns(): {
1160
1191
}
1161
1192
}
1162
1193
1194
+ ExportIntoItem ExportIntoItem(): {
1195
+ ExportIntoItem exportIntoItem;
1196
+ ErrorClause errorClause;
1197
+ } {
1198
+ (
1199
+ exportIntoItem = DBMSDestination()
1200
+ | exportIntoItem = FileDestination()
1201
+ | exportIntoItem = ScriptSourceDestination()
1202
+ )
1203
+ [ LOOKAHEAD(2) errorClause = ErrorClause() { exportIntoItem.setErrorClause(errorClause); } ]
1204
+
1205
+ {
1206
+ return exportIntoItem;
1207
+ }
1208
+ }
1209
+
1163
1210
ImportFromItem ImportFromItem(): {
1164
1211
ImportFromItem importFromItem;
1165
1212
ErrorClause errorClause;
@@ -1176,6 +1223,62 @@ ImportFromItem ImportFromItem(): {
1176
1223
}
1177
1224
}
1178
1225
1226
+ DBMSDestination DBMSDestination() #DBMSDestination: {
1227
+ DBMSDestination dbmsDestination = new DBMSDestination();
1228
+ DBMSType dbmsType;
1229
+ ConnectionDefinition connectionDefinition;
1230
+ Table table;
1231
+ ExpressionList<Column> columns;
1232
+ StringValue statement;
1233
+ List<DBMSTableDestinationOption> dbmsTableDestinationOptions;
1234
+ } {
1235
+ dbmsType = DBMSType() { dbmsDestination.setSourceType(dbmsType); }
1236
+
1237
+ connectionDefinition = ConnectionDefinition() { dbmsDestination.setConnectionDefinition(connectionDefinition); }
1238
+
1239
+ (
1240
+ LOOKAHEAD(3)
1241
+ <K_TABLE> table = Table() { dbmsDestination.setTable(table); }
1242
+ [ LOOKAHEAD(2) columns = ParenthesedColumnList() { dbmsDestination.setColumns(columns); } ]
1243
+ [ LOOKAHEAD(2) dbmsTableDestinationOptions = DBMSTableDestinationOptionList() { dbmsDestination.setDBMSTableDestinationOptionList(dbmsTableDestinationOptions); } ]
1244
+ | statement = ImportExportStatement() { dbmsDestination.setStatement(statement); }
1245
+ )
1246
+
1247
+ {
1248
+ return dbmsDestination;
1249
+ }
1250
+ }
1251
+
1252
+ DBMSTableDestinationOption DBMSTableDestinationOption(): {
1253
+ DBMSTableDestinationOption dbmsTableDestinationOption;
1254
+
1255
+ Token token;
1256
+ Token token2;
1257
+ Token token3;
1258
+ } {
1259
+ (
1260
+ (
1261
+ token = <K_REPLACE>
1262
+ | token = <K_TRUNCATE>
1263
+ ) { dbmsTableDestinationOption = new DBMSTableDestinationOption(token.image); }
1264
+ | token = <K_CREATED> token2 = <K_BY> token3 = <S_CHAR_LITERAL> { dbmsTableDestinationOption = new DBMSTableDestinationOption(token.image + " " + token2.image, new StringValue(token3.image)); }
1265
+ )
1266
+
1267
+ {
1268
+ return dbmsTableDestinationOption;
1269
+ }
1270
+ }
1271
+
1272
+ List<DBMSTableDestinationOption> DBMSTableDestinationOptionList(): {
1273
+ List<DBMSTableDestinationOption> dbmsTableDestinationOptions = new ArrayList<DBMSTableDestinationOption>();
1274
+ DBMSTableDestinationOption dbmsTableDestinationOption;
1275
+ } {
1276
+ ( LOOKAHEAD(2) dbmsTableDestinationOption = DBMSTableDestinationOption() { dbmsTableDestinationOptions.add(dbmsTableDestinationOption); } )+
1277
+ {
1278
+ return dbmsTableDestinationOptions;
1279
+ }
1280
+ }
1281
+
1179
1282
DBMSSource DBMSSource() #DBMSSource: {
1180
1283
DBMSSource dbmsSource = new DBMSSource();
1181
1284
DBMSType dbmsType;
@@ -1192,7 +1295,7 @@ DBMSSource DBMSSource() #DBMSSource: {
1192
1295
(
1193
1296
<K_TABLE> table = Table() { dbmsSource.setTable(table); }
1194
1297
[ LOOKAHEAD(2) columns = ParenthesedColumnList() { dbmsSource.setColumns(columns); } ]
1195
- | statements = StatementsList () { dbmsSource.setStatements(statements); }
1298
+ | statements = ImportExportStatementsList () { dbmsSource.setStatements(statements); }
1196
1299
)
1197
1300
{
1198
1301
return dbmsSource;
@@ -1237,7 +1340,7 @@ StringValue ImportExportStatement() #ImportExportStatement: {
1237
1340
}
1238
1341
}
1239
1342
1240
- List<StringValue> StatementsList (): {
1343
+ List<StringValue> ImportExportStatementsList (): {
1241
1344
List<StringValue> statements = new ArrayList<StringValue>();
1242
1345
StringValue statement;
1243
1346
} {
@@ -1290,6 +1393,44 @@ List<ConnectionFileDefinition> ConnectionFileDefinitionList(): {
1290
1393
}
1291
1394
}
1292
1395
1396
+ CSVColumn CSVDestinationColumn(): {
1397
+ CSVColumn csvColumn;
1398
+
1399
+ Token token;
1400
+ Token token2;
1401
+ } {
1402
+ (
1403
+ LOOKAHEAD(2)
1404
+ token=<S_LONG> ".." token2=<S_LONG> { csvColumn = new CSVColumn(Long.valueOf(token.image), Long.valueOf(token2.image)); }
1405
+ | token=<S_LONG> { csvColumn = new CSVColumn(Long.valueOf(token.image)); }
1406
+ [ <K_FORMAT> "=" token = <S_CHAR_LITERAL> { csvColumn.setFormat(new StringValue(token.image)); }]
1407
+ [
1408
+ <K_DELIMIT>
1409
+ "="
1410
+ (
1411
+ token=<K_ALWAYS>
1412
+ | token=<K_NEVER>
1413
+ | token=<K_AUTO>
1414
+ )
1415
+ { csvColumn.setDelimit(token.image); }
1416
+ ]
1417
+ )
1418
+ {
1419
+ return csvColumn;
1420
+ }
1421
+ }
1422
+
1423
+ List<CSVColumn> CSVDestinationColumnList(): {
1424
+ List<CSVColumn> csvColumns = new ArrayList<CSVColumn>();
1425
+ CSVColumn csvColumn;
1426
+ } {
1427
+ csvColumn = CSVDestinationColumn() { csvColumns.add(csvColumn); }
1428
+ ( "," csvColumn = CSVDestinationColumn() { csvColumns.add(csvColumn); } )*
1429
+ {
1430
+ return csvColumns;
1431
+ }
1432
+ }
1433
+
1293
1434
CSVColumn CSVSourceColumn(): {
1294
1435
CSVColumn csvColumn;
1295
1436
@@ -1318,6 +1459,38 @@ List<CSVColumn> CSVSourceColumnList(): {
1318
1459
}
1319
1460
}
1320
1461
1462
+ FBVColumn FBVDestinationColumn(): {
1463
+ FBVColumn fbvColumn;
1464
+
1465
+ Token token;
1466
+ Token token2;
1467
+ } {
1468
+ (
1469
+ token=<K_SIZE> "=" token2=<S_LONG> { fbvColumn = new FBVColumn(token.image, new LongValue(token2.image)); }
1470
+ | ( token=<K_FORMAT> | token=<K_PADDING> ) "=" token2=<S_CHAR_LITERAL> { fbvColumn = new FBVColumn(token.image, new StringValue(token2.image)); }
1471
+ | token=<K_ALIGN> "=" ( token2=<K_LEFT> | token2=<K_RIGHT> ) { fbvColumn = new FBVColumn(token.image, token2.image); }
1472
+ )
1473
+ {
1474
+ return fbvColumn;
1475
+ }
1476
+ }
1477
+
1478
+ List<FBVColumn> FBVDestinationColumnList(): {
1479
+ List<FBVColumn> fbvColumns = new ArrayList<FBVColumn>();
1480
+ FBVColumn fbvColumn;
1481
+ boolean precedesComma;
1482
+ } {
1483
+ fbvColumn = FBVDestinationColumn() { fbvColumns.add(fbvColumn); }
1484
+ (
1485
+ { precedesComma = false; }
1486
+ ["," { precedesComma = true; }]
1487
+ fbvColumn = FBVDestinationColumn() { fbvColumn.setPrecedesComma(precedesComma); fbvColumns.add(fbvColumn); }
1488
+ )*
1489
+ {
1490
+ return fbvColumns;
1491
+ }
1492
+ }
1493
+
1321
1494
FBVColumn FBVSourceColumn(): {
1322
1495
FBVColumn fbvColumn;
1323
1496
@@ -1350,6 +1523,39 @@ List<FBVColumn> FBVSourceColumnList(): {
1350
1523
}
1351
1524
}
1352
1525
1526
+ FileOption FileDestinationOption(): {
1527
+ FileOption fileOption;
1528
+
1529
+ Token token;
1530
+ Token token2;
1531
+ Token token3;
1532
+ } {
1533
+ (
1534
+ ( token=<K_REPLACE> | token=<K_TRUNCATE> ) { fileOption = new FileOption(token.image); }
1535
+ | token=<K_WITH> token2=<K_COLUMN> token3=<K_NAMES> { fileOption = new FileOption(token.image + " " + token2.image + " " + token3.image); }
1536
+ | ( token=<K_ENCODING> | token=<K_NULL> | token=<K_BOOLEAN> ) "=" token2=<S_CHAR_LITERAL> { fileOption = new FileOption(token.image, new StringValue(token2.image)); }
1537
+ | (
1538
+ token=<K_ROW> token2=<K_SEPARATOR> "=" token3=<S_CHAR_LITERAL>
1539
+ | token=<K_COLUMN> ( token2=<K_SEPARATOR> | token2=<K_DELIMITER> ) "=" token3=<S_CHAR_LITERAL>
1540
+ )
1541
+ { fileOption = new FileOption(token.image + " " + token2.image, new StringValue(token3.image)); }
1542
+ | token=<K_DELIMIT> "=" ( token2=<K_ALWAYS> | token2=<K_NEVER> | token2=<K_AUTO> ) { fileOption = new FileOption(token.image, token2.image); }
1543
+ )
1544
+ {
1545
+ return fileOption;
1546
+ }
1547
+ }
1548
+
1549
+ List<FileOption> FileDestinationOptionList(): {
1550
+ List<FileOption> fileOptions = new ArrayList<FileOption>();
1551
+ FileOption fileOption;
1552
+ } {
1553
+ ( LOOKAHEAD(2) fileOption = FileDestinationOption() { fileOptions.add(fileOption); } )+
1554
+ {
1555
+ return fileOptions;
1556
+ }
1557
+ }
1558
+
1353
1559
FileOption FileSourceOption(): {
1354
1560
FileOption fileOption;
1355
1561
@@ -1387,6 +1593,50 @@ List<FileOption> FileSourceOptionList(): {
1387
1593
}
1388
1594
}
1389
1595
1596
+ FileDestination FileDestination() #FileDestination: {
1597
+ FileDestination fileDestination = new FileDestination();
1598
+ FileType fileType;
1599
+ List<ConnectionFileDefinition> connectionFileDefinitions;
1600
+ List<StringValue> files;
1601
+ List<CSVColumn> csvColumns;
1602
+ List<FBVColumn> fbvColumns;
1603
+ List<FileOption> fileOptions;
1604
+ CertificateVerification certificateVerification;
1605
+ } {
1606
+ (
1607
+ fileType = FileType() { fileDestination.setDestinationType(fileType); }
1608
+ connectionFileDefinitions = ConnectionFileDefinitionList() { fileDestination.setConnectionFileDefinitions(connectionFileDefinitions); }
1609
+ | <K_LOCAL> { fileDestination.setLocal(true); }
1610
+ [<K_SECURE> { fileDestination.setSecure(true); }]
1611
+
1612
+ fileType = FileType() { fileDestination.setDestinationType(fileType); }
1613
+ files = FileList()
1614
+ {
1615
+ connectionFileDefinitions = new ArrayList<ConnectionFileDefinition>();
1616
+ connectionFileDefinitions.add(new ConnectionFileDefinition(files));
1617
+ }
1618
+ )
1619
+ { fileDestination.setConnectionFileDefinitions(connectionFileDefinitions); }
1620
+
1621
+ [
1622
+ LOOKAHEAD(2)
1623
+ "("
1624
+ (
1625
+ csvColumns = CSVDestinationColumnList() { fileDestination.setCSVColumns(csvColumns); }
1626
+ | fbvColumns = FBVDestinationColumnList() { fileDestination.setFBVColumns(fbvColumns); }
1627
+ )
1628
+ ")"
1629
+ ]
1630
+
1631
+ [ LOOKAHEAD(2) fileOptions = FileDestinationOptionList() { fileDestination.setFileOptions(fileOptions); } ]
1632
+
1633
+ [ LOOKAHEAD(2) certificateVerification = CertificateVerification() { fileDestination.setCertificateVerification(certificateVerification); } ]
1634
+
1635
+ {
1636
+ return fileDestination;
1637
+ }
1638
+ }
1639
+
1390
1640
FileSource FileSource() #FileSource: {
1391
1641
FileSource fileSource = new FileSource();
1392
1642
FileType fileType;
@@ -1396,10 +1646,6 @@ FileSource FileSource() #FileSource: {
1396
1646
List<FBVColumn> fbvColumns;
1397
1647
List<FileOption> fileOptions;
1398
1648
CertificateVerification certificateVerification;
1399
-
1400
- Token token = null;
1401
- Token token2 = null;
1402
- Token token3 = null;
1403
1649
} {
1404
1650
(
1405
1651
fileType = FileType() { fileSource.setSourceType(fileType); }
@@ -1614,7 +1860,7 @@ RejectClause RejectClause(): {
1614
1860
| <K_UNLIMITED>
1615
1861
)
1616
1862
1617
- [ <K_ERRORS> { rejectClause.setErrors(true); } ]
1863
+ [ LOOKAHEAD(2) <K_ERRORS> { rejectClause.setErrors(true); } ]
1618
1864
1619
1865
{
1620
1866
return rejectClause;
0 commit comments