refactor: migrate antlr4 v4.12.0 to antlr4ts(4.9.0) (#106)

* build: ignore gen folder

* refactor: remove useless code

* fix: correct the Javascript usage in grammar

* refactor: move to antlr4ts

* fix: remove useless

* fix: update grammars for javascript target

* refactor: migrate to antlr4ts

* refactor: migrate to antlr4ts

* refactor: implements ParserErrorListener

* fix: rename the  start reserved word

* refactor: remove unused import

* refactor: migrate to antlr4ts

* test: update the expects of test cases

* refactor: migrate hive to antlr4ts

* refactor: update the incompatible syntax for antlr4ts

* refactor: migrate pgsql grammar to antlr4ts, increasing tests

* refactor: migrate the plsql to antlr4ts

* build: remove unused config

* build: migrate to antlr4ts

* build: migrate ts-jest to @swc/jest

* refactor: migrate to anltr4ts

* build: migrate ts-jest to @swc/jest
This commit is contained in:
Ziv 2023-05-30 14:44:03 +08:00 committed by GitHub
parent 793ff6ef0e
commit 34f64e6bea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
104 changed files with 436945 additions and 419757 deletions

View File

@ -65,13 +65,7 @@ jobs:
- name: Run Units Test - name: Run Units Test
run: | run: |
export NODE_OPTIONS="--max_old_space_size=4096" export NODE_OPTIONS="--max_old_space_size=4096"
npx jest test/utils yarn test
npx jest test/parser/flinksql
npx jest test/parser/spark
npx jest test/parser/generic
npx jest test/parser/hive
npx jest test/parser/pgsql
npx jest test/parser/plsql
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [setup] needs: [setup]

Binary file not shown.

View File

@ -18,11 +18,10 @@ const entry = [
function compile(language) { function compile(language) {
const cmd = ` const cmd = `
java -jar ${antlr4} antlr4ts
-Dlanguage=TypeScript
-visitor -visitor
-listener -listener
-o ${output}/${language} -Xexact-output-dir -o ${output}/${language}
${grammars}/${language}/*.g4 ${grammars}/${language}/*.g4
`.replace(/\n/g, ''); `.replace(/\n/g, '');
console.info('Executing:', cmd); console.info('Executing:', cmd);

View File

@ -100,7 +100,7 @@ module.exports = {
// notifyMode: "failure-change", // notifyMode: "failure-change",
// A preset that is used as a base for Jest's configuration // A preset that is used as a base for Jest's configuration
preset: "ts-jest/presets/js-with-ts-esm", // preset: "ts-jest/presets/js-with-ts-esm",
// Run tests from one or more projects // Run tests from one or more projects
// projects: undefined, // projects: undefined,
@ -171,19 +171,11 @@ module.exports = {
// A map from regular expressions to paths to transformers // A map from regular expressions to paths to transformers
transform: { transform: {
"\\.[jt]sx?$": [ "\\.[jt]sx?$": ['@swc/jest']
"ts-jest",
{
tsconfig: {
noUnusedLocals: false,
},
},
],
}, },
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
transformIgnorePatterns: ["/node_modules/.pnpm/(?!antlr4)"], extensionsToTreatAsEsm: ['.ts', '.tsx'],
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined, // unmockedModulePathPatterns: undefined,
@ -194,8 +186,5 @@ module.exports = {
// watchPathIgnorePatterns: [], // watchPathIgnorePatterns: [],
// Whether to use watchman for file crawling // Whether to use watchman for file crawling
// watchman: true, // watchman: true
moduleNameMapper: {
"^antlr4$": "<rootDir>/node_modules/antlr4/dist/antlr4.web.js",
},
}; };

View File

@ -28,6 +28,8 @@
"author": "dt-insight-front", "author": "dt-insight-front",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@swc/core": "^1.3.60",
"@swc/jest": "^0.2.26",
"@types/jest": "^29.5.1", "@types/jest": "^29.5.1",
"@types/node": "^18.15.11", "@types/node": "^18.15.11",
"@typescript-eslint/eslint-plugin": "^3.10.1", "@typescript-eslint/eslint-plugin": "^3.10.1",
@ -36,7 +38,6 @@
"eslint-config-google": "^0.14.0", "eslint-config-google": "^0.14.0",
"jest": "^29.5.0", "jest": "^29.5.0",
"standard-version": "^9.5.0", "standard-version": "^9.5.0",
"ts-jest": "^29.1.0",
"typescript": "^5.0.4", "typescript": "^5.0.4",
"yargs-parser": "^21.1.1" "yargs-parser": "^21.1.1"
}, },
@ -46,6 +47,7 @@
"registry": "https://registry.npmjs.org/" "registry": "https://registry.npmjs.org/"
}, },
"dependencies": { "dependencies": {
"antlr4": "^4.12.0" "antlr4ts": "^0.5.0-alpha.4",
"antlr4ts-cli": "^0.5.0-alpha.4"
} }
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,441 +1,553 @@
/**
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
lexer grammar HiveSqlLexer; lexer grammar HiveSqlLexer;
// Lexer rules options { caseInsensitive = true; }
T_ACTION : A C T I O N ;
T_ADD2 : A D D ;
T_ALL : A L L ;
T_ALLOCATE : A L L O C A T E ;
T_ALTER : A L T E R ;
T_AND : A N D ;
T_ANSI_NULLS : A N S I '_' N U L L S ;
T_ANSI_PADDING : A N S I '_' P A D D I N G ;
T_AS : A S ;
T_ASC : A S C ;
T_ASSOCIATE : A S S O C I A T E ;
T_AT : A T ;
T_AUTO_INCREMENT : A U T O '_' I N C R E M E N T ;
T_AVG : A V G ;
T_BATCHSIZE : B A T C H S I Z E ;
T_BEGIN : B E G I N ;
T_BETWEEN : B E T W E E N ;
T_BIGINT : B I G I N T ;
T_BINARY_DOUBLE : B I N A R Y '_' D O U B L E ;
T_BINARY_FLOAT : B I N A R Y '_' F L O A T ;
T_BINARY_INTEGER : B I N A R Y '_' I N T E G E R ;
T_BIT : B I T ;
T_BODY : B O D Y ;
T_BREAK : B R E A K ;
T_BY : B Y ;
T_BYTE : B Y T E ;
T_CALL : C A L L ;
T_CALLER : C A L L E R ;
T_CASCADE : C A S C A D E ;
T_CASE : C A S E ;
T_CASESPECIFIC : C A S E S P E C I F I C ;
T_CAST : C A S T ;
T_CHAR : C H A R ;
T_CHARACTER : C H A R A C T E R ;
T_CHARSET : C H A R S E T ;
T_CLIENT : C L I E N T ;
T_CLOSE : C L O S E ;
T_CLUSTERED : C L U S T E R E D;
T_CMP : C M P ;
T_COLLECT : C O L L E C T ;
T_COLLECTION : C O L L E C T I O N ;
T_COLUMN : C O L U M N ;
T_COMMENT : C O M M E N T;
T_CONSTANT : C O N S T A N T ;
T_COMMIT : C O M M I T ;
T_COMPRESS : C O M P R E S S ;
T_CONCAT : C O N C A T;
T_CONDITION : C O N D I T I O N ;
T_CONSTRAINT : C O N S T R A I N T ;
T_CONTINUE : C O N T I N U E ;
T_COPY : C O P Y ;
T_COUNT : C O U N T ;
T_COUNT_BIG : C O U N T '_' B I G;
T_CREATE : C R E A T E ;
T_CREATION : C R E A T I O N ;
T_CREATOR : C R E A T O R ;
T_CS : C S;
T_CURRENT : C U R R E N T ;
T_CURRENT_SCHEMA : C U R R E N T '_' S C H E M A ;
T_CURSOR : C U R S O R ;
T_DATABASE : D A T A B A S E ;
T_DATA : D A T A ;
T_DATE : D A T E ;
T_DATETIME : D A T E T I M E ;
T_DAY : D A Y ;
T_DAYS : D A Y S ;
T_DEC : D E C ;
T_DECIMAL : D E C I M A L ;
T_DECLARE : D E C L A R E ;
T_DEFAULT : D E F A U L T ;
T_DEFERRED : D E F E R R E D ;
T_DEFINED : D E F I N E D ;
T_DEFINER : D E F I N E R ;
T_DEFINITION : D E F I N I T I O N ;
T_DELETE : D E L E T E ;
T_DELIMITED : D E L I M I T E D ;
T_DELIMITER : D E L I M I T E R ;
T_DESC : D E S C ;
T_DESCRIBE : D E S C R I B E ;
T_DIAGNOSTICS : D I A G N O S T I C S ;
T_DIR : D I R ;
T_DIRECTORY : D I R E C T O R Y ;
T_DISTINCT : D I S T I N C T ;
T_DISTRIBUTE : D I S T R I B U T E ;
T_DO : D O ;
T_DOUBLE : D O U B L E ;
T_DROP : D R O P ;
T_DYNAMIC : D Y N A M I C ;
T_ELSE : E L S E ;
T_ELSEIF : E L S E I F ;
T_ELSIF : E L S I F ;
T_ENABLE : E N A B L E ;
T_END : E N D ;
T_ENGINE : E N G I N E ;
T_ESCAPED : E S C A P E D ;
T_EXCEPT : E X C E P T ;
T_EXEC : E X E C ;
T_EXECUTE : E X E C U T E ;
T_EXCEPTION : E X C E P T I O N ;
T_EXCLUSIVE : E X C L U S I V E ;
T_EXISTS : E X I S T S ;
T_EXIT : E X I T ;
T_FALLBACK : F A L L B A C K ;
T_FALSE : F A L S E ;
T_FETCH : F E T C H ;
T_FIELDS : F I E L D S ;
T_FILE : F I L E ;
T_FILES : F I L E S ;
T_FLOAT : F L O A T ;
T_FOR : F O R ;
T_FOREIGN : F O R E I G N ;
T_FORMAT : F O R M A T ;
T_FOUND : F O U N D ;
T_FROM : F R O M ;
T_FULL : F U L L ;
T_FUNCTION : F U N C T I O N ;
T_GET : G E T ;
T_GLOBAL : G L O B A L ;
T_GO : G O ;
T_GRANT : G R A N T ;
T_GROUP : G R O U P ;
T_HANDLER : H A N D L E R ;
T_HASH : H A S H ;
T_HAVING : H A V I N G ;
T_HDFS : H D F S ;
T_HIVE : H I V E ;
T_HOST : H O S T ;
T_IDENTITY : I D E N T I T Y ;
T_IF : I F ;
T_IGNORE : I G N O R E ;
T_IMMEDIATE : I M M E D I A T E ;
T_IN : I N ;
T_INCLUDE : I N C L U D E ;
T_INDEX : I N D E X ;
T_INITRANS : I N I T R A N S ;
T_INNER : I N N E R ;
T_INOUT : I N O U T;
T_INSERT : I N S E R T ;
T_INT : I N T ;
T_INT2 : I N T '2';
T_INT4 : I N T '4';
T_INT8 : I N T '8';
T_INTEGER : I N T E G E R ;
T_INTERSECT : I N T E R S E C T ;
T_INTERVAL : I N T E R V A L ;
T_INTO : I N T O ;
T_INVOKER : I N V O K E R ;
T_IS : I S ;
T_ISOPEN : I S O P E N ;
T_ITEMS : I T E M S ;
T_JOIN : J O I N ;
T_KEEP : K E E P;
T_KEY : K E Y ;
T_KEYS : K E Y S ;
T_LANGUAGE : L A N G U A G E ;
T_LEAVE : L E A V E ;
T_LEFT : L E F T ;
T_LIKE : L I K E ;
T_LIMIT : L I M I T ;
T_LINES : L I N E S ;
T_LOCAL : L O C A L ;
T_LOCATION : L O C A T I O N ;
T_LOCATOR : L O C A T O R ;
T_LOCATORS : L O C A T O R S ;
T_LOCKS : L O C K S ;
T_LOG : L O G ;
T_LOGGED : L O G G E D ;
T_LOGGING : L O G G I N G ;
T_LOOP : L O O P ;
T_MAP : M A P ;
T_MATCHED : M A T C H E D ;
T_MAX : M A X ;
T_MAXTRANS : M A X T R A N S ;
T_MERGE : M E R G E ;
T_MESSAGE_TEXT : M E S S A G E '_' T E X T ;
T_MICROSECOND : M I C R O S E C O N D ;
T_MICROSECONDS : M I C R O S E C O N D S;
T_MIN : M I N ;
T_MULTISET : M U L T I S E T ;
T_NCHAR : N C H A R ;
T_NEW : N E W ;
T_NVARCHAR : N V A R C H A R ;
T_NO : N O ;
T_NOCOUNT : N O C O U N T ;
T_NOCOMPRESS : N O C O M P R E S S ;
T_NOLOGGING : N O L O G G I N G ;
T_NONE : N O N E ;
T_NOT : N O T ;
T_NOTFOUND : N O T F O U N D ;
T_NULL : N U L L ;
T_NUMERIC : N U M E R I C ;
T_NUMBER : N U M B E R ;
T_OBJECT : O B J E C T ;
T_OFF : O F F ;
T_ON : O N ;
T_ONLY : O N L Y ;
T_OPEN : O P E N ;
T_OR : O R ;
T_ORDER : O R D E R;
T_OUT : O U T ;
T_OUTER : O U T E R ;
T_OVER : O V E R ;
T_OVERWRITE : O V E R W R I T E ;
T_OWNER : O W N E R ;
T_PACKAGE : P A C K A G E ;
T_PARTITION : P A R T I T I O N ;
T_PCTFREE : P C T F R E E ;
T_PCTUSED : P C T U S E D ;
T_PLS_INTEGER : P L S '_' I N T E G E R ;
T_PRECISION : P R E C I S I O N ;
T_PRESERVE : P R E S E R V E ;
T_PRIMARY : P R I M A R Y ;
T_PRINT : P R I N T ;
T_PROC : P R O C ;
T_PROCEDURE : P R O C E D U R E ;
T_QUALIFY : Q U A L I F Y ;
T_QUERY_BAND : Q U E R Y '_' B A N D ;
T_QUIT : Q U I T ;
T_QUOTED_IDENTIFIER : Q U O T E D '_' I D E N T I F I E R ;
T_RAISE : R A I S E ;
T_REAL : R E A L ;
T_REFERENCES : R E F E R E N C E S ;
T_REGEXP : R E G E X P ;
T_REPLACE : R E P L A C E ;
T_RESIGNAL : R E S I G N A L ;
T_RESTRICT : R E S T R I C T ;
T_RESULT : R E S U L T ;
T_RESULT_SET_LOCATOR : R E S U L T '_' S E T '_' L O C A T O R ;
T_RETURN : R E T U R N ;
T_RETURNS : R E T U R N S ;
T_REVERSE : R E V E R S E ;
T_RIGHT : R I G H T ;
T_RLIKE : R L I K E ;
T_ROLE : R O L E ;
T_ROLLBACK : R O L L B A C K ;
T_ROW : R O W ;
T_ROWS : R O W S ;
T_ROWTYPE : R O W T Y P E ;
T_ROW_COUNT : R O W '_' C O U N T ;
T_RR : R R;
T_RS : R S ;
T_PWD : P W D ;
T_TRIM : T R I M ;
T_SCHEMA : S C H E M A ;
T_SECOND : S E C O N D ;
T_SECONDS : S E C O N D S;
T_SECURITY : S E C U R I T Y ;
T_SEGMENT : S E G M E N T ;
T_SEL : S E L ;
T_SELECT : S E L E C T ;
T_SET : S E T ;
T_SESSION : S E S S I O N ;
T_SESSIONS : S E S S I O N S ;
T_SETS : S E T S;
T_SHARE : S H A R E ;
T_SIGNAL : S I G N A L ;
T_SIMPLE_DOUBLE : S I M P L E '_' D O U B L E ;
T_SIMPLE_FLOAT : S I M P L E '_' F L O A T ;
T_SIMPLE_INTEGER : S I M P L E '_' I N T E G E R ;
T_SMALLDATETIME : S M A L L D A T E T I M E ;
T_SMALLINT : S M A L L I N T ;
T_SQL : S Q L ;
T_SQLEXCEPTION : S Q L E X C E P T I O N ;
T_SQLINSERT : S Q L I N S E R T ;
T_SQLSTATE : S Q L S T A T E ;
T_SQLWARNING : S Q L W A R N I N G ;
T_STATS : S T A T S ;
T_STATISTICS : S T A T I S T I C S ;
T_STEP : S T E P ;
T_STORAGE : S T O R A G E ;
T_STORED : S T O R E D ;
T_STRING : S T R I N G ;
T_SUBDIR : S U B D I R ;
T_SUBSTRING : S U B S T R I N G ;
T_SUM : S U M ;
T_SUMMARY : S U M M A R Y ;
T_SYS_REFCURSOR : S Y S '_' R E F C U R S O R ;
T_TABLE : T A B L E ;
T_TABLESPACE : T A B L E S P A C E ;
T_TEMPORARY : T E M P O R A R Y ;
T_TERMINATED : T E R M I N A T E D ;
T_TEXTIMAGE_ON : T E X T I M A G E '_' O N ;
T_THEN : T H E N ;
T_TIMESTAMP : T I M E S T A M P ;
T_TINYINT : T I N Y I N T ;
T_TITLE : T I T L E ;
T_TO : T O ;
T_TOP : T O P ;
T_TRANSACTION : T R A N S A C T I O N ;
T_TRUE : T R U E ;
T_TRUNCATE : T R U N C A T E;
T_TYPE : T Y P E ;
T_UNION : U N I O N ;
T_UNIQUE : U N I Q U E ;
T_UPDATE : U P D A T E ;
T_UR : U R ;
T_USE : U S E ;
T_USING : U S I N G ;
T_VALUE : V A L U E ;
T_VALUES : V A L U E S ;
T_VAR : V A R ;
T_VARCHAR : V A R C H A R ;
T_VARCHAR2 : V A R C H A R '2' ;
T_VARYING : V A R Y I N G ;
T_VOLATILE : V O L A T I L E ;
T_WHEN : W H E N ;
T_WHERE : W H E R E ;
T_WHILE : W H I L E ;
T_WITH : W I T H ;
T_WITHOUT : W I T H O U T ;
T_WORK : W O R K ;
T_XACT_ABORT : X A C T '_' A B O R T ;
T_XML : X M L ;
T_YES : Y E S ;
// Functions with specific syntax // Keywords
T_ACTIVITY_COUNT : A C T I V I T Y '_' C O U N T ; KW_ABORT : 'ABORT';
T_CUME_DIST : C U M E '_' D I S T ; KW_ACTIVATE : 'ACTIVATE';
T_CURRENT_DATE : C U R R E N T '_' D A T E ; KW_ACTIVE : 'ACTIVE';
T_CURRENT_TIMESTAMP : C U R R E N T '_' T I M E S T A M P ; KW_ADD : 'ADD';
T_CURRENT_USER : C U R R E N T '_' U S E R ; KW_ADMIN : 'ADMIN';
T_DENSE_RANK : D E N S E '_' R A N K ; KW_AFTER : 'AFTER';
T_FIRST_VALUE : F I R S T '_' V A L U E; KW_ALL : 'ALL';
T_LAG : L A G ; KW_ALLOC_FRACTION : 'ALLOC_FRACTION';
T_LAST_VALUE : L A S T '_' V A L U E; KW_ALTER : 'ALTER';
T_LEAD : L E A D ; KW_ANALYZE : 'ANALYZE';
T_MAX_PART_STRING : M A X '_' P A R T '_' S T R I N G ; KW_AND : 'AND';
T_MIN_PART_STRING : M I N '_' P A R T '_' S T R I N G ; KW_ANTI : 'ANTI';
T_MAX_PART_INT : M A X '_' P A R T '_' I N T ; KW_ANY : 'ANY';
T_MIN_PART_INT : M I N '_' P A R T '_' I N T ; KW_APPLICATION : 'APPLICATION';
T_MAX_PART_DATE : M A X '_' P A R T '_' D A T E ; KW_ARCHIVE : 'ARCHIVE';
T_MIN_PART_DATE : M I N '_' P A R T '_' D A T E ; KW_ARRAY : 'ARRAY';
T_PART_COUNT : P A R T '_' C O U N T ; KW_AS : 'AS';
T_PART_LOC : P A R T '_' L O C ; KW_ASC : 'ASC';
T_RANK : R A N K ; KW_AST : 'AST';
T_ROW_NUMBER : R O W '_' N U M B E R; KW_AT : 'AT';
T_STDEV : S T D E V ; KW_AUTHORIZATION : 'AUTHORIZATION';
T_SYSDATE : S Y S D A T E ; KW_AUTOCOMMIT : 'AUTOCOMMIT';
T_VARIANCE : V A R I A N C E ; KW_BATCH : 'KW_BATCH';
T_USER : U S E R; KW_BEFORE : 'BEFORE';
KW_BETWEEN : 'BETWEEN';
KW_BIGINT : 'BIGINT';
KW_BINARY : 'BINARY';
KW_BOOLEAN : 'BOOLEAN';
KW_BOTH : 'BOTH';
KW_BUCKET : 'BUCKET';
KW_BUCKETS : 'BUCKETS';
KW_BY : 'BY';
KW_CACHE : 'CACHE';
KW_CASCADE : 'CASCADE';
KW_CASE : 'CASE';
KW_CAST : 'CAST';
KW_CBO : 'CBO';
KW_CHANGE : 'CHANGE';
KW_CHAR : 'CHAR';
KW_CHECK : 'CHECK';
KW_CLUSTER : 'CLUSTER';
KW_CLUSTERED : 'CLUSTERED';
KW_CLUSTERSTATUS : 'CLUSTERSTATUS';
KW_COLLECTION : 'COLLECTION';
KW_COLUMN : 'COLUMN';
KW_COLUMNS : 'COLUMNS';
KW_COMMENT : 'COMMENT';
KW_COMMIT : 'COMMIT';
KW_COMPACT : 'COMPACT';
KW_COMPACTIONS : 'COMPACTIONS';
KW_COMPACT_ID : 'COMPACTIONID';
KW_COMPUTE : 'COMPUTE';
KW_CONCATENATE : 'CONCATENATE';
KW_CONF : 'CONF';
KW_CONSTRAINT : 'CONSTRAINT';
KW_CONTINUE : 'CONTINUE';
KW_COST : 'COST';
KW_CREATE : 'CREATE';
KW_CRON : 'CRON';
KW_CROSS : 'CROSS';
KW_CUBE : 'CUBE';
KW_CURRENT : 'CURRENT';
KW_CURRENT_DATE : 'CURRENT_DATE';
KW_CURRENT_TIMESTAMP : 'CURRENT_TIMESTAMP';
KW_CURSOR : 'CURSOR';
KW_DATA : 'DATA';
KW_DATABASE : 'DATABASE';
KW_DATABASES : 'DATABASES';
KW_DATACONNECTOR : 'CONNECTOR';
KW_DATACONNECTORS : 'CONNECTORS';
KW_DATE : 'DATE';
KW_DATETIME : 'DATETIME';
KW_DAY : 'DAY' 'S'?;
KW_DAYOFWEEK : 'KW_DAYOFWEEK';
KW_DBPROPERTIES : 'DBPROPERTIES';
KW_DCPROPERTIES : 'DCPROPERTIES';
KW_DDL : 'DDL';
KW_DEBUG : 'DEBUG';
KW_DECIMAL : 'DEC' 'IMAL'? | 'NUMERIC';
KW_DEFAULT : 'DEFAULT';
KW_DEFERRED : 'DEFERRED';
KW_DEFINED : 'DEFINED';
KW_DELETE : 'DELETE';
KW_DELIMITED : 'DELIMITED';
KW_DEPENDENCY : 'DEPENDENCY';
KW_DESC : 'DESC';
KW_DESCRIBE : 'DESCRIBE';
KW_DETAIL : 'DETAIL';
KW_DIRECTORIES : 'DIRECTORIES';
KW_DIRECTORY : 'DIRECTORY';
KW_DISABLE : 'DISABLE' 'D'?;
KW_DISTINCT : 'DISTINCT';
KW_DISTRIBUTE : 'DISTRIBUTE';
KW_DISTRIBUTED : 'DISTRIBUTED';
KW_DO : 'DO';
KW_DOUBLE : 'DOUBLE';
KW_DOW : 'DAYOFWEEK';
KW_DROP : 'DROP';
KW_DUMP : 'DUMP';
KW_ELEM_TYPE : '$ELEM$';
KW_ELSE : 'ELSE';
KW_ENABLE : 'ENABLE' 'D'?;
KW_END : 'END';
KW_ENFORCED : 'ENFORCED';
KW_ESCAPED : 'ESCAPED';
KW_EVERY : 'EVERY';
KW_EXCEPT : 'EXCEPT';
KW_EXCHANGE : 'EXCHANGE';
KW_EXCLUSIVE : 'EXCLUSIVE';
KW_EXECUTE : 'EXECUTE';
KW_EXECUTED : 'EXECUTED';
KW_EXISTS : 'EXISTS';
KW_EXPIRE_SNAPSHOTS : 'EXPIRE_SNAPSHOTS';
KW_EXPLAIN : 'EXPLAIN';
KW_EXPORT : 'EXPORT';
KW_EXPRESSION : 'EXPRESSION';
KW_EXTENDED : 'EXTENDED';
KW_EXTERNAL : 'EXTERNAL';
KW_EXTRACT : 'EXTRACT';
KW_FALSE : 'FALSE';
KW_FETCH : 'FETCH';
KW_FIELDS : 'FIELDS';
KW_FILE : 'FILE';
KW_FILEFORMAT : 'FILEFORMAT';
KW_FIRST : 'FIRST';
KW_FLOAT : 'FLOAT';
KW_FLOOR : 'FLOOR';
KW_FOLLOWING : 'FOLLOWING';
KW_FOR : 'FOR';
KW_FORCE : 'FORCE';
KW_FOREIGN : 'FOREIGN';
KW_FORMAT : 'FORMAT';
KW_FORMATTED : 'FORMATTED';
KW_FROM : 'FROM';
KW_FULL : 'FULL';
KW_FUNCTION : 'FUNCTION';
KW_FUNCTIONS : 'FUNCTIONS';
KW_GRANT : 'GRANT';
KW_GROUP : 'GROUP';
KW_GROUPING : 'GROUPING';
KW_HAVING : 'HAVING';
KW_HOLD_DDLTIME : 'KW_HOLD_DDLTIME';
KW_HOUR : 'HOUR' 'S'?;
KW_IDXPROPERTIES : 'IDXPROPERTIES';
KW_IF : 'IF';
KW_IGNORE : 'IGNORE';
KW_IMPORT : 'IMPORT';
KW_IN : 'IN';
KW_INDEX : 'INDEX';
KW_INDEXES : 'INDEXES';
KW_INNER : 'INNER';
KW_INPATH : 'INPATH';
KW_INPUTDRIVER : 'INPUTDRIVER';
KW_INPUTFORMAT : 'INPUTFORMAT';
KW_INSERT : 'INSERT';
KW_INT : 'INT' 'EGER'?;
KW_INTERSECT : 'INTERSECT';
KW_INTERVAL : 'INTERVAL';
KW_INTO : 'INTO';
KW_IS : 'IS';
KW_ISOLATION : 'ISOLATION';
KW_ITEMS : 'ITEMS';
KW_JAR : 'JAR';
KW_JOIN : 'JOIN';
KW_JOINCOST : 'JOINCOST';
KW_KEY : 'KEY';
KW_KEYS : 'KEYS';
KW_KEY_TYPE : '$KEY$';
KW_KILL : 'KILL';
KW_LAST : 'LAST';
KW_LATERAL : 'LATERAL';
KW_LEADING : 'LEADING';
KW_LEFT : 'LEFT';
KW_LESS : 'LESS';
KW_LEVEL : 'LEVEL';
KW_LIKE : 'LIKE';
KW_LIMIT : 'LIMIT';
KW_LINES : 'LINES';
KW_LOAD : 'LOAD';
KW_LOCAL : 'LOCAL';
KW_LOCATION : 'LOCATION';
KW_LOCK : 'LOCK';
KW_LOCKS : 'LOCKS';
KW_LOGICAL : 'LOGICAL';
KW_LONG : 'LONG';
KW_MACRO : 'MACRO';
KW_MANAGED : 'MANAGED';
KW_MANAGEDLOCATION : 'MANAGEDLOCATION';
KW_MANAGEMENT : 'MANAGEMENT';
KW_MAP : 'MAP';
KW_MAPJOIN : 'MAPJOIN';
KW_MAPPING : 'MAPPING';
KW_MATCHED : 'MATCHED';
KW_MATERIALIZED : 'MATERIALIZED';
KW_MERGE : 'MERGE';
KW_METADATA : 'METADATA';
KW_MINUS : 'MINUS';
KW_MINUTE : 'MINUTE' 'S'?;
KW_MONTH : 'MONTH' 'S'?;
KW_MORE : 'MORE';
KW_MOVE : 'MOVE';
KW_MSCK : 'MSCK';
KW_NONE : 'NONE';
KW_NORELY : 'NORELY';
KW_NOSCAN : 'NOSCAN';
KW_NOT : 'NOT' | '!';
KW_NOVALIDATE : 'NOVALIDATE';
KW_NO_DROP : 'KW_NO_DROP';
KW_NULL : 'NULL';
KW_NULLS : 'NULLS';
KW_OF : 'OF';
KW_OFFLINE : 'KW_OFFLINE';
KW_OFFSET : 'OFFSET';
KW_ON : 'ON';
KW_ONLY : 'ONLY';
KW_OPERATOR : 'OPERATOR';
KW_OPTION : 'OPTION';
KW_OR : 'OR';
KW_ORDER : 'ORDER';
KW_OUT : 'OUT';
KW_OUTER : 'OUTER';
KW_OUTPUTDRIVER : 'OUTPUTDRIVER';
KW_OUTPUTFORMAT : 'OUTPUTFORMAT';
KW_OVER : 'OVER';
KW_OVERWRITE : 'OVERWRITE';
KW_OWNER : 'OWNER';
KW_PARTITION : 'PARTITION';
KW_PARTITIONED : 'PARTITIONED';
KW_PARTITIONS : 'PARTITIONS';
KW_PATH : 'PATH';
KW_PERCENT : 'PERCENT';
KW_PKFK_JOIN : 'PKFK_JOIN';
KW_PLAN : 'PLAN';
KW_PLANS : 'PLANS';
KW_PLUS : 'PLUS';
KW_POOL : 'POOL';
KW_PRECEDING : 'PRECEDING';
KW_PRECISION : 'PRECISION';
KW_PREPARE : 'PREPARE';
KW_PRESERVE : 'PRESERVE';
KW_PRIMARY : 'PRIMARY';
KW_PRINCIPALS : 'PRINCIPALS';
KW_PROCEDURE : 'PROCEDURE';
KW_PROTECTION : 'KW_PROTECTION';
KW_PURGE : 'PURGE';
KW_QUALIFY : 'QUALIFY';
KW_QUARTER : 'QUARTER';
KW_QUERY : 'QUERY';
KW_QUERY_PARALLELISM : 'QUERY_PARALLELISM';
KW_RANGE : 'RANGE';
KW_READ : 'READ';
KW_READONLY : 'KW_READONLY';
KW_READS : 'READS';
KW_REAL : 'REAL';
KW_REBUILD : 'REBUILD';
KW_RECORDREADER : 'RECORDREADER';
KW_RECORDWRITER : 'RECORDWRITER';
KW_REDUCE : 'REDUCE';
KW_REFERENCES : 'REFERENCES';
KW_REGEXP : 'REGEXP';
KW_RELOAD : 'RELOAD';
KW_RELY : 'RELY';
KW_REMOTE : 'REMOTE';
KW_RENAME : 'RENAME';
KW_REOPTIMIZATION : 'REOPTIMIZATION';
KW_REPAIR : 'REPAIR';
KW_REPL : 'REPL';
KW_REPLACE : 'REPLACE';
KW_REPLICATION : 'REPLICATION';
KW_RESOURCE : 'RESOURCE';
KW_RESPECT : 'RESPECT';
KW_RESTRICT : 'RESTRICT';
KW_REVOKE : 'REVOKE';
KW_REWRITE : 'REWRITE';
KW_RIGHT : 'RIGHT';
KW_RLIKE : 'RLIKE';
KW_ROLE : 'ROLE';
KW_ROLES : 'ROLES';
KW_ROLLBACK : 'ROLLBACK';
KW_ROLLUP : 'ROLLUP';
KW_ROW : 'ROW';
KW_ROWS : 'ROWS';
KW_SCHEDULED : 'SCHEDULED';
KW_SCHEDULING_POLICY : 'SCHEDULING_POLICY';
KW_SCHEMA : 'SCHEMA';
KW_SCHEMAS : 'SCHEMAS';
KW_SECOND : 'SECOND' 'S'?;
KW_SELECT : 'SELECT';
KW_SEMI : 'SEMI';
KW_SERDE : 'SERDE';
KW_SERDEPROPERTIES : 'SERDEPROPERTIES';
KW_SERVER : 'SERVER';
KW_SET : 'SET';
KW_SETS : 'SETS';
KW_SET_CURRENT_SNAPSHOT : 'SET_CURRENT_SNAPSHOT';
KW_SHARED : 'SHARED';
KW_SHOW : 'SHOW';
KW_SHOW_DATABASE : 'SHOW_DATABASE';
KW_SKEWED : 'SKEWED';
KW_SMALLINT : 'SMALLINT';
KW_SNAPSHOT : 'SNAPSHOT';
KW_SOME : 'SOME';
KW_SORT : 'SORT';
KW_SORTED : 'SORTED';
KW_SPEC : 'SPEC';
KW_SSL : 'SSL';
KW_START : 'START';
KW_STATISTICS : 'STATISTICS';
KW_STATUS : 'STATUS';
KW_STORED : 'STORED';
KW_STREAMTABLE : 'STREAMTABLE';
KW_STRING : 'STRING';
KW_STRUCT : 'STRUCT';
KW_SUMMARY : 'SUMMARY';
KW_SYNC : 'SYNC';
KW_SYSTEM_TIME : 'SYSTEM_TIME';
KW_SYSTEM_VERSION : 'SYSTEM_VERSION';
KW_TABLE : 'TABLE';
KW_TABLES : 'TABLES';
KW_TABLESAMPLE : 'TABLESAMPLE';
KW_TBLPROPERTIES : 'TBLPROPERTIES';
KW_TEMPORARY : 'TEMPORARY';
KW_TERMINATED : 'TERMINATED';
KW_THEN : 'THEN';
KW_TIME : 'TIME';
KW_TIMESTAMP : 'TIMESTAMP';
KW_TIMESTAMPLOCALTZ : 'TIMESTAMPLOCALTZ';
KW_TIMESTAMPTZ : 'KW_TIMESTAMPTZ';
KW_TINYINT : 'TINYINT';
KW_TO : 'TO';
KW_TOUCH : 'TOUCH';
KW_TRAILING : 'TRAILING';
KW_TRANSACTION : 'TRANSACTION';
KW_TRANSACTIONAL : 'TRANSACTIONAL';
KW_TRANSACTIONS : 'TRANSACTIONS';
KW_TRANSFORM : 'TRANSFORM';
KW_TRIGGER : 'TRIGGER';
KW_TRIM : 'TRIM';
KW_TRUE : 'TRUE';
KW_TRUNCATE : 'TRUNCATE';
KW_TYPE : 'TYPE';
KW_UNARCHIVE : 'UNARCHIVE';
KW_UNBOUNDED : 'UNBOUNDED';
KW_UNDO : 'UNDO';
KW_UNION : 'UNION';
KW_UNIONTYPE : 'UNIONTYPE';
KW_UNIQUE : 'UNIQUE';
KW_UNIQUEJOIN : 'UNIQUEJOIN';
KW_UNKNOWN : 'UNKNOWN';
KW_UNLOCK : 'UNLOCK';
KW_UNMANAGED : 'UNMANAGED';
KW_UNSET : 'UNSET';
KW_UNSIGNED : 'UNSIGNED';
KW_UPDATE : 'UPDATE';
KW_URI : 'URI';
KW_URL : 'URL';
KW_USE : 'USE';
KW_USER : 'USER';
KW_USING : 'USING';
KW_UTC : 'UTC';
KW_UTCTIMESTAMP : 'UTC_TMESTAMP';
KW_VALIDATE : 'VALIDATE';
KW_VALUES : 'VALUES';
KW_VALUE_TYPE : '$VALUE$';
KW_VARCHAR : 'VARCHAR';
KW_VECTORIZATION : 'VECTORIZATION';
KW_VIEW : 'VIEW';
KW_VIEWS : 'VIEWS';
KW_WAIT : 'WAIT';
KW_WEEK : 'WEEK' 'S'?;
KW_WHEN : 'WHEN';
KW_WHERE : 'WHERE';
KW_WHILE : 'WHILE';
KW_WINDOW : 'WINDOW';
KW_WITH : 'WITH';
KW_WITHIN : 'WITHIN';
KW_WORK : 'WORK';
KW_WORKLOAD : 'WORKLOAD';
KW_WRITE : 'WRITE';
KW_YEAR : 'YEAR' 'S'?;
KW_ZONE : 'ZONE';
T_ADD : '+' ; // Operators
T_COLON : ':' ; // NOTE: if you add a new function/operator, add it to sysFuncNames so that describe function _FUNC_ will work.
T_COMMA : ',' ; DOT : '.'; // generated as a part of Number rule
T_PIPE : '||' ; COLON : ':' ;
T_DIV : '/' ; COMMA : ',' ;
T_DOT : '.' ; SEMICOLON : ';' ;
T_DOT2 : '..' ;
T_EQUAL : '=' ;
T_EQUAL2 : '==' ;
T_SHARP : '#' ;
T_NOTE : '!' ;
T_NOTEQUAL : '<>' ;
T_NOTEQUAL2 : '!=' ;
T_GREATER : '>' ;
T_GREATEREQUAL : '>=' ;
T_LESS : '<' ;
T_LESSEQUAL : '<=' ;
T_MUL : '*' ;
T_PRECENT : '%' ;
T_CALLS : '@' ;
T_OPEN_B : '{' ;
T_OPEN_P : '(' ;
T_OPEN_SB : '[' ;
T_CLOSE_B : '}' ;
T_CLOSE_P : ')' ;
T_CLOSE_SB : ']' ;
T_SEMICOLON : ';' ;
T_SUB : '-' ;
L_ID : L_ID_PART // Identifier LPAREN : '(' ;
; RPAREN : ')' ;
L_S_STRING : '\'' (('\'' '\'') | ('\\' '\'') | ~('\''))* '\'' // Single quoted string literal LSQUARE : '[' ;
; RSQUARE : ']' ;
L_D_STRING : '"' (L_STR_ESC_D | .)*? '"' // Double quoted string literal LCURLY : '{';
; RCURLY : '}';
L_INT : L_DIGIT+ ; // Integer
L_DEC : L_DIGIT+ '.' ~'.' L_DIGIT* // Decimal number
| '.' L_DIGIT+
;
L_WS : L_BLANK+ -> skip ; // Whitespace
L_M_COMMENT : '/*' .*? '*/' -> channel(HIDDEN) ; // Multiline comment
L_S_COMMENT : ('--' | '//') .*? '\r'? '\n' -> channel(HIDDEN) ; // Single line comment
L_FILE : ([a-zA-Z] ':' '\\'?)? L_ID ('\\' L_ID)* // File path (a/b/c Linux path causes conflicts with division operator and handled at parser level) EQUAL : '=' | '==';
EQUAL_NS : '<=>';
NOTEQUAL : '<>' | '!=';
LESSTHANOREQUALTO : '<=';
LESSTHAN : '<';
GREATERTHANOREQUALTO : '>=';
GREATERTHAN : '>';
DIVIDE : '/';
PLUS : '+';
MINUS : '-';
STAR : '*';
MOD : '%';
DIV : 'DIV';
AMPERSAND : '&';
TILDE : '~';
BITWISEOR : '|';
CONCATENATE : '||';
BITWISEXOR : '^';
QUESTION : '?';
DOLLAR : '$';
// LITERALS
StringLiteral
: ( '\'' ( ~('\''|'\\') | ('\\' .) )* '\''
| '"' ( ~('"'|'\\') | ('\\' .) )* '"'
)+
; ;
L_LABEL : ([a-zA-Z] | L_DIGIT | '_')* ':' CharSetLiteral
: StringLiteral
| '0' 'X' (HexDigit | Digit)+
;
IntegralLiteral
: Digit+ ('L' | 'S' | 'Y')
;
NumberLiteral
: Number ('B'? 'D')
;
ByteLengthLiteral
: Digit+ [BKMG]
;
Number
: Digit+ (DOT Digit* Exponent? | Exponent)?
;
/*
An Identifier can be:
- tableName
- columnName
- select expr alias
- lateral view aliases
- database name
- view name
- subquery alias
- function name
- ptf argument identifier
- index name
- property name for: db,tbl,partition...
- fileFormat
- role name
- privilege name
- principal name
- macro name
- hint name
- window name
*/
Identifier
: (Letter | Digit) (Letter | Digit | '_')*
| QuotedIdentifier
| '`' RegexComponent+ '`'
; ;
fragment fragment
L_ID_PART : QuotedIdentifier
[a-zA-Z] ([a-zA-Z] | L_DIGIT | '_')* // Identifier part : '`' ('``' | ~'`')* '`'
| '$' '{' .*? '}'
| ('_' | '@' | ':' | '#' | '$') ([a-zA-Z] | L_DIGIT | '_' | '@' | ':' | '#' | '$')+ // (at least one char must follow special char)
| '"' .*? '"' // Quoted identifiers
| '[' .*? ']'
| '`' .*? '`'
;
fragment
L_STR_ESC_D : // Double quoted string escape sequence
'""' | '\\"'
;
fragment
L_DIGIT : [0-9] // Digit
;
fragment
L_BLANK : (' ' | '\t' | '\r' | '\n')
; ;
// Support case-insensitive keywords and allowing case-sensitive identifiers fragment
fragment A : ('a'|'A') ; Letter
fragment B : ('b'|'B') ; : 'A'..'Z'
fragment C : ('c'|'C') ; ;
fragment D : ('d'|'D') ;
fragment E : ('e'|'E') ; fragment
fragment F : ('f'|'F') ; HexDigit
fragment G : ('g'|'G') ; : 'A'..'F'
fragment H : ('h'|'H') ; ;
fragment I : ('i'|'I') ;
fragment J : ('j'|'J') ; fragment
fragment K : ('k'|'K') ; Digit
fragment L : ('l'|'L') ; : '0'..'9'
fragment M : ('m'|'M') ; ;
fragment N : ('n'|'N') ;
fragment O : ('o'|'O') ; fragment
fragment P : ('p'|'P') ; Exponent
fragment Q : ('q'|'Q') ; : ('E') ( PLUS|MINUS )? (Digit)+
fragment R : ('r'|'R') ; ;
fragment S : ('s'|'S') ;
fragment T : ('t'|'T') ; fragment
fragment U : ('u'|'U') ; RegexComponent
fragment V : ('v'|'V') ; : 'A'..'Z' | '0'..'9' | '_'
fragment W : ('w'|'W') ; | PLUS | STAR | QUESTION | MINUS | DOT
fragment X : ('x'|'X') ; | LPAREN | RPAREN | LSQUARE | RSQUARE | LCURLY | RCURLY
fragment Y : ('y'|'Y') ; | BITWISEXOR | BITWISEOR | DOLLAR | '!'
fragment Z : ('z'|'Z') ; ;
CharSetName
: '_' (Letter | Digit | '_' | '-' | '.' | ':')+
;
WHITE_SPACE
: (' '|'\r'|'\t'|'\n') -> channel(HIDDEN)
;
LINE_COMMENT
: '--' ~('\n' | '\r')* -> channel(HIDDEN)
;
QUERY_HINT
: SHOW_HINT
| HIDDEN_HINT
;
SHOW_HINT
: '/*+' (QUERY_HINT | .)*? '*/' ->channel(HIDDEN)
;
HIDDEN_HINT
: '/*' (QUERY_HINT | .)*? '*/' -> channel(HIDDEN)
;

View File

@ -0,0 +1,6 @@
# HiveSQL (V4)
## Sources
<https://github.com/antlr/grammars-v4/blob/master/sql/hive/v4/README.md>
<https://github.com/apache/hive/tree/master/parser/src/java/org/apache/hadoop/hive/ql/parse>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -22,15 +22,21 @@ lexer grammar PlSqlLexer;
options { options {
superClass=PlSqlBaseLexer; superClass=PlSqlBaseLexer;
caseInsensitive = true;
}
@lexer::header {
import PlSqlBaseLexer from "./PlSqlBaseLexer";
} }
ABORT: 'ABORT'; ABORT: 'ABORT';
ABS: 'ABS'; ABS: 'ABS';
ABSENT: 'ABSENT';
ACCESS: 'ACCESS'; ACCESS: 'ACCESS';
ACCESSED: 'ACCESSED'; ACCESSED: 'ACCESSED';
ACCOUNT: 'ACCOUNT'; ACCOUNT: 'ACCOUNT';
ACL: 'ACL'; ACL: 'ACL';
ACOS: 'ACOS'; ACOS: 'ACOS';
ACROSS: 'ACROSS';
ACTION: 'ACTION'; ACTION: 'ACTION';
ACTIONS: 'ACTIONS'; ACTIONS: 'ACTIONS';
ACTIVATE: 'ACTIVATE'; ACTIVATE: 'ACTIVATE';
@ -63,8 +69,11 @@ ALLOCATE: 'ALLOCATE';
ALLOW: 'ALLOW'; ALLOW: 'ALLOW';
ALL_ROWS: 'ALL_ROWS'; ALL_ROWS: 'ALL_ROWS';
ALTER: 'ALTER'; ALTER: 'ALTER';
ALTERNATE: 'ALTERNATE';
ALWAYS: 'ALWAYS'; ALWAYS: 'ALWAYS';
ANALYTIC: 'ANALYTIC';
ANALYZE: 'ANALYZE'; ANALYZE: 'ANALYZE';
ANCESTOR: 'ANCESTOR';
ANCILLARY: 'ANCILLARY'; ANCILLARY: 'ANCILLARY';
AND: 'AND'; AND: 'AND';
AND_EQUAL: 'AND_EQUAL'; AND_EQUAL: 'AND_EQUAL';
@ -116,7 +125,9 @@ AUTO_REOPTIMIZE: 'AUTO_REOPTIMIZE';
AVAILABILITY: 'AVAILABILITY'; AVAILABILITY: 'AVAILABILITY';
AVRO: 'AVRO'; AVRO: 'AVRO';
BACKGROUND: 'BACKGROUND'; BACKGROUND: 'BACKGROUND';
BACKINGFILE: 'BACKINGFILE';
BACKUP: 'BACKUP'; BACKUP: 'BACKUP';
BACKUPS: 'BACKUPS';
BACKUPSET: 'BACKUPSET'; BACKUPSET: 'BACKUPSET';
BASIC: 'BASIC'; BASIC: 'BASIC';
BASICFILE: 'BASICFILE'; BASICFILE: 'BASICFILE';
@ -184,10 +195,12 @@ CALL: 'CALL';
CANCEL: 'CANCEL'; CANCEL: 'CANCEL';
CANONICAL: 'CANONICAL'; CANONICAL: 'CANONICAL';
CAPACITY: 'CAPACITY'; CAPACITY: 'CAPACITY';
CAPTION: 'CAPTION';
CARDINALITY: 'CARDINALITY'; CARDINALITY: 'CARDINALITY';
CASCADE: 'CASCADE'; CASCADE: 'CASCADE';
CASE: 'CASE'; CASE: 'CASE';
CAST: 'CAST'; CAST: 'CAST';
CASESENSITIVE: 'CASE-SENSITIVE';
CATEGORY: 'CATEGORY'; CATEGORY: 'CATEGORY';
CDBDEFAULT: 'CDB$DEFAULT'; CDBDEFAULT: 'CDB$DEFAULT';
CEIL: 'CEIL'; CEIL: 'CEIL';
@ -210,7 +223,10 @@ CHOOSE: 'CHOOSE';
CHR: 'CHR'; CHR: 'CHR';
CHUNK: 'CHUNK'; CHUNK: 'CHUNK';
CLASS: 'CLASS'; CLASS: 'CLASS';
CLASSIFICATION: 'CLASSIFICATION';
CLASSIFIER: 'CLASSIFIER'; CLASSIFIER: 'CLASSIFIER';
CLAUSE: 'CLAUSE';
CLEAN: 'CLEAN';
CLEANUP: 'CLEANUP'; CLEANUP: 'CLEANUP';
CLEAR: 'CLEAR'; CLEAR: 'CLEAR';
C_LETTER: 'C'; C_LETTER: 'C';
@ -243,6 +259,7 @@ COLUMN_VALUE: 'COLUMN_VALUE';
COMMENT: 'COMMENT'; COMMENT: 'COMMENT';
COMMIT: 'COMMIT'; COMMIT: 'COMMIT';
COMMITTED: 'COMMITTED'; COMMITTED: 'COMMITTED';
COMMON: 'COMMON';
COMMON_DATA: 'COMMON_DATA'; COMMON_DATA: 'COMMON_DATA';
COMPACT: 'COMPACT'; COMPACT: 'COMPACT';
COMPATIBILITY: 'COMPATIBILITY'; COMPATIBILITY: 'COMPATIBILITY';
@ -284,8 +301,10 @@ CONSTRAINT: 'CONSTRAINT';
CONSTRAINTS: 'CONSTRAINTS'; CONSTRAINTS: 'CONSTRAINTS';
CONSTRUCTOR: 'CONSTRUCTOR'; CONSTRUCTOR: 'CONSTRUCTOR';
CONTAINER: 'CONTAINER'; CONTAINER: 'CONTAINER';
CONTAINER_DATA: 'CONTAINER_DATA';
CONTAINERS: 'CONTAINERS'; CONTAINERS: 'CONTAINERS';
CONTAINERS_DEFAULT: 'CONTAINERS_DEFAULT';
CONTAINER_DATA: 'CONTAINER_DATA';
CONTAINER_MAP: 'CONTAINER_MAP';
CONTENT: 'CONTENT'; CONTENT: 'CONTENT';
CONTENTS: 'CONTENTS'; CONTENTS: 'CONTENTS';
CONTEXT: 'CONTEXT'; CONTEXT: 'CONTEXT';
@ -293,6 +312,7 @@ CONTINUE: 'CONTINUE';
CONTROLFILE: 'CONTROLFILE'; CONTROLFILE: 'CONTROLFILE';
CON_UID_TO_ID: 'CON_UID_TO_ID'; CON_UID_TO_ID: 'CON_UID_TO_ID';
CONVERT: 'CONVERT'; CONVERT: 'CONVERT';
CONVERSION: 'CONVERSION';
COOKIE: 'COOKIE'; COOKIE: 'COOKIE';
COPY: 'COPY'; COPY: 'COPY';
CORR_K: 'CORR_K'; CORR_K: 'CORR_K';
@ -376,6 +396,8 @@ DECRYPT: 'DECRYPT';
DEDUPLICATE: 'DEDUPLICATE'; DEDUPLICATE: 'DEDUPLICATE';
DEFAULT: 'DEFAULT'; DEFAULT: 'DEFAULT';
DEFAULTS: 'DEFAULTS'; DEFAULTS: 'DEFAULTS';
DEFAULT_COLLATION: 'DEFAULT_COLLATION';
DEFAULT_CREDENTIAL: 'DEFAULT_CREDENTIAL';
DEFERRABLE: 'DEFERRABLE'; DEFERRABLE: 'DEFERRABLE';
DEFERRED: 'DEFERRED'; DEFERRED: 'DEFERRED';
DEFINED: 'DEFINED'; DEFINED: 'DEFINED';
@ -395,6 +417,7 @@ DEQUEUE: 'DEQUEUE';
DEREF: 'DEREF'; DEREF: 'DEREF';
DEREF_NO_REWRITE: 'DEREF_NO_REWRITE'; DEREF_NO_REWRITE: 'DEREF_NO_REWRITE';
DESC: 'DESC'; DESC: 'DESC';
DESCRIPTION: 'DESCRIPTION';
DESTROY: 'DESTROY'; DESTROY: 'DESTROY';
DETACHED: 'DETACHED'; DETACHED: 'DETACHED';
DETERMINES: 'DETERMINES'; DETERMINES: 'DETERMINES';
@ -445,6 +468,7 @@ DV: 'DV';
DYNAMIC: 'DYNAMIC'; DYNAMIC: 'DYNAMIC';
DYNAMIC_SAMPLING: 'DYNAMIC_SAMPLING'; DYNAMIC_SAMPLING: 'DYNAMIC_SAMPLING';
DYNAMIC_SAMPLING_EST_CDN: 'DYNAMIC_SAMPLING_EST_CDN'; DYNAMIC_SAMPLING_EST_CDN: 'DYNAMIC_SAMPLING_EST_CDN';
E_LETTER: 'E';
EACH: 'EACH'; EACH: 'EACH';
EDITIONABLE: 'EDITIONABLE'; EDITIONABLE: 'EDITIONABLE';
EDITION: 'EDITION'; EDITION: 'EDITION';
@ -537,6 +561,7 @@ FAR: 'FAR';
FAST: 'FAST'; FAST: 'FAST';
FASTSTART: 'FASTSTART'; FASTSTART: 'FASTSTART';
FBTSCAN: 'FBTSCAN'; FBTSCAN: 'FBTSCAN';
FEATURE: 'FEATURE';
FEATURE_DETAILS: 'FEATURE_DETAILS'; FEATURE_DETAILS: 'FEATURE_DETAILS';
FEATURE_ID: 'FEATURE_ID'; FEATURE_ID: 'FEATURE_ID';
FEATURE_SET: 'FEATURE_SET'; FEATURE_SET: 'FEATURE_SET';
@ -544,6 +569,8 @@ FEATURE_VALUE: 'FEATURE_VALUE';
FETCH: 'FETCH'; FETCH: 'FETCH';
FILE: 'FILE'; FILE: 'FILE';
FILE_NAME_CONVERT: 'FILE_NAME_CONVERT'; FILE_NAME_CONVERT: 'FILE_NAME_CONVERT';
FILEGROUP: 'FILEGROUP';
FILESTORE: 'FILESTORE';
FILESYSTEM_LIKE_LOGGING: 'FILESYSTEM_LIKE_LOGGING'; FILESYSTEM_LIKE_LOGGING: 'FILESYSTEM_LIKE_LOGGING';
FILTER: 'FILTER'; FILTER: 'FILTER';
FINAL: 'FINAL'; FINAL: 'FINAL';
@ -559,6 +586,7 @@ FLASHBACK: 'FLASHBACK';
FLASH_CACHE: 'FLASH_CACHE'; FLASH_CACHE: 'FLASH_CACHE';
FLOAT: 'FLOAT'; FLOAT: 'FLOAT';
FLOB: 'FLOB'; FLOB: 'FLOB';
FLEX: 'FLEX';
FLOOR: 'FLOOR'; FLOOR: 'FLOOR';
FLUSH: 'FLUSH'; FLUSH: 'FLUSH';
FOLDER: 'FOLDER'; FOLDER: 'FOLDER';
@ -583,6 +611,8 @@ FULL: 'FULL';
FULL_OUTER_JOIN_TO_OUTER: 'FULL_OUTER_JOIN_TO_OUTER'; FULL_OUTER_JOIN_TO_OUTER: 'FULL_OUTER_JOIN_TO_OUTER';
FUNCTION: 'FUNCTION'; FUNCTION: 'FUNCTION';
FUNCTIONS: 'FUNCTIONS'; FUNCTIONS: 'FUNCTIONS';
FTP: 'FTP';
G_LETTER: 'G';
GATHER_OPTIMIZER_STATISTICS: 'GATHER_OPTIMIZER_STATISTICS'; GATHER_OPTIMIZER_STATISTICS: 'GATHER_OPTIMIZER_STATISTICS';
GATHER_PLAN_STATISTICS: 'GATHER_PLAN_STATISTICS'; GATHER_PLAN_STATISTICS: 'GATHER_PLAN_STATISTICS';
GBY_CONC_ROLLUP: 'GBY_CONC_ROLLUP'; GBY_CONC_ROLLUP: 'GBY_CONC_ROLLUP';
@ -604,6 +634,7 @@ GROUPS: 'GROUPS';
GUARANTEED: 'GUARANTEED'; GUARANTEED: 'GUARANTEED';
GUARANTEE: 'GUARANTEE'; GUARANTEE: 'GUARANTEE';
GUARD: 'GUARD'; GUARD: 'GUARD';
HALF_YEARS: 'HALF_YEARS';
HASH_AJ: 'HASH_AJ'; HASH_AJ: 'HASH_AJ';
HASH: 'HASH'; HASH: 'HASH';
HASHKEYS: 'HASHKEYS'; HASHKEYS: 'HASHKEYS';
@ -616,14 +647,20 @@ HEXTORAW: 'HEXTORAW';
HEXTOREF: 'HEXTOREF'; HEXTOREF: 'HEXTOREF';
HIDDEN_KEYWORD: 'HIDDEN'; HIDDEN_KEYWORD: 'HIDDEN';
HIDE: 'HIDE'; HIDE: 'HIDE';
HIER_ORDER: 'HIER_ORDER';
HIERARCHICAL: 'HIERARCHICAL';
HIERARCHIES: 'HIERARCHIES';
HIERARCHY: 'HIERARCHY'; HIERARCHY: 'HIERARCHY';
HIGH: 'HIGH'; HIGH: 'HIGH';
HINTSET_BEGIN: 'HINTSET_BEGIN'; HINTSET_BEGIN: 'HINTSET_BEGIN';
HINTSET_END: 'HINTSET_END'; HINTSET_END: 'HINTSET_END';
HOT: 'HOT'; HOT: 'HOT';
HOUR: 'HOUR'; HOUR: 'HOUR';
HOURS: 'HOURS';
HTTP: 'HTTP';
HWM_BROKERED: 'HWM_BROKERED'; HWM_BROKERED: 'HWM_BROKERED';
HYBRID: 'HYBRID'; HYBRID: 'HYBRID';
H_LETTER: 'H';
IDENTIFIED: 'IDENTIFIED'; IDENTIFIED: 'IDENTIFIED';
IDENTIFIER: 'IDENTIFIER'; IDENTIFIER: 'IDENTIFIER';
IDENTITY: 'IDENTITY'; IDENTITY: 'IDENTITY';
@ -640,6 +677,7 @@ IMMEDIATE: 'IMMEDIATE';
IMPACT: 'IMPACT'; IMPACT: 'IMPACT';
IMPORT: 'IMPORT'; IMPORT: 'IMPORT';
INACTIVE: 'INACTIVE'; INACTIVE: 'INACTIVE';
INACTIVE_ACCOUNT_TIME: 'INACTIVE_ACCOUNT_TIME';
INCLUDE: 'INCLUDE'; INCLUDE: 'INCLUDE';
INCLUDE_VERSION: 'INCLUDE_VERSION'; INCLUDE_VERSION: 'INCLUDE_VERSION';
INCLUDING: 'INCLUDING'; INCLUDING: 'INCLUDING';
@ -719,6 +757,7 @@ INVALIDATE: 'INVALIDATE';
INVISIBLE: 'INVISIBLE'; INVISIBLE: 'INVISIBLE';
IN_XQUERY: 'IN_XQUERY'; IN_XQUERY: 'IN_XQUERY';
IS: 'IS'; IS: 'IS';
IS_LEAF: 'IS_LEAF';
ISOLATION: 'ISOLATION'; ISOLATION: 'ISOLATION';
ISOLATION_LEVEL: 'ISOLATION_LEVEL'; ISOLATION_LEVEL: 'ISOLATION_LEVEL';
ITERATE: 'ITERATE'; ITERATE: 'ITERATE';
@ -741,7 +780,9 @@ JSON_SERIALIZE: 'JSON_SERIALIZE';
JSON_TABLE: 'JSON_TABLE'; JSON_TABLE: 'JSON_TABLE';
JSON_TEXTCONTAINS2: 'JSON_TEXTCONTAINS2'; JSON_TEXTCONTAINS2: 'JSON_TEXTCONTAINS2';
JSON_TEXTCONTAINS: 'JSON_TEXTCONTAINS'; JSON_TEXTCONTAINS: 'JSON_TEXTCONTAINS';
JSON_TRANSFORM: 'JSON_TRANSFORM';
JSON_VALUE: 'JSON_VALUE'; JSON_VALUE: 'JSON_VALUE';
K_LETTER: 'K';
KEEP_DUPLICATES: 'KEEP_DUPLICATES'; KEEP_DUPLICATES: 'KEEP_DUPLICATES';
KEEP: 'KEEP'; KEEP: 'KEEP';
KERBEROS: 'KERBEROS'; KERBEROS: 'KERBEROS';
@ -762,6 +803,9 @@ LAYER: 'LAYER';
LDAP_REGISTRATION_ENABLED: 'LDAP_REGISTRATION_ENABLED'; LDAP_REGISTRATION_ENABLED: 'LDAP_REGISTRATION_ENABLED';
LDAP_REGISTRATION: 'LDAP_REGISTRATION'; LDAP_REGISTRATION: 'LDAP_REGISTRATION';
LDAP_REG_SYNC_INTERVAL: 'LDAP_REG_SYNC_INTERVAL'; LDAP_REG_SYNC_INTERVAL: 'LDAP_REG_SYNC_INTERVAL';
LEAF: 'LEAF';
LEAD_CDB: 'LEAD_CDB';
LEAD_CDB_URI: 'LEAD_CDB_URI';
LEADING: 'LEADING'; LEADING: 'LEADING';
LEFT: 'LEFT'; LEFT: 'LEFT';
LENGTH2: 'LENGTH2'; LENGTH2: 'LENGTH2';
@ -771,6 +815,7 @@ LENGTHC: 'LENGTHC';
LENGTH: 'LENGTH'; LENGTH: 'LENGTH';
LESS: 'LESS'; LESS: 'LESS';
LEVEL: 'LEVEL'; LEVEL: 'LEVEL';
LEVEL_NAME: 'LEVEL_NAME';
LEVELS: 'LEVELS'; LEVELS: 'LEVELS';
LIBRARY: 'LIBRARY'; LIBRARY: 'LIBRARY';
LIFECYCLE: 'LIFECYCLE'; LIFECYCLE: 'LIFECYCLE';
@ -797,6 +842,7 @@ LOCALTIME: 'LOCALTIME';
LOCALTIMESTAMP: 'LOCALTIMESTAMP'; LOCALTIMESTAMP: 'LOCALTIMESTAMP';
LOCATION: 'LOCATION'; LOCATION: 'LOCATION';
LOCATOR: 'LOCATOR'; LOCATOR: 'LOCATOR';
LOCKDOWN: 'LOCKDOWN';
LOCKED: 'LOCKED'; LOCKED: 'LOCKED';
LOCKING: 'LOCKING'; LOCKING: 'LOCKING';
LOCK: 'LOCK'; LOCK: 'LOCK';
@ -813,16 +859,19 @@ LOGON: 'LOGON';
LOG_READ_ONLY_VIOLATIONS: 'LOG_READ_ONLY_VIOLATIONS'; LOG_READ_ONLY_VIOLATIONS: 'LOG_READ_ONLY_VIOLATIONS';
LONG: 'LONG'; LONG: 'LONG';
LOOP: 'LOOP'; LOOP: 'LOOP';
LOST: 'LOST';
LOWER: 'LOWER'; LOWER: 'LOWER';
LOW: 'LOW'; LOW: 'LOW';
LPAD: 'LPAD'; LPAD: 'LPAD';
LTRIM: 'LTRIM'; LTRIM: 'LTRIM';
M_LETTER: 'M';
MAIN: 'MAIN'; MAIN: 'MAIN';
MAKE_REF: 'MAKE_REF'; MAKE_REF: 'MAKE_REF';
MANAGED: 'MANAGED'; MANAGED: 'MANAGED';
MANAGE: 'MANAGE'; MANAGE: 'MANAGE';
MANAGEMENT: 'MANAGEMENT'; MANAGEMENT: 'MANAGEMENT';
MANAGER: 'MANAGER'; MANAGER: 'MANAGER';
MANDATORY: 'MANDATORY';
MANUAL: 'MANUAL'; MANUAL: 'MANUAL';
MAP: 'MAP'; MAP: 'MAP';
MAPPING: 'MAPPING'; MAPPING: 'MAPPING';
@ -850,6 +899,10 @@ MEASURE: 'MEASURE';
MEASURES: 'MEASURES'; MEASURES: 'MEASURES';
MEDIUM: 'MEDIUM'; MEDIUM: 'MEDIUM';
MEMBER: 'MEMBER'; MEMBER: 'MEMBER';
MEMBER_CAPTION: 'MEMBER_CAPTION';
MEMBER_DESCRIPTION: 'MEMBER_DESCRIPTION';
MEMBER_NAME: 'MEMBER_NAME';
MEMBER_UNIQUE_NAME: 'MEMBER_UNIQUE_NAME';
MEMCOMPRESS: 'MEMCOMPRESS'; MEMCOMPRESS: 'MEMCOMPRESS';
MEMORY: 'MEMORY'; MEMORY: 'MEMORY';
MERGEACTIONS: 'MERGE$ACTIONS'; MERGEACTIONS: 'MERGE$ACTIONS';
@ -868,10 +921,13 @@ MINING: 'MINING';
MINUS: 'MINUS'; MINUS: 'MINUS';
MINUS_NULL: 'MINUS_NULL'; MINUS_NULL: 'MINUS_NULL';
MINUTE: 'MINUTE'; MINUTE: 'MINUTE';
MINUTES: 'MINUTES';
MINVALUE: 'MINVALUE'; MINVALUE: 'MINVALUE';
MIRRORCOLD: 'MIRRORCOLD'; MIRRORCOLD: 'MIRRORCOLD';
MIRRORHOT: 'MIRRORHOT'; MIRRORHOT: 'MIRRORHOT';
MIRROR: 'MIRROR'; MIRROR: 'MIRROR';
MISSING: 'MISSING';
MISMATCH: 'MISMATCH';
MLSLABEL: 'MLSLABEL'; MLSLABEL: 'MLSLABEL';
MODEL_COMPILE_SUBQUERY: 'MODEL_COMPILE_SUBQUERY'; MODEL_COMPILE_SUBQUERY: 'MODEL_COMPILE_SUBQUERY';
MODEL_DONTVERIFY_UNIQUENESS: 'MODEL_DONTVERIFY_UNIQUENESS'; MODEL_DONTVERIFY_UNIQUENESS: 'MODEL_DONTVERIFY_UNIQUENESS';
@ -896,6 +952,7 @@ MONTHS_BETWEEN: 'MONTHS_BETWEEN';
MONTHS: 'MONTHS'; MONTHS: 'MONTHS';
MOUNT: 'MOUNT'; MOUNT: 'MOUNT';
MOUNTPATH: 'MOUNTPATH'; MOUNTPATH: 'MOUNTPATH';
MOUNTPOINT: 'MOUNTPOINT';
MOVEMENT: 'MOVEMENT'; MOVEMENT: 'MOVEMENT';
MOVE: 'MOVE'; MOVE: 'MOVE';
MULTIDIMENSIONAL: 'MULTIDIMENSIONAL'; MULTIDIMENSIONAL: 'MULTIDIMENSIONAL';
@ -1053,6 +1110,7 @@ NO_PLACE_DISTINCT: 'NO_PLACE_DISTINCT';
NO_PLACE_GROUP_BY: 'NO_PLACE_GROUP_BY'; NO_PLACE_GROUP_BY: 'NO_PLACE_GROUP_BY';
NO_PQ_CONCURRENT_UNION: 'NO_PQ_CONCURRENT_UNION'; NO_PQ_CONCURRENT_UNION: 'NO_PQ_CONCURRENT_UNION';
NO_PQ_MAP: 'NO_PQ_MAP'; NO_PQ_MAP: 'NO_PQ_MAP';
NOPROMPT: 'NOPROMPT';
NO_PQ_REPLICATE: 'NO_PQ_REPLICATE'; NO_PQ_REPLICATE: 'NO_PQ_REPLICATE';
NO_PQ_SKEW: 'NO_PQ_SKEW'; NO_PQ_SKEW: 'NO_PQ_SKEW';
NO_PRUNE_GSETS: 'NO_PRUNE_GSETS'; NO_PRUNE_GSETS: 'NO_PRUNE_GSETS';
@ -1214,6 +1272,7 @@ OVERRIDING: 'OVERRIDING';
OWNER: 'OWNER'; OWNER: 'OWNER';
OWNERSHIP: 'OWNERSHIP'; OWNERSHIP: 'OWNERSHIP';
OWN: 'OWN'; OWN: 'OWN';
P_LETTER: 'P';
PACKAGE: 'PACKAGE'; PACKAGE: 'PACKAGE';
PACKAGES: 'PACKAGES'; PACKAGES: 'PACKAGES';
PARALLEL_ENABLE: 'PARALLEL_ENABLE'; PARALLEL_ENABLE: 'PARALLEL_ENABLE';
@ -1223,6 +1282,8 @@ PARAMETERFILE: 'PARAMETERFILE';
PARAMETERS: 'PARAMETERS'; PARAMETERS: 'PARAMETERS';
PARAM: 'PARAM'; PARAM: 'PARAM';
PARENT: 'PARENT'; PARENT: 'PARENT';
PARENT_LEVEL_NAME: 'PARENT_LEVEL_NAME';
PARENT_UNIQUE_NAME: 'PARENT_UNIQUE_NAME';
PARITY: 'PARITY'; PARITY: 'PARITY';
PARTIAL_JOIN: 'PARTIAL_JOIN'; PARTIAL_JOIN: 'PARTIAL_JOIN';
PARTIALLY: 'PARTIALLY'; PARTIALLY: 'PARTIALLY';
@ -1241,6 +1302,7 @@ PASSWORD_LOCK_TIME: 'PASSWORD_LOCK_TIME';
PASSWORD: 'PASSWORD'; PASSWORD: 'PASSWORD';
PASSWORD_REUSE_MAX: 'PASSWORD_REUSE_MAX'; PASSWORD_REUSE_MAX: 'PASSWORD_REUSE_MAX';
PASSWORD_REUSE_TIME: 'PASSWORD_REUSE_TIME'; PASSWORD_REUSE_TIME: 'PASSWORD_REUSE_TIME';
PASSWORD_ROLLOVER_TIME: 'PASSWORD_ROLLOVER_TIME';
PASSWORD_VERIFY_FUNCTION: 'PASSWORD_VERIFY_FUNCTION'; PASSWORD_VERIFY_FUNCTION: 'PASSWORD_VERIFY_FUNCTION';
PAST: 'PAST'; PAST: 'PAST';
PATCH: 'PATCH'; PATCH: 'PATCH';
@ -1289,6 +1351,7 @@ PLSQL_DEBUG: 'PLSQL_DEBUG';
PLSQL_OPTIMIZE_LEVEL: 'PLSQL_OPTIMIZE_LEVEL'; PLSQL_OPTIMIZE_LEVEL: 'PLSQL_OPTIMIZE_LEVEL';
PLSQL_WARNINGS: 'PLSQL_WARNINGS'; PLSQL_WARNINGS: 'PLSQL_WARNINGS';
PLUGGABLE: 'PLUGGABLE'; PLUGGABLE: 'PLUGGABLE';
PMEM: 'PMEM';
POINT: 'POINT'; POINT: 'POINT';
POLICY: 'POLICY'; POLICY: 'POLICY';
POOL_16K: 'POOL_16K'; POOL_16K: 'POOL_16K';
@ -1343,8 +1406,10 @@ PROFILE: 'PROFILE';
PROGRAM: 'PROGRAM'; PROGRAM: 'PROGRAM';
PROJECT: 'PROJECT'; PROJECT: 'PROJECT';
PROPAGATE: 'PROPAGATE'; PROPAGATE: 'PROPAGATE';
PROPERTY: 'PROPERTY';
PROTECTED: 'PROTECTED'; PROTECTED: 'PROTECTED';
PROTECTION: 'PROTECTION'; PROTECTION: 'PROTECTION';
PROTOCOL: 'PROTOCOL';
PROXY: 'PROXY'; PROXY: 'PROXY';
PRUNING: 'PRUNING'; PRUNING: 'PRUNING';
PUBLIC: 'PUBLIC'; PUBLIC: 'PUBLIC';
@ -1356,6 +1421,7 @@ PX_FAULT_TOLERANCE: 'PX_FAULT_TOLERANCE';
PX_GRANULE: 'PX_GRANULE'; PX_GRANULE: 'PX_GRANULE';
PX_JOIN_FILTER: 'PX_JOIN_FILTER'; PX_JOIN_FILTER: 'PX_JOIN_FILTER';
QB_NAME: 'QB_NAME'; QB_NAME: 'QB_NAME';
QUARTERS: 'QUARTERS';
QUERY_BLOCK: 'QUERY_BLOCK'; QUERY_BLOCK: 'QUERY_BLOCK';
QUERY: 'QUERY'; QUERY: 'QUERY';
QUEUE_CURR: 'QUEUE_CURR'; QUEUE_CURR: 'QUEUE_CURR';
@ -1364,6 +1430,7 @@ QUEUE_ROWP: 'QUEUE_ROWP';
QUIESCE: 'QUIESCE'; QUIESCE: 'QUIESCE';
QUORUM: 'QUORUM'; QUORUM: 'QUORUM';
QUOTA: 'QUOTA'; QUOTA: 'QUOTA';
QUOTAGROUP: 'QUOTAGROUP';
RAISE: 'RAISE'; RAISE: 'RAISE';
RANDOM_LOCAL: 'RANDOM_LOCAL'; RANDOM_LOCAL: 'RANDOM_LOCAL';
RANDOM: 'RANDOM'; RANDOM: 'RANDOM';
@ -1425,6 +1492,7 @@ RELIES_ON: 'RELIES_ON';
RELOCATE: 'RELOCATE'; RELOCATE: 'RELOCATE';
RELY: 'RELY'; RELY: 'RELY';
REMAINDER: 'REMAINDER'; REMAINDER: 'REMAINDER';
REMOTE: 'REMOTE';
REMOTE_MAPPED: 'REMOTE_MAPPED'; REMOTE_MAPPED: 'REMOTE_MAPPED';
REMOVE: 'REMOVE'; REMOVE: 'REMOVE';
RENAME: 'RENAME'; RENAME: 'RENAME';
@ -1501,9 +1569,11 @@ SCRUB: 'SCRUB';
SD_ALL: 'SD_ALL'; SD_ALL: 'SD_ALL';
SD_INHIBIT: 'SD_INHIBIT'; SD_INHIBIT: 'SD_INHIBIT';
SDO_GEOM_MBR: 'SDO_GEOM_MBR'; SDO_GEOM_MBR: 'SDO_GEOM_MBR';
SDO_GEOMETRY: 'SDO_GEOMETRY';
SD_SHOW: 'SD_SHOW'; SD_SHOW: 'SD_SHOW';
SEARCH: 'SEARCH'; SEARCH: 'SEARCH';
SECOND: 'SECOND'; SECOND: 'SECOND';
SECONDS: 'SECONDS';
SECRET: 'SECRET'; SECRET: 'SECRET';
SECUREFILE_DBA: 'SECUREFILE_DBA'; SECUREFILE_DBA: 'SECUREFILE_DBA';
SECUREFILE: 'SECUREFILE'; SECUREFILE: 'SECUREFILE';
@ -1527,6 +1597,7 @@ SERIALLY_REUSABLE: 'SERIALLY_REUSABLE';
SERIAL: 'SERIAL'; SERIAL: 'SERIAL';
SERVERERROR: 'SERVERERROR'; SERVERERROR: 'SERVERERROR';
SERVICE_NAME_CONVERT: 'SERVICE_NAME_CONVERT'; SERVICE_NAME_CONVERT: 'SERVICE_NAME_CONVERT';
SERVICE: 'SERVICE';
SERVICES: 'SERVICES'; SERVICES: 'SERVICES';
SESSION_CACHED_CURSORS: 'SESSION_CACHED_CURSORS'; SESSION_CACHED_CURSORS: 'SESSION_CACHED_CURSORS';
SESSION: 'SESSION'; SESSION: 'SESSION';
@ -1538,6 +1609,7 @@ SETS: 'SETS';
SETTINGS: 'SETTINGS'; SETTINGS: 'SETTINGS';
SET_TO_JOIN: 'SET_TO_JOIN'; SET_TO_JOIN: 'SET_TO_JOIN';
SEVERE: 'SEVERE'; SEVERE: 'SEVERE';
SHARDSPACE: 'SHARDSPACE';
SHARED_POOL: 'SHARED_POOL'; SHARED_POOL: 'SHARED_POOL';
SHARED: 'SHARED'; SHARED: 'SHARED';
SHARE: 'SHARE'; SHARE: 'SHARE';
@ -1548,6 +1620,7 @@ SHRINK: 'SHRINK';
SHUTDOWN: 'SHUTDOWN'; SHUTDOWN: 'SHUTDOWN';
SIBLINGS: 'SIBLINGS'; SIBLINGS: 'SIBLINGS';
SID: 'SID'; SID: 'SID';
SITE: 'SITE';
SIGNAL_COMPONENT: 'SIGNAL_COMPONENT'; SIGNAL_COMPONENT: 'SIGNAL_COMPONENT';
SIGNAL_FUNCTION: 'SIGNAL_FUNCTION'; SIGNAL_FUNCTION: 'SIGNAL_FUNCTION';
SIGN: 'SIGN'; SIGN: 'SIGN';
@ -1581,11 +1654,13 @@ SQLDATA: 'SQLDATA';
SQLERROR: 'SQLERROR'; SQLERROR: 'SQLERROR';
SQLLDR: 'SQLLDR'; SQLLDR: 'SQLLDR';
SQL: 'SQL'; SQL: 'SQL';
SQL_MACRO: 'SQL_MACRO';
SQL_TRACE: 'SQL_TRACE'; SQL_TRACE: 'SQL_TRACE';
SQL_TRANSLATION_PROFILE: 'SQL_TRANSLATION_PROFILE'; SQL_TRANSLATION_PROFILE: 'SQL_TRANSLATION_PROFILE';
SQRT: 'SQRT'; SQRT: 'SQRT';
STALE: 'STALE'; STALE: 'STALE';
STANDALONE: 'STANDALONE'; STANDALONE: 'STANDALONE';
STANDARD: 'STANDARD';
STANDARD_HASH: 'STANDARD_HASH'; STANDARD_HASH: 'STANDARD_HASH';
STANDBY_MAX_DATA_DELAY: 'STANDBY_MAX_DATA_DELAY'; STANDBY_MAX_DATA_DELAY: 'STANDBY_MAX_DATA_DELAY';
STANDBYS: 'STANDBYS'; STANDBYS: 'STANDBYS';
@ -1651,6 +1726,7 @@ SWITCH: 'SWITCH';
SYNCHRONOUS: 'SYNCHRONOUS'; SYNCHRONOUS: 'SYNCHRONOUS';
SYNC: 'SYNC'; SYNC: 'SYNC';
SYNONYM: 'SYNONYM'; SYNONYM: 'SYNONYM';
SYS: 'SYS';
SYSASM: 'SYSASM'; SYSASM: 'SYSASM';
SYS_AUDIT: 'SYS_AUDIT'; SYS_AUDIT: 'SYS_AUDIT';
SYSAUX: 'SYSAUX'; SYSAUX: 'SYSAUX';
@ -1930,6 +2006,7 @@ SYS_XQXFORM: 'SYS_XQXFORM';
SYS_XSID_TO_RAW: 'SYS_XSID_TO_RAW'; SYS_XSID_TO_RAW: 'SYS_XSID_TO_RAW';
SYS_ZMAP_FILTER: 'SYS_ZMAP_FILTER'; SYS_ZMAP_FILTER: 'SYS_ZMAP_FILTER';
SYS_ZMAP_REFRESH: 'SYS_ZMAP_REFRESH'; SYS_ZMAP_REFRESH: 'SYS_ZMAP_REFRESH';
T_LETTER: 'T';
TABLE_LOOKUP_BY_NL: 'TABLE_LOOKUP_BY_NL'; TABLE_LOOKUP_BY_NL: 'TABLE_LOOKUP_BY_NL';
TABLESPACE_NO: 'TABLESPACE_NO'; TABLESPACE_NO: 'TABLESPACE_NO';
TABLESPACE: 'TABLESPACE'; TABLESPACE: 'TABLESPACE';
@ -1968,6 +2045,7 @@ TIMEZONE_MINUTE: 'TIMEZONE_MINUTE';
TIMEZONE_OFFSET: 'TIMEZONE_OFFSET'; TIMEZONE_OFFSET: 'TIMEZONE_OFFSET';
TIMEZONE_REGION: 'TIMEZONE_REGION'; TIMEZONE_REGION: 'TIMEZONE_REGION';
TIME_ZONE: 'TIME_ZONE'; TIME_ZONE: 'TIME_ZONE';
TIMING: 'TIMING';
TIV_GB: 'TIV_GB'; TIV_GB: 'TIV_GB';
TIV_SSF: 'TIV_SSF'; TIV_SSF: 'TIV_SSF';
TO_ACLID: 'TO_ACLID'; TO_ACLID: 'TO_ACLID';
@ -1994,6 +2072,7 @@ TRACING: 'TRACING';
TRACKING: 'TRACKING'; TRACKING: 'TRACKING';
TRAILING: 'TRAILING'; TRAILING: 'TRAILING';
TRANSACTION: 'TRANSACTION'; TRANSACTION: 'TRANSACTION';
TRANSFORM: 'TRANSFORM';
TRANSFORM_DISTINCT_AGG: 'TRANSFORM_DISTINCT_AGG'; TRANSFORM_DISTINCT_AGG: 'TRANSFORM_DISTINCT_AGG';
TRANSITIONAL: 'TRANSITIONAL'; TRANSITIONAL: 'TRANSITIONAL';
TRANSITION: 'TRANSITION'; TRANSITION: 'TRANSITION';
@ -2094,6 +2173,7 @@ UTF8: 'UTF8';
V1: 'V1'; V1: 'V1';
V2: 'V2'; V2: 'V2';
VALIDATE: 'VALIDATE'; VALIDATE: 'VALIDATE';
VALIDATE_CONVERSION: 'VALIDATE_CONVERSION';
VALIDATION: 'VALIDATION'; VALIDATION: 'VALIDATION';
VALID_TIME_END: 'VALID_TIME_END'; VALID_TIME_END: 'VALID_TIME_END';
VALUES: 'VALUES'; VALUES: 'VALUES';
@ -2204,6 +2284,28 @@ PREDICTION_DETAILS: 'PREDICTION_DETAILS';
PREDICTION_PROBABILITY: 'PREDICTION_PROBABILITY'; PREDICTION_PROBABILITY: 'PREDICTION_PROBABILITY';
PREDICTION_SET: 'PREDICTION_SET'; PREDICTION_SET: 'PREDICTION_SET';
BLOCKCHAIN: 'BLOCKCHAIN';
COLLATE: 'COLLATE';
COLLATION: 'COLLATION';
DEFINITION: 'DEFINITION';
DUPLICATED: 'DUPLICATED';
EXTENDED: 'EXTENDED';
HASHING: 'HASHING';
IDLE: 'IDLE';
IMMUTABLE: 'IMMUTABLE';
ORACLE_DATAPUMP: 'ORACLE_DATAPUMP';
ORACLE_HDFS: 'ORACLE_HDFS';
ORACLE_HIVE: 'ORACLE_HIVE';
ORACLE_LOADER: 'ORACLE_LOADER';
SHA2_512_Q: '"SHA2_512"';
SHARDED: 'SHARDED';
V1_Q: '"V1"';
ISOLATE: 'ISOLATE';
ROOT: 'ROOT';
UNITE: 'UNITE';
ALGORITHM: 'ALGORITHM';
CUME_DIST: 'CUME_DIST'; CUME_DIST: 'CUME_DIST';
DENSE_RANK: 'DENSE_RANK'; DENSE_RANK: 'DENSE_RANK';
LISTAGG: 'LISTAGG'; LISTAGG: 'LISTAGG';
@ -2217,9 +2319,12 @@ CORR: 'CORR';
COVAR_: 'COVAR_'; COVAR_: 'COVAR_';
DECODE: 'DECODE'; DECODE: 'DECODE';
LAG: 'LAG'; LAG: 'LAG';
LAG_DIFF: 'LAG_DIFF';
LAG_DIFF_PERCENT: 'LAG_DIFF_PERCENT';
LEAD: 'LEAD'; LEAD: 'LEAD';
MAX: 'MAX'; MAX: 'MAX';
MEDIAN: 'MEDIAN'; MEDIAN: 'MEDIAN';
MEMOPTIMIZE: 'MEMOPTIMIZE';
MIN: 'MIN'; MIN: 'MIN';
NTILE: 'NTILE'; NTILE: 'NTILE';
NVL: 'NVL'; NVL: 'NVL';
@ -2251,7 +2356,7 @@ BIT_STRING_LIT: 'B' ('\'' [01]* '\'')+;
// Rule #284 <HEX_STRING_LIT> - subtoken typecast in <REGULAR_ID> // Rule #284 <HEX_STRING_LIT> - subtoken typecast in <REGULAR_ID>
// Lowercase 'x' is a usual addition to the standard // Lowercase 'x' is a usual addition to the standard
HEX_STRING_LIT: 'X' ('\'' [A-F0-9]* '\'')+; HEX_STRING_LIT: 'X' ('\'' [A-Fa-f0-9]* '\'')+;
DOUBLE_PERIOD: '..'; DOUBLE_PERIOD: '..';
PERIOD: '.'; PERIOD: '.';
@ -2274,6 +2379,7 @@ PERIOD: '.';
UNSIGNED_INTEGER: [0-9]+; UNSIGNED_INTEGER: [0-9]+;
APPROXIMATE_NUM_LIT: FLOAT_FRAGMENT ('E' ('+'|'-')? (FLOAT_FRAGMENT | [0-9]+))? ('D' | 'F')?; APPROXIMATE_NUM_LIT: FLOAT_FRAGMENT ('E' ('+'|'-')? (FLOAT_FRAGMENT | [0-9]+))? ('D' | 'F')?;
// Rule #--- <CHAR_STRING> is a base for Rule #065 <char_string_lit> , it incorporates <character_representation> // Rule #--- <CHAR_STRING> is a base for Rule #065 <char_string_lit> , it incorporates <character_representation>
// and a superfluous subtoken typecasting of the "QUOTE" // and a superfluous subtoken typecasting of the "QUOTE"
CHAR_STRING: '\'' (~('\'' | '\r' | '\n') | '\'' '\'' | NEWLINE)* '\''; CHAR_STRING: '\'' (~('\'' | '\r' | '\n') | '\'' '\'' | NEWLINE)* '\'';
@ -2304,6 +2410,9 @@ COMMA: ',';
SOLIDUS: '/'; SOLIDUS: '/';
AT_SIGN: '@'; AT_SIGN: '@';
ASSIGN_OP: ':='; ASSIGN_OP: ':=';
HASH_OP: '#';
SQ: '\'';
BINDVAR BINDVAR
: ':' SIMPLE_LETTER (SIMPLE_LETTER | [0-9] | '_')* : ':' SIMPLE_LETTER (SIMPLE_LETTER | [0-9] | '_')*
@ -2359,7 +2468,7 @@ SPACES: [ \t\r\n]+ -> channel(HIDDEN);
fragment NEWLINE_EOF : NEWLINE | EOF; fragment NEWLINE_EOF : NEWLINE | EOF;
fragment QUESTION_MARK : '?'; fragment QUESTION_MARK : '?';
fragment SIMPLE_LETTER : [A-Z]; fragment SIMPLE_LETTER : [a-zA-Z];
fragment FLOAT_FRAGMENT : UNSIGNED_INTEGER* '.'? UNSIGNED_INTEGER+; fragment FLOAT_FRAGMENT : UNSIGNED_INTEGER* '.'? UNSIGNED_INTEGER+;
fragment NEWLINE : '\r'? '\n'; fragment NEWLINE : '\r'? '\n';
fragment SPACE : [ \t]; fragment SPACE : [ \t];

View File

@ -24,11 +24,14 @@ options {
tokenVocab=PlSqlLexer; tokenVocab=PlSqlLexer;
superClass=PlSqlBaseParser; superClass=PlSqlBaseParser;
} }
@parser::header {
import PlSqlBaseParser from './PlSqlBaseParser';
}
program: sql_script EOF; program: sql_script SEMICOLON? EOF;
sql_script sql_script
: ((unit_statement | sql_plus_command) SEMICOLON?)* EOF : (unit_statement | sql_plus_command)*
; ;
unit_statement unit_statement
@ -268,21 +271,6 @@ trigger_body
| trigger_block | trigger_block
; ;
routine_clause
: routine_name function_argument?
;
compound_trigger_block
: COMPOUND TRIGGER seq_of_declare_specs? timing_point_section+ END trigger_name
;
timing_point_section
: bk=BEFORE STATEMENT IS trigger_block BEFORE STATEMENT ';'
| bk=BEFORE EACH ROW IS trigger_block BEFORE EACH ROW ';'
| ak=AFTER STATEMENT IS trigger_block AFTER STATEMENT ';'
| ak=AFTER EACH ROW IS trigger_block AFTER EACH ROW ';'
;
non_dml_event non_dml_event
: ALTER : ALTER
| ANALYZE | ANALYZE
@ -366,14 +354,6 @@ alter_method_element
: (ADD | DROP) (map_order_function_spec | subprogram_spec) : (ADD | DROP) (map_order_function_spec | subprogram_spec)
; ;
alter_attribute_definition
: (ADD | MODIFY | DROP) ATTRIBUTE (attribute_definition | '(' attribute_definition (',' attribute_definition)* ')')
;
attribute_definition
: attribute_name type_spec?
;
alter_collection_clauses alter_collection_clauses
: MODIFY (LIMIT expression | ELEMENT TYPE type_spec) : MODIFY (LIMIT expression | ELEMENT TYPE type_spec)
; ;
@ -1621,27 +1601,6 @@ mv_log_augmentation
new_values_clause? new_values_clause?
; ;
// Should bound this to just date/time expr
datetime_expr
: expression
;
// Should bound this to just interval expr
interval_expr
: expression
;
synchronous_or_asynchronous
: SYNCHRONOUS
| ASYNCHRONOUS
;
including_or_excluding
: INCLUDING
| EXCLUDING
;
create_materialized_view_log create_materialized_view_log
: CREATE MATERIALIZED VIEW LOG ON tableview_name : CREATE MATERIALIZED VIEW LOG ON tableview_name
( ( physical_attributes_clause ( ( physical_attributes_clause
@ -2005,12 +1964,6 @@ lob_partitioning_storage
) )
; ;
datatype_null_enable
: column_name datatype
SORT? (DEFAULT expression)? (ENCRYPT ( USING CHAR_STRING )? (IDENTIFIED BY REGULAR_ID)? CHAR_STRING? ( NO? SALT )? )?
(NOT NULL_)? (ENABLE | DISABLE)?
;
//Technically, this should only allow 'K' | 'M' | 'G' | 'T' | 'P' | 'E' //Technically, this should only allow 'K' | 'M' | 'G' | 'T' | 'P' | 'E'
// but having issues with examples/numbers01.sql line 11 "sysdate -1m" // but having issues with examples/numbers01.sql line 11 "sysdate -1m"
size_clause size_clause
@ -2286,8 +2239,7 @@ database_file_clauses
create_datafile_clause create_datafile_clause
: CREATE DATAFILE (filename | filenumber) (',' (filename | filenumber) )* : CREATE DATAFILE (filename | filenumber) (',' (filename | filenumber) )*
(AS (//TODO (','? file_specification)+ | (AS (NEW) )?
NEW) )?
; ;
alter_datafile_clause alter_datafile_clause
@ -2655,11 +2607,6 @@ add_column_clause
')' ')'
| ( column_definition | virtual_column_definition )) | ( column_definition | virtual_column_definition ))
column_properties? column_properties?
//TODO (','? out_of_line_part_storage )
;
alter_varray_col_properties
: MODIFY VARRAY varray_item '(' modify_lob_parameters ')'
; ;
varray_col_properties varray_col_properties
@ -2760,19 +2707,6 @@ column_properties
| xmltype_column_properties | xmltype_column_properties
; ;
period_definition
: {this.isVersion12()}? PERIOD FOR column_name
( '(' start_time_column ',' end_time_column ')' )?
;
start_time_column
: column_name
;
end_time_column
: column_name
;
column_definition column_definition
: column_name (datatype | type_name) : column_name (datatype | type_name)
SORT? (DEFAULT expression)? (ENCRYPT (USING CHAR_STRING)? (IDENTIFIED BY regular_id)? CHAR_STRING? (NO? SALT)? )? (inline_constraint* | inline_ref_constraint) SORT? (DEFAULT expression)? (ENCRYPT (USING CHAR_STRING)? (IDENTIFIED BY regular_id)? CHAR_STRING? (NO? SALT)? )? (inline_constraint* | inline_ref_constraint)
@ -2787,10 +2721,6 @@ autogenerated_sequence_definition
: GENERATED (ALWAYS | BY DEFAULT (ON NULL_)?)? AS IDENTITY : GENERATED (ALWAYS | BY DEFAULT (ON NULL_)?)? AS IDENTITY
; ;
out_of_line_part_storage
: PARTITION partition_name
;
nested_table_col_properties nested_table_col_properties
: NESTED TABLE (nested_item | COLUMN_VALUE) substitutable_column_clause? (LOCAL | GLOBAL)? : NESTED TABLE (nested_item | COLUMN_VALUE) substitutable_column_clause? (LOCAL | GLOBAL)?
STORE AS tableview_name ( '(' ( '(' object_properties ')' STORE AS tableview_name ( '(' ( '(' object_properties ')'
@ -2819,10 +2749,6 @@ supplemental_logging_props
: SUPPLEMENTAL LOG (supplemental_log_grp_clause | supplemental_id_key_clause) : SUPPLEMENTAL LOG (supplemental_log_grp_clause | supplemental_id_key_clause)
; ;
column_or_attribute
: regular_id
;
object_type_col_properties object_type_col_properties
: COLUMN column=regular_id substitutable_column_clause : COLUMN column=regular_id substitutable_column_clause
; ;
@ -2852,33 +2778,11 @@ drop_primary_key_or_unique_or_generic_clause
| CONSTRAINT constraint_name CASCADE? | CONSTRAINT constraint_name CASCADE?
; ;
add_constraint
: ADD (CONSTRAINT constraint_name)? add_constraint_clause (',' (CONSTRAINT constraint_name)? add_constraint_clause)+
;
add_constraint_clause
: primary_key_clause
| foreign_key_clause
| unique_key_clause
| check_constraint
;
check_constraint check_constraint
: CHECK '(' condition ')' DISABLE? : CHECK '(' condition ')' DISABLE?
; ;
drop_constraint
: DROP CONSTRAINT constraint_name
;
enable_constraint
: ENABLE CONSTRAINT constraint_name
;
disable_constraint
: DISABLE CONSTRAINT constraint_name
;
foreign_key_clause foreign_key_clause
: FOREIGN KEY paren_column_list references_clause on_delete_clause? : FOREIGN KEY paren_column_list references_clause on_delete_clause?
; ;
@ -2891,14 +2795,6 @@ on_delete_clause
: ON DELETE (CASCADE | SET NULL_) : ON DELETE (CASCADE | SET NULL_)
; ;
unique_key_clause
: UNIQUE paren_column_list using_index_clause?
;
primary_key_clause
: PRIMARY KEY paren_column_list using_index_clause?
;
// Anonymous PL/SQL code block // Anonymous PL/SQL code block
anonymous_block anonymous_block
@ -3053,10 +2949,6 @@ statement
| procedure_call | procedure_call
; ;
swallow_to_semi
: ~';'+
;
assignment_statement assignment_statement
: (general_element | bind_variable) ASSIGN_OP expression : (general_element | bind_variable) ASSIGN_OP expression
; ;
@ -3322,7 +3214,7 @@ subquery_operation_part
query_block query_block
: SELECT (DISTINCT | UNIQUE | ALL)? selected_list : SELECT (DISTINCT | UNIQUE | ALL)? selected_list
into_clause? from_clause where_clause? hierarchical_query_clause? group_by_clause? model_clause? order_by_clause? into_clause? from_clause? where_clause? hierarchical_query_clause? group_by_clause? model_clause? order_by_clause?
; ;
selected_list selected_list
@ -4146,10 +4038,6 @@ rollback_segment_name
: identifier : identifier
; ;
table_var_name
: identifier
;
schema_name schema_name
: identifier : identifier
; ;
@ -6741,19 +6629,3 @@ non_reserved_keywords_pre12c
| YES | YES
| ZONE | ZONE
; ;
string_function_name
: CHR
| DECODE
| SUBSTR
| TO_CHAR
| TRIM
;
numeric_function_name
: AVG
| COUNT
| NVL
| ROUND
| SUM
;

View File

@ -490,12 +490,12 @@ windowFrame: (
)?; )?;
frameExtent: frameExtent:
frameType = RANGE start = frameBound frameType = RANGE frameStart = frameBound
| frameType = ROWS start = frameBound | frameType = ROWS frameStart = frameBound
| frameType = GROUPS start = frameBound | frameType = GROUPS frameStart = frameBound
| frameType = RANGE BETWEEN start = frameBound AND end = frameBound | frameType = RANGE BETWEEN frameStart = frameBound AND end = frameBound
| frameType = ROWS BETWEEN start = frameBound AND end = frameBound | frameType = ROWS BETWEEN frameStart = frameBound AND end = frameBound
| frameType = GROUPS BETWEEN start = frameBound AND end = frameBound; | frameType = GROUPS BETWEEN frameStart = frameBound AND end = frameBound;
frameBound: frameBound:
UNBOUNDED boundType = PRECEDING # unboundedFrame UNBOUNDED boundType = PRECEDING # unboundedFrame

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -548,11 +548,9 @@ EscapeStringConstant=547
UnterminatedEscapeStringConstant=548 UnterminatedEscapeStringConstant=548
InvalidEscapeStringConstant=549 InvalidEscapeStringConstant=549
InvalidUnterminatedEscapeStringConstant=550 InvalidUnterminatedEscapeStringConstant=550
AfterEscapeStringConstantMode_NotContinued=551 DollarText=551
AfterEscapeStringConstantWithNewlineMode_NotContinued=552 EndDollarStringConstant=552
DollarText=553 AfterEscapeStringConstantWithNewlineMode_Continued=553
EndDollarStringConstant=554
AfterEscapeStringConstantWithNewlineMode_Continued=555
'$'=1 '$'=1
'('=2 '('=2
')'=3 ')'=3
@ -1063,4 +1061,4 @@ AfterEscapeStringConstantWithNewlineMode_Continued=555
'LOOP'=510 'LOOP'=510
'OPEN'=511 'OPEN'=511
'\\\\'=545 '\\\\'=545
'\''=555 '\''=553

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,60 @@
import { Lexer } from "antlr4ts/Lexer";
import { Lexer } from 'antlr4';
function isLetter(str) { function isLetter(str) {
return str.length === 1 && str.match(/[a-z]/i); return str.length === 1 && str.match(/[a-z]/i);
} }
export default class PostgreSQLLexerBase extends Lexer { export default abstract class PostgreSQLLexerBase extends Lexer {
tags: string[] = []; tags: string[] = [];
_interp: any;
constructor(input) {
super(input);
}
pushTag() {
this.tags.push(this.text);
}
isTag() {
return this.text === this.tags[this.tags.length - 1];
}
popTag() {
this.tags.pop();
}
getInputStream() {
return this._input;
}
checkLA( c) {
// eslint-disable-next-line new-cap
return this.getInputStream().LA(1) !== c;
}
charIsLetter() {
// eslint-disable-next-line new-cap
return isLetter(this.getInputStream().LA(-1));
}
HandleNumericFail() {
this.getInputStream().seek(this.getInputStream().index - 2);
const Integral = 535;
this.type = Integral;
}
HandleLessLessGreaterGreater() {
const LESS_LESS = 18;
const GREATER_GREATER = 19;
if (this.text === '<<') this.type = LESS_LESS;
if (this.text === '>>') this.type = GREATER_GREATER;
}
UnterminatedBlockCommentDebugAssert() {
// Debug.Assert(InputStream.LA(1) == -1 /*EOF*/);
}
CheckIfUtf32Letter() { CheckIfUtf32Letter() {
// eslint-disable-next-line new-cap // eslint-disable-next-line new-cap
@ -21,52 +68,4 @@ export default class PostgreSQLLexerBase extends Lexer {
} }
return isLetter(c[0]); return isLetter(c[0]);
} }
UnterminatedBlockCommentDebugAssert() {
// Debug.Assert(InputStream.LA(1) == -1 /*EOF*/);
}
HandleLessLessGreaterGreater() {
const LESS_LESS = 18;
const GREATER_GREATER = 19;
if (this.text === '<<') {
this._type = LESS_LESS;
}
if (this.text === '>>') {
this._type = GREATER_GREATER;
}
}
HandleNumericFail() {
this.getInputStream().seek(this.getInputStream().index - 2);
const Integral = 535;
this._type = Integral;
}
charIsLetter() {
// eslint-disable-next-line new-cap
return isLetter(this.getInputStream().LA(-1));
}
pushTag() {
this.tags.push(this.text);
};
isTag() {
return this.text === this.tags.pop();
}
popTag() {
this.tags.pop();
}
getInputStream() {
return this._input;
}
checkLA(c) {
// eslint-disable-next-line new-cap
return this.getInputStream().LA(1) !== c;
}
} }

File diff suppressed because one or more lines are too long

View File

@ -548,11 +548,9 @@ EscapeStringConstant=547
UnterminatedEscapeStringConstant=548 UnterminatedEscapeStringConstant=548
InvalidEscapeStringConstant=549 InvalidEscapeStringConstant=549
InvalidUnterminatedEscapeStringConstant=550 InvalidUnterminatedEscapeStringConstant=550
AfterEscapeStringConstantMode_NotContinued=551 DollarText=551
AfterEscapeStringConstantWithNewlineMode_NotContinued=552 EndDollarStringConstant=552
DollarText=553 AfterEscapeStringConstantWithNewlineMode_Continued=553
EndDollarStringConstant=554
AfterEscapeStringConstantWithNewlineMode_Continued=555
'$'=1 '$'=1
'('=2 '('=2
')'=3 ')'=3
@ -1063,4 +1061,4 @@ AfterEscapeStringConstantWithNewlineMode_Continued=555
'LOOP'=510 'LOOP'=510
'OPEN'=511 'OPEN'=511
'\\\\'=545 '\\\\'=545
'\''=555 '\''=553

File diff suppressed because one or more lines are too long

View File

@ -1,16 +1,12 @@
/* eslint-disable new-cap,camelcase */ /* eslint-disable new-cap,camelcase */
import { Parser, CharStreams, CommonTokenStream } from 'antlr4'; import { CharStreams, CommonTokenStream, Parser } from 'antlr4ts';
import PostgreSQLLexer from './PostgreSQLLexer'; import { PostgreSQLLexer } from './PostgreSQLLexer';
import PostgreSQLParser from './PostgreSQLParser'; import { PostgreSQLParser } from './PostgreSQLParser';
export default class PostgreSQLParserBase extends Parser { // @ts-ignore
export default abstract class PostgreSQLParserBase extends Parser {
getPostgreSQLParser(script) { constructor( input) {
const charStream = CharStreams.fromString(script); super(input);
const lexer = new PostgreSQLLexer(charStream);
const tokens = new CommonTokenStream(lexer);
const parser = new PostgreSQLParser(tokens);
return parser;
} }
GetParsedSqlTree( script, line) { GetParsedSqlTree( script, line) {
@ -35,13 +31,10 @@ export default class PostgreSQLParserBase extends Parser {
} }
} }
} }
if (!lang) { if (!lang) return;
return;
}
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
let func_as = null; let func_as = null;
for (let _b = 0, _c = _localctx.createfunc_opt_item(); _b < _c.length; _b++) { for (const a of _localctx.createfunc_opt_item()) {
const a = _c[_b];
if (!a.func_as()) { if (!a.func_as()) {
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
func_as = a; func_as = a;
@ -49,9 +42,8 @@ export default class PostgreSQLParserBase extends Parser {
} }
} }
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
if (!!func_as) { if (!func_as) {
const txt = this.GetRoutineBodyString(func_as.func_as().sconst(0)); const txt = this.GetRoutineBodyString(func_as.func_as().sconst(0));
// @ts-ignore
const line = func_as.func_as().sconst(0).start.getLine(); const line = func_as.func_as().sconst(0).start.getLine();
const ph = this.getPostgreSQLParser(txt); const ph = this.getPostgreSQLParser(txt);
switch (lang) { switch (lang) {
@ -65,46 +57,47 @@ export default class PostgreSQLParserBase extends Parser {
} }
} }
TrimQuotes(s: string) { TrimQuotes( s) {
return (!s) ? s : s.substring(1, s.length - 1); return (!s) ? s : s.substring(1, s.length() - 1);
} }
unquote(s: string) { unquote( s) {
const slength = s.length; const slength = s.length();
let r = ''; let r = '';
let i = 0; let i = 0;
while (i < slength) { while (i < slength) {
const c = s.charAt(i); const c = s.charAt(i);
r = r.concat(c); r = r.concat(c);
if (c === '\'' && i < slength - 1 && (s.charAt(i + 1) === '\'')) { if (c === '\'' && i < slength - 1 && (s.charAt(i + 1) === '\'')) i++;
i++;
}
i++; i++;
} }
return r.toString(); return r.toString();
}; }
GetRoutineBodyString( rule) { GetRoutineBodyString( rule) {
const anysconst = rule.anysconst(); const anysconst = rule.anysconst();
// eslint-disable-next-line new-cap
const StringConstant = anysconst.StringConstant(); const StringConstant = anysconst.StringConstant();
if (!!StringConstant) { if (null !== StringConstant) return this.unquote(this.TrimQuotes(StringConstant.getText()));
return this.unquote(this.TrimQuotes(StringConstant.getText()));
}
const UnicodeEscapeStringConstant = anysconst.UnicodeEscapeStringConstant(); const UnicodeEscapeStringConstant = anysconst.UnicodeEscapeStringConstant();
if (!!UnicodeEscapeStringConstant) { if (null !== UnicodeEscapeStringConstant) return this.TrimQuotes(UnicodeEscapeStringConstant.getText());
return this.TrimQuotes(UnicodeEscapeStringConstant.getText());
}
const EscapeStringConstant = anysconst.EscapeStringConstant(); const EscapeStringConstant = anysconst.EscapeStringConstant();
if (!!EscapeStringConstant) { if (null !== EscapeStringConstant) return this.TrimQuotes(EscapeStringConstant.getText());
return this.TrimQuotes(EscapeStringConstant.getText());
}
let result = ''; let result = '';
const dollartext = anysconst.DollarText(); const dollartext = anysconst.DollarText();
for (let _i = 0, dollartext_1 = dollartext; _i < dollartext_1.length; _i++) { for (const s of dollartext) {
const s = dollartext_1[_i];
result += s.getText(); result += s.getText();
} }
return result; return result;
} }
getPostgreSQLParser( script) {
const charStream = CharStreams.fromString(script);
const lexer = new PostgreSQLLexer(charStream);
const tokens = new CommonTokenStream(lexer);
const parser = new PostgreSQLParser(tokens);
// lexer.removeErrorListeners();
// parser.removeErrorListeners();
return parser;
}
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,11 @@
import { Lexer } from "antlr4"; import { Lexer } from "antlr4ts/Lexer";
export default class PlSqlBaseLexer extends Lexer { export default abstract class PlSqlBaseLexer extends Lexer {
_interp: any;
IsNewlineAtPos(pos: number): boolean { IsNewlineAtPos(pos: number): boolean {
const la = this._input.LA(pos); const la = this._input.LA(pos);
return la == -1; return la == -1 || String.fromCharCode(la) == '\n';
} }
} }

View File

@ -1,20 +1,30 @@
import { Parser } from 'antlr4'; import { Parser } from "antlr4ts/Parser";
import { TokenStream } from "antlr4ts/TokenStream";
export default class PlSqlBaseParser extends Parser { export default abstract class PlSqlBaseParser extends Parser {
private _isVersion10: boolean = false; private _isVersion10: boolean = false;
private _isVersion12: boolean = true; private _isVersion12: boolean = true;
public isVersion10(): boolean { constructor(input: TokenStream) {
super(input);
this._isVersion10 = false;
this._isVersion12 = true;
}
isVersion10(): boolean {
return this._isVersion10; return this._isVersion10;
} }
public isVersion12(): boolean {
isVersion12(): boolean {
return this._isVersion12; return this._isVersion12;
} }
public setVersion10(value: boolean): void {
setVersion10(value: boolean): void {
this._isVersion10 = value; this._isVersion10 = value;
} }
public setVersion12(value: boolean): void {
setVersion12(value: boolean): void {
this._isVersion12 = value; this._isVersion12 = value;
} }
} }

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,13 @@
import { ParseTreeWalker, CommonTokenStream } from 'antlr4'; import { Parser } from 'antlr4ts';
import type { Parser } from 'antlr4/src/antlr4'; import { ParseTreeWalker } from 'antlr4ts/tree';
import ParserErrorListener, { import ParserErrorListener, {
ParserError, ParserError,
ErrorHandler, ErrorHandler,
ParserErrorCollector, ParserErrorCollector,
} from './parserErrorListener'; } from './parserErrorListener';
interface IParser { interface IParser extends Parser {
// Lost in type definition // Lost in type definition
ruleNames: string[]; ruleNames: string[];
// Customized in our parser // Customized in our parser
@ -17,7 +18,7 @@ interface IParser {
* Custom Parser class, subclass needs extends it. * Custom Parser class, subclass needs extends it.
*/ */
export default abstract class BasicParser { export default abstract class BasicParser {
private _parser: IParser & Parser; private _parser: IParser;
public parse( public parse(
input: string, input: string,
@ -66,16 +67,14 @@ export default abstract class BasicParser {
*/ */
public getAllTokens(input: string): string[] { public getAllTokens(input: string): string[] {
const lexer = this.createLexer(input); const lexer = this.createLexer(input);
const tokensStream = new CommonTokenStream(lexer); return lexer.getAllTokens().map(token => token.text);
tokensStream.fill();
return tokensStream.tokens;
}; };
/** /**
* Get Parser instance by input string * Get Parser instance by input string
* @param input * @param input
*/ */
public createParser(input: string): IParser & Parser { public createParser(input: string): IParser {
const lexer = this.createLexer(input); const lexer = this.createLexer(input);
const parser: any = this.createParserFromLexer(lexer); const parser: any = this.createParserFromLexer(lexer);
parser.buildParseTrees = true; parser.buildParseTrees = true;

View File

@ -1,4 +1,4 @@
import { Token, Recognizer, ErrorListener, RecognitionException } from 'antlr4'; import { Token, Recognizer, ParserErrorListener, RecognitionException } from 'antlr4ts';
export interface ParserError { export interface ParserError {
startLine: number; startLine: number;
endLine: number; endLine: number;
@ -8,7 +8,7 @@ export interface ParserError {
} }
export interface SyntaxError<T> { export interface SyntaxError<T> {
recognizer: Recognizer<T>; recognizer: Recognizer<T, any>;
offendingSymbol: Token; offendingSymbol: Token;
line: number; line: number;
charPositionInLine: number; charPositionInLine: number;
@ -22,16 +22,15 @@ type ErrorOffendingSymbol = {
export type ErrorHandler<T> = (err: ParserError, errOption: SyntaxError<T>) => void; export type ErrorHandler<T> = (err: ParserError, errOption: SyntaxError<T>) => void;
export class ParserErrorCollector extends ErrorListener<ErrorOffendingSymbol> { export class ParserErrorCollector implements ParserErrorListener {
private _errors: ParserError[]; private _errors: ParserError[];
constructor(error: ParserError[]) { constructor(error: ParserError[]) {
super();
this._errors = error; this._errors = error;
} }
syntaxError( syntaxError(
recognizer: Recognizer<ErrorOffendingSymbol>, offendingSymbol: ErrorOffendingSymbol, line: number, recognizer: Recognizer<ErrorOffendingSymbol, any>, offendingSymbol: ErrorOffendingSymbol, line: number,
charPositionInLine: number, msg: string, e: RecognitionException, charPositionInLine: number, msg: string, e: RecognitionException,
) { ) {
let endCol = charPositionInLine + 1; let endCol = charPositionInLine + 1;
@ -49,16 +48,15 @@ export class ParserErrorCollector extends ErrorListener<ErrorOffendingSymbol> {
} }
export default class ParserErrorListener extends ErrorListener<ErrorOffendingSymbol> { export default class CustomParserErrorListener implements ParserErrorListener {
private _errorHandler; private _errorHandler;
constructor(errorListener: ErrorHandler<ErrorOffendingSymbol>) { constructor(errorListener: ErrorHandler<ErrorOffendingSymbol>) {
super();
this._errorHandler = errorListener; this._errorHandler = errorListener;
} }
syntaxError( syntaxError(
recognizer: Recognizer<ErrorOffendingSymbol>, offendingSymbol: ErrorOffendingSymbol, line: number, recognizer: Recognizer<ErrorOffendingSymbol, any>, offendingSymbol: ErrorOffendingSymbol, line: number,
charPositionInLine: number, msg: string, e: any, charPositionInLine: number, msg: string, e: any,
) { ) {
let endCol = charPositionInLine + 1; let endCol = charPositionInLine + 1;

View File

@ -1,14 +1,14 @@
import { CharStream, CommonTokenStream, Lexer } from 'antlr4'; import { CharStreams, CommonTokenStream } from 'antlr4ts';
import FlinkSqlLexer from '../lib/flinksql/FlinkSqlLexer'; import { FlinkSqlLexer } from '../lib/flinksql/FlinkSqlLexer';
import FlinkSqlParser from '../lib/flinksql/FlinkSqlParser'; import { FlinkSqlParser } from '../lib/flinksql/FlinkSqlParser';
import BasicParser from './common/basicParser'; import BasicParser from './common/basicParser';
export default class FlinkSQL extends BasicParser { export default class FlinkSQL extends BasicParser {
public createLexer(input: string): FlinkSqlLexer { public createLexer(input: string): FlinkSqlLexer {
const chars = new CharStream(input.toUpperCase()); // Some Lexer only support uppercase token, So you need transform const chars = CharStreams.fromString(input.toUpperCase()); // Some Lexer only support uppercase token, So you need transform
const lexer = new FlinkSqlLexer(chars); const lexer = new FlinkSqlLexer(chars);
return lexer; return lexer;
} }
public createParserFromLexer(lexer: Lexer): FlinkSqlParser { public createParserFromLexer(lexer: FlinkSqlLexer): FlinkSqlParser {
const tokens = new CommonTokenStream(lexer); const tokens = new CommonTokenStream(lexer);
const parser = new FlinkSqlParser(tokens); const parser = new FlinkSqlParser(tokens);
return parser; return parser;

View File

@ -1,15 +1,15 @@
import { CharStream, CommonTokenStream, Lexer } from 'antlr4'; import { CharStreams, CommonTokenStream } from 'antlr4ts';
import SqlLexer from '../lib/generic/SqlLexer'; import { SqlLexer } from '../lib/generic/SqlLexer';
import SqlParser from '../lib/generic/SqlParser'; import { SqlParser } from '../lib/generic/SqlParser';
import BasicParser from './common/basicParser'; import BasicParser from './common/basicParser';
export default class GenericSQL extends BasicParser { export default class GenericSQL extends BasicParser {
public createLexer(input: string): SqlLexer { public createLexer(input: string): SqlLexer {
const chars = new CharStream(input.toUpperCase()); // Some Lexer only support uppercase token, So you need transform const chars = CharStreams.fromString(input.toUpperCase()); // Some Lexer only support uppercase token, So you need transform
const lexer = new SqlLexer(chars); const lexer = new SqlLexer(chars);
return lexer; return lexer;
} }
public createParserFromLexer(lexer: Lexer): SqlParser { public createParserFromLexer(lexer: SqlLexer): SqlParser {
const tokenStream = new CommonTokenStream(lexer); const tokenStream = new CommonTokenStream(lexer);
return new SqlParser(tokenStream); return new SqlParser(tokenStream);
} }

View File

@ -1,15 +1,15 @@
import { CharStream, CommonTokenStream, Lexer } from 'antlr4'; import { CharStreams, CommonTokenStream } from 'antlr4ts';
import HiveSqlLexer from '../lib/hive/HiveSqlLexer'; import { HiveSqlLexer } from '../lib/hive/HiveSqlLexer';
import HiveSql from '../lib/hive/HiveSql'; import { HiveSql } from '../lib/hive/HiveSql';
import BasicParser from './common/basicParser'; import BasicParser from './common/basicParser';
export default class HiveSQL extends BasicParser { export default class HiveSQL extends BasicParser {
public createLexer(input: string): HiveSqlLexer { public createLexer(input: string): HiveSqlLexer {
const chars = new CharStream(input); const chars = CharStreams.fromString(input.toUpperCase());
const lexer = new HiveSqlLexer(chars); const lexer = new HiveSqlLexer(chars);
return lexer; return lexer;
} }
public createParserFromLexer(lexer: Lexer): HiveSql { public createParserFromLexer(lexer: HiveSqlLexer): HiveSql {
const tokenStream = new CommonTokenStream(lexer); const tokenStream = new CommonTokenStream(lexer);
return new HiveSql(tokenStream); return new HiveSql(tokenStream);
} }

View File

@ -1,16 +1,16 @@
import { CharStream, CommonTokenStream, Lexer } from 'antlr4'; import { CharStreams, CommonTokenStream, Lexer } from 'antlr4ts';
import BasicParser from './common/basicParser'; import BasicParser from './common/basicParser';
import PostgreSQLLexer from '../lib/pgsql/PostgreSQLLexer'; import { PostgreSQLLexer } from '../lib/pgsql/PostgreSQLLexer';
import PostgreSQLParser from '../lib/pgsql/PostgreSQLParser'; import { PostgreSQLParser } from '../lib/pgsql/PostgreSQLParser';
export default class PostgresSQL extends BasicParser { export default class PostgresSQL extends BasicParser {
public createLexer(input: string): PostgreSQLLexer { public createLexer(input: string): PostgreSQLLexer {
const chars = new CharStream(input.toUpperCase()); const chars = CharStreams.fromString(input.toUpperCase());
const lexer = new PostgreSQLLexer(chars); const lexer = new PostgreSQLLexer(chars);
return lexer; return lexer;
} }
public createParserFromLexer(lexer: Lexer): any { public createParserFromLexer(lexer: Lexer): PostgreSQLParser {
const tokenStream = new CommonTokenStream(lexer); const tokenStream = new CommonTokenStream(lexer);
return new PostgreSQLParser(tokenStream); return new PostgreSQLParser(tokenStream);
} }

View File

@ -1,16 +1,16 @@
import { CharStream, CommonTokenStream } from 'antlr4'; import { CharStreams, CommonTokenStream, Lexer } from 'antlr4ts';
import BasicParser from './common/basicParser'; import BasicParser from './common/basicParser';
import PlSqlLexer from '../lib/plsql/PlSqlLexer'; import { PlSqlLexer } from '../lib/plsql/PlSqlLexer';
import PlSqlParser from '../lib/plsql/PlSqlParser'; import { PlSqlParser } from '../lib/plsql/PlSqlParser';
export default class PLSQLParser extends BasicParser { export default class PLSQLParser extends BasicParser {
public createLexer(input: string): PlSqlLexer { public createLexer(input: string): PlSqlLexer {
const chars = new CharStream(input.toUpperCase()); const chars = CharStreams.fromString(input.toUpperCase());
const lexer = new PlSqlLexer(chars); const lexer = new PlSqlLexer(chars);
return lexer; return lexer;
} }
public createParserFromLexer(lexer: PlSqlLexer): PlSqlParser { public createParserFromLexer(lexer: Lexer): PlSqlParser {
const tokenStream = new CommonTokenStream(lexer); const tokenStream = new CommonTokenStream(lexer);
return new PlSqlParser(tokenStream); return new PlSqlParser(tokenStream);
} }

View File

@ -1,15 +1,15 @@
import { CharStream, CommonTokenStream, Lexer } from 'antlr4'; import { CharStreams, CommonTokenStream } from 'antlr4ts';
import BasicParser from './common/basicParser'; import BasicParser from './common/basicParser';
import SparkSqlLexer from '../lib/spark/SparkSqlLexer'; import { SparkSqlLexer } from '../lib/spark/SparkSqlLexer';
import SparkSqlParser from '../lib/spark/SparkSqlParser'; import { SparkSqlParser } from '../lib/spark/SparkSqlParser';
export default class SparkSQL extends BasicParser { export default class SparkSQL extends BasicParser {
public createLexer(input: string): Lexer { public createLexer(input: string): SparkSqlLexer {
const chars = new CharStream(input.toUpperCase()); // Some Lexer only support uppercase token, So you need transform const chars = CharStreams.fromString(input.toUpperCase()); // Some Lexer only support uppercase token, So you need transform
const lexer = new SparkSqlLexer(chars); const lexer = new SparkSqlLexer(chars);
return lexer; return lexer;
} }
public createParserFromLexer(lexer: Lexer): any { public createParserFromLexer(lexer: SparkSqlLexer): SparkSqlParser {
const tokenStream = new CommonTokenStream(lexer); const tokenStream = new CommonTokenStream(lexer);
return new SparkSqlParser(tokenStream); return new SparkSqlParser(tokenStream);
} }

View File

@ -1,10 +1,10 @@
import { CharStream, CommonTokenStream, Lexer } from 'antlr4'; import { CharStreams, CommonTokenStream, Lexer } from 'antlr4ts';
import TrinoSqlLexer from '../lib/trinosql/TrinoSqlLexer'; import { TrinoSqlLexer } from '../lib/trinosql/TrinoSqlLexer';
import TrinoSqlParser from '../lib/trinosql/TrinoSqlParser'; import { TrinoSqlParser } from '../lib/trinosql/TrinoSqlParser';
import BasicParser from './common/basicParser'; import BasicParser from './common/basicParser';
export default class trinoSQL extends BasicParser { export default class trinoSQL extends BasicParser {
public createLexer(input: string): TrinoSqlLexer { public createLexer(input: string): TrinoSqlLexer {
const chars = new CharStream(input.toUpperCase()); // Some Lexer only support uppercase token, So you need transform const chars = CharStreams.fromString(input.toUpperCase()); // Some Lexer only support uppercase token, So you need transform
const lexer = new TrinoSqlLexer(chars); const lexer = new TrinoSqlLexer(chars);
return lexer; return lexer;
} }

View File

@ -6,6 +6,6 @@ describe('FlinkSQL Lexer tests', () => {
const sql = 'SELECT * FROM table1'; const sql = 'SELECT * FROM table1';
const tokens = parser.getAllTokens(sql); const tokens = parser.getAllTokens(sql);
test('token counts', () => { test('token counts', () => {
expect(tokens.length - 1).toBe(7); expect(tokens.length).toBe(7);
}); });
}); });

View File

@ -1,5 +1,5 @@
import FlinkSQL from '../../../src/parser/flinksql'; import FlinkSQL from '../../../src/parser/flinksql';
import FlinkSqlParserListener from '../../../src/lib/flinksql/FlinkSqlParserListener'; import { FlinkSqlParserListener } from '../../../src/lib/flinksql/FlinkSqlParserListener';
import { TableExpressionContext } from '../../../src/lib/flinksql/FlinkSqlParser'; import { TableExpressionContext } from '../../../src/lib/flinksql/FlinkSqlParser';
describe('Flink SQL Listener Tests', () => { describe('Flink SQL Listener Tests', () => {
@ -11,14 +11,10 @@ describe('Flink SQL Listener Tests', () => {
test('Listener enterTableName', async () => { test('Listener enterTableName', async () => {
let result = ''; let result = '';
class MyListener extends FlinkSqlParserListener { class MyListener implements FlinkSqlParserListener {
constructor() {
super()
}
enterTableExpression = (ctx: TableExpressionContext): void => { enterTableExpression = (ctx: TableExpressionContext): void => {
result = ctx.getText().toLowerCase(); result = ctx.text.toLowerCase();
} }
} }
const listenTableName = new MyListener(); const listenTableName = new MyListener();

View File

@ -1,5 +1,6 @@
import FlinkSQL from '../../../src/parser/flinksql'; import FlinkSQL from '../../../src/parser/flinksql';
import FlinkSqlParserVisitor from '../../../src/lib/flinksql/FlinkSqlParserVisitor'; import { FlinkSqlParserVisitor } from '../../../src/lib/flinksql/FlinkSqlParserVisitor';
import { AbstractParseTreeVisitor } from 'antlr4ts/tree';
describe('Flink SQL Visitor Tests', () => { describe('Flink SQL Visitor Tests', () => {
const expectTableName = 'user1'; const expectTableName = 'user1';
@ -12,9 +13,12 @@ describe('Flink SQL Visitor Tests', () => {
test('Visitor visitTableName', () => { test('Visitor visitTableName', () => {
let result = ''; let result = '';
class MyVisitor extends FlinkSqlParserVisitor<any>{ class MyVisitor extends AbstractParseTreeVisitor<any> implements FlinkSqlParserVisitor<any>{
protected defaultResult() {
return result;
}
visitTableExpression = (ctx): void => { visitTableExpression = (ctx): void => {
result = ctx.getText().toLowerCase(); result = ctx.text.toLowerCase();
} }
} }
const visitor: any = new MyVisitor(); const visitor: any = new MyVisitor();

View File

@ -7,6 +7,6 @@ describe('GenericSQL Lexer tests', () => {
const tokens = mysqlParser.getAllTokens(sql); const tokens = mysqlParser.getAllTokens(sql);
test('token counts', () => { test('token counts', () => {
expect(tokens.length - 1).toBe(12); expect(tokens.length).toBe(12);
}); });
}); });

View File

@ -1,5 +1,5 @@
import GenericSQL from '../../../src/parser/generic'; import GenericSQL from '../../../src/parser/generic';
import SqlParserListener from '../../../src/lib/generic/SqlParserListener'; import { SqlParserListener } from '../../../src/lib/generic/SqlParserListener';
describe('Generic SQL Listener Tests', () => { describe('Generic SQL Listener Tests', () => {
const expectTableName = 'user1'; const expectTableName = 'user1';
@ -10,9 +10,9 @@ describe('Generic SQL Listener Tests', () => {
test('Listener enterTableName', async () => { test('Listener enterTableName', async () => {
let result = ''; let result = '';
class MyListener extends SqlParserListener { class MyListener implements SqlParserListener {
enterTableName = (ctx): void => { enterTableName = (ctx): void => {
result = ctx.getText().toLowerCase(); result = ctx.text.toLowerCase();
} }
} }
const listenTableName: any = new MyListener(); const listenTableName: any = new MyListener();

View File

@ -1,5 +1,6 @@
import GenericSQL from '../../../src/parser/generic'; import GenericSQL from '../../../src/parser/generic';
import SqlParserVisitor from '../../../src/lib/generic/SqlParserVisitor'; import { SqlParserVisitor } from '../../../src/lib/generic/SqlParserVisitor';
import { AbstractParseTreeVisitor } from 'antlr4ts/tree';
describe('Generic SQL Visitor Tests', () => { describe('Generic SQL Visitor Tests', () => {
const expectTableName = 'user1'; const expectTableName = 'user1';
@ -12,14 +13,13 @@ describe('Generic SQL Visitor Tests', () => {
test('Visitor visitTableName', () => { test('Visitor visitTableName', () => {
let result = ''; let result = '';
class MyVisitor extends SqlParserVisitor<any> { class MyVisitor extends AbstractParseTreeVisitor<any> implements SqlParserVisitor<any> {
constructor() { protected defaultResult() {
super(); return result;
} }
visitTableName = (ctx): void => { visitTableName = (ctx): void => {
result = ctx.getText().toLowerCase(); result = ctx.text.toLowerCase();
super.visitTableName?.(ctx);
} }
} }
const visitor = new MyVisitor(); const visitor = new MyVisitor();

View File

@ -5,12 +5,12 @@ describe('HiveSQL Lexer tests', () => {
test('select token counts', () => { test('select token counts', () => {
const sql = 'SELECT * FROM t1'; const sql = 'SELECT * FROM t1';
const tokens = parser.getAllTokens(sql); const tokens = parser.getAllTokens(sql);
expect(tokens.length - 1).toBe(4); expect(tokens.length).toBe(7);
}); });
test('select token counts', () => { test('select token counts', () => {
const sql = 'show create table_name;'; const sql = 'show create table_name;';
const tokens = parser.getAllTokens(sql); const tokens = parser.getAllTokens(sql);
expect(tokens.length - 1).toBe(4); expect(tokens.length).toBe(6);
}); });
}); });

View File

@ -1,4 +1,4 @@
import HiveSqlListener from '../../../src/lib/hive/HiveSqlListener'; import { HiveSqlListener } from '../../../src/lib/hive/HiveSqlListener';
import HiveSQL from '../../../src/parser/hive'; import HiveSQL from '../../../src/parser/hive';
@ -10,28 +10,28 @@ describe('Hive SQL Listener Tests', () => {
const parserTree = parser.parse(sql); const parserTree = parser.parse(sql);
let result = ''; let result = '';
class MyListener extends HiveSqlListener { class MyListener implements HiveSqlListener {
enterSelect_list = (ctx): void => { enterSelectItem(ctx) {
result = ctx.getText(); result = ctx.text;
} }
} }
const listenTableName: any = new MyListener(); const listenTableName: any = new MyListener();
await parser.listen(listenTableName, parserTree); await parser.listen(listenTableName, parserTree);
expect(result).toBe(expectTableName); expect(result).toBe(expectTableName.toUpperCase());
}); });
test('Listener enterCreateTable', async () => { test('Listener enterCreateTable', async () => {
const sql = `drop table table_name;`; const sql = `drop table table_name;`;
const parserTree = parser.parse(sql); const parserTree = parser.parse(sql);
let result = ''; let result = '';
class MyListener extends HiveSqlListener { class MyListener implements HiveSqlListener {
enterDrop_stmt = (ctx): void => { enterDropTableStatement(ctx) {
result = ctx.getText(); result = ctx.text;
} }
} }
const listenTableName: any = new MyListener(); const listenTableName: any = new MyListener();
await parser.listen(listenTableName, parserTree); await parser.listen(listenTableName, parserTree);
expect(result).toBe('droptabletable_name'); expect(result).toBe('DROPTABLETABLE_NAME');
}); });
}); });

View File

@ -13,10 +13,8 @@ describe('Hive SQL Syntax Tests', () => {
expect(result.length).toBe(0); expect(result.length).toBe(0);
}); });
test('Wrong Select Statement', () => { test('Wrong Select Statement', () => {
const sql = 'SELECT add ABC from Where ;'; const sql = 'SELECT add ABC FROM WHERE;';
const result = parser.validate(sql); const result = parser.validate(sql);
expect(result.length).toBe(2); expect(result.length).toBe(2);
expect(result[0].message).toBe(`no viable alternative at input 'SELECTaddABCfromWhere'`);
expect(result[1].message).toBe(`mismatched input 'Where' expecting <EOF>`);
}); });
}); });

View File

@ -1,7 +1,8 @@
import HiveSqlVisitor from '../../../src/lib/hive/HiveSqlVisitor'; import { AbstractParseTreeVisitor } from 'antlr4ts/tree/AbstractParseTreeVisitor';
import { HiveSqlVisitor } from '../../../src/lib/hive/HiveSqlVisitor';
import HiveSQL from '../../../src/parser/hive'; import HiveSQL from '../../../src/parser/hive';
describe('Generic SQL Visitor Tests', () => { describe('Hive SQL Visitor Tests', () => {
const expectTableName = 'dm_gis.dlv_addr_tc_count'; const expectTableName = 'dm_gis.dlv_addr_tc_count';
const sql = `select citycode,tc,inc_day from ${expectTableName} where inc_day='20190501' limit 100;`; const sql = `select citycode,tc,inc_day from ${expectTableName} where inc_day='20190501' limit 100;`;
const parser = new HiveSQL(); const parser = new HiveSQL();
@ -12,10 +13,14 @@ describe('Generic SQL Visitor Tests', () => {
test('Visitor visitTableName', () => { test('Visitor visitTableName', () => {
let result = ''; let result = '';
class MyVisitor extends HiveSqlVisitor<any> { class MyVisitor extends AbstractParseTreeVisitor<any> implements HiveSqlVisitor<any> {
visitTable_name = (ctx): void => {
result = ctx.getText().toLowerCase(); defaultResult() {
super.visitTable_name?.(ctx); return result;
}
visitTableName(ctx) {
result = ctx.text.toLowerCase();
} }
} }

View File

@ -0,0 +1,244 @@
SELECT * FROM onek
WHERE onek.unique1 < 10
ORDER BY onek.unique1;
SELECT onek.unique1, onek.stringu1 FROM onek
WHERE onek.unique1 < 20
ORDER BY unique1 using >;
SELECT onek.unique1, onek.stringu1 FROM onek
WHERE onek.unique1 > 980
ORDER BY stringu1 using <;
SELECT onek.unique1, onek.string4 FROM onek
WHERE onek.unique1 > 980
ORDER BY string4 using <, unique1 using >;
SELECT onek.unique1, onek.string4 FROM onek
WHERE onek.unique1 > 980
ORDER BY string4 using >, unique1 using <;
--
-- awk '{if($1<20){print $1,$16;}else{next;}}' onek.data |
-- sort +0nr -1 +1d -2
--
SELECT onek.unique1, onek.string4 FROM onek
WHERE onek.unique1 < 20
ORDER BY unique1 using >, string4 using <;
--
-- awk '{if($1<20){print $1,$16;}else{next;}}' onek.data |
-- sort +0n -1 +1dr -2
--
SELECT onek.unique1, onek.string4 FROM onek
WHERE onek.unique1 < 20
ORDER BY unique1 using <, string4 using >;
--
-- test partial btree indexes
--
-- As of 7.2, planner probably won't pick an indexscan without stats,
-- so ANALYZE first. Also, we want to prevent it from picking a bitmapscan
-- followed by sort, because that could hide index ordering problems.
--
ANALYZE onek2;
SET enable_seqscan TO off;
SET enable_bitmapscan TO off;
SET enable_sort TO off;
--
-- awk '{if($1<10){print $0;}else{next;}}' onek.data | sort +0n -1
--
SELECT onek2.* FROM onek2 WHERE onek2.unique1 < 10;
--
-- awk '{if($1<20){print $1,$14;}else{next;}}' onek.data | sort +0nr -1
--
SELECT onek2.unique1, onek2.stringu1 FROM onek2
WHERE onek2.unique1 < 20
ORDER BY unique1 using >;
--
-- awk '{if($1>980){print $1,$14;}else{next;}}' onek.data | sort +1d -2
--
SELECT onek2.unique1, onek2.stringu1 FROM onek2
WHERE onek2.unique1 > 980;
RESET enable_seqscan;
RESET enable_bitmapscan;
RESET enable_sort;
SELECT two, stringu1, ten, string4
INTO TABLE tmp
FROM onek;
--
-- awk '{print $1,$2;}' person.data |
-- awk '{if(NF!=2){print $3,$2;}else{print;}}' - emp.data |
-- awk '{if(NF!=2){print $3,$2;}else{print;}}' - student.data |
-- awk 'BEGIN{FS=" ";}{if(NF!=2){print $4,$5;}else{print;}}' - stud_emp.data
--
-- SELECT name, age FROM person*; ??? check if different
SELECT p.name, p.age FROM person* p;
--
-- awk '{print $1,$2;}' person.data |
-- awk '{if(NF!=2){print $3,$2;}else{print;}}' - emp.data |
-- awk '{if(NF!=2){print $3,$2;}else{print;}}' - student.data |
-- awk 'BEGIN{FS=" ";}{if(NF!=1){print $4,$5;}else{print;}}' - stud_emp.data |
-- sort +1nr -2
--
SELECT p.name, p.age FROM person* p ORDER BY age using >, name;
--
-- Test some cases involving whole-row Var referencing a subquery
--
select foo from (select 1 offset 0) as foo;
select foo from (select null offset 0) as foo;
select foo from (select 'xyzzy',1,null offset 0) as foo;
--
-- Test VALUES lists
--
select * from onek, (values(147, 'RFAAAA'), (931, 'VJAAAA')) as v (i, j)
WHERE onek.unique1 = v.i and onek.stringu1 = v.j;
-- a more complex case
-- looks like we're coding lisp :-)
select * from onek,
(values ((select i from
(values(10000), (2), (389), (1000), (2000), ((select 10029))) as foo(i)
order by i asc limit 1))) bar (i)
where onek.unique1 = bar.i;
-- try VALUES in a subquery
select * from onek
where (unique1,ten) in (values (1,1), (20,0), (99,9), (17,99))
order by unique1;
-- VALUES is also legal as a standalone query or a set-operation member
VALUES (1,2), (3,4+4), (7,77.7);
VALUES (1,2), (3,4+4), (7,77.7)
UNION ALL
SELECT 2+2, 57
UNION ALL
TABLE int8_tbl;
--
-- Test ORDER BY options
--
CREATE TEMP TABLE foo (f1 int);
INSERT INTO foo VALUES (42),(3),(10),(7),(null),(null),(1);
SELECT * FROM foo ORDER BY f1;
SELECT * FROM foo ORDER BY f1 ASC; -- same thing
SELECT * FROM foo ORDER BY f1 NULLS FIRST;
SELECT * FROM foo ORDER BY f1 DESC;
SELECT * FROM foo ORDER BY f1 DESC NULLS LAST;
-- check if indexscans do the right things
CREATE INDEX fooi ON foo (f1);
SET enable_sort = false;
SELECT * FROM foo ORDER BY f1;
SELECT * FROM foo ORDER BY f1 NULLS FIRST;
SELECT * FROM foo ORDER BY f1 DESC;
SELECT * FROM foo ORDER BY f1 DESC NULLS LAST;
DROP INDEX fooi;
CREATE INDEX fooi ON foo (f1 DESC);
SELECT * FROM foo ORDER BY f1;
SELECT * FROM foo ORDER BY f1 NULLS FIRST;
SELECT * FROM foo ORDER BY f1 DESC;
SELECT * FROM foo ORDER BY f1 DESC NULLS LAST;
DROP INDEX fooi;
CREATE INDEX fooi ON foo (f1 DESC NULLS LAST);
SELECT * FROM foo ORDER BY f1;
SELECT * FROM foo ORDER BY f1 NULLS FIRST;
SELECT * FROM foo ORDER BY f1 DESC;
SELECT * FROM foo ORDER BY f1 DESC NULLS LAST;
--
-- Test planning of some cases with partial indexes
--
-- partial index is usable
explain (costs off)
select * from onek2 where unique2 = 11 and stringu1 = 'ATAAAA';
select * from onek2 where unique2 = 11 and stringu1 = 'ATAAAA';
-- actually run the query with an analyze to use the partial index
explain (costs off, analyze on, timing off, summary off)
select * from onek2 where unique2 = 11 and stringu1 = 'ATAAAA';
explain (costs off)
select unique2 from onek2 where unique2 = 11 and stringu1 = 'ATAAAA';
select unique2 from onek2 where unique2 = 11 and stringu1 = 'ATAAAA';
-- partial index predicate implies clause, so no need for retest
explain (costs off)
select * from onek2 where unique2 = 11 and stringu1 < 'B';
select * from onek2 where unique2 = 11 and stringu1 < 'B';
explain (costs off)
select unique2 from onek2 where unique2 = 11 and stringu1 < 'B';
select unique2 from onek2 where unique2 = 11 and stringu1 < 'B';
-- but if it's an update target, must retest anyway
explain (costs off)
select unique2 from onek2 where unique2 = 11 and stringu1 < 'B' for update;
select unique2 from onek2 where unique2 = 11 and stringu1 < 'B' for update;
-- partial index is not applicable
explain (costs off)
select unique2 from onek2 where unique2 = 11 and stringu1 < 'C';
select unique2 from onek2 where unique2 = 11 and stringu1 < 'C';
-- partial index implies clause, but bitmap scan must recheck predicate anyway
SET enable_indexscan TO off;
explain (costs off)
select unique2 from onek2 where unique2 = 11 and stringu1 < 'B';
select unique2 from onek2 where unique2 = 11 and stringu1 < 'B';
RESET enable_indexscan;
-- check multi-index cases too
explain (costs off)
select unique1, unique2 from onek2
where (unique2 = 11 or unique1 = 0) and stringu1 < 'B';
select unique1, unique2 from onek2
where (unique2 = 11 or unique1 = 0) and stringu1 < 'B';
explain (costs off)
select unique1, unique2 from onek2
where (unique2 = 11 and stringu1 < 'B') or unique1 = 0;
select unique1, unique2 from onek2
where (unique2 = 11 and stringu1 < 'B') or unique1 = 0;
--
-- Test some corner cases that have been known to confuse the planner
--
-- ORDER BY on a constant doesn't really need any sorting
SELECT 1 AS x ORDER BY x;
-- But ORDER BY on a set-valued expression does
create function sillysrf(int) returns setof int as
'values (1),(10),(2),($1)' language sql immutable;
select sillysrf(42);
select sillysrf(-1) order by 1;
drop function sillysrf(int);
-- X = X isn't a no-op, it's effectively X IS NOT NULL assuming = is strict
-- (see bug #5084)
select * from (values (2),(null),(1)) v(k) where k = k order by k;
select * from (values (2),(null),(1)) v(k) where k = k;
-- Test partitioned tables with no partitions, which should be handled the
-- same as the non-inheritance case when expanding its RTE.
create table list_parted_tbl (a int,b int) partition by list (a);
create table list_parted_tbl1 partition of list_parted_tbl
for values in (1) partition by list(b);
explain (costs off) select * from list_parted_tbl;
drop table list_parted_tbl;

View File

@ -7,6 +7,6 @@ describe('PostgresSQL Lexer tests', () => {
const tokens = mysqlParser.getAllTokens(sql); const tokens = mysqlParser.getAllTokens(sql);
test('token counts', () => { test('token counts', () => {
expect(tokens.length - 1).toBe(12); expect(tokens.length).toBe(12);
}); });
}); });

View File

@ -1,4 +1,5 @@
import PostgreSQLParserListener from '../../../src/lib/pgsql/PostgreSQLParserListener'; import { Target_listContext } from '../../../src/lib/pgsql/PostgreSQLParser';
import { PostgreSQLParserListener } from '../../../src/lib/pgsql/PostgreSQLParserListener';
import PostgresSQL from '../../../src/parser/pgsql'; import PostgresSQL from '../../../src/parser/pgsql';
describe('PostgresSQL Listener Tests', () => { describe('PostgresSQL Listener Tests', () => {
@ -10,10 +11,9 @@ describe('PostgresSQL Listener Tests', () => {
test('Listener enterTableName', async () => { test('Listener enterTableName', async () => {
let result = ''; let result = '';
class MyListener extends PostgreSQLParserListener { class MyListener implements PostgreSQLParserListener {
// eslint-disable-next-line camelcase enterTable_ref(ctx) {
enterTable_ref = (ctx): void => { result = ctx.text.toLowerCase();
result = ctx.getText().toLowerCase();
} }
} }
const listenTableName: any = new MyListener(); const listenTableName: any = new MyListener();

View File

@ -0,0 +1,18 @@
import PostgresSQL from "../../../src/parser/pgsql";
import { readSQL } from "../../helper";
const parser = new PostgresSQL();
const features = {
base: readSQL(__dirname, "select.sql"),
};
describe("Postgre SQL Query Statement Tests", () => {
describe("Base Select", () => {
features.base.forEach((sql) => {
it(sql, () => {
expect(parser.validate(sql).length).toBe(0);
});
});
});
});

View File

@ -1,10 +1,10 @@
import PostgresSQL from "../../../src/parser/pgsql"; import PostgresSQL from "../../../src/parser/pgsql";
describe('Generic SQL Syntax Tests', () => { describe('PostgresSQL SQL Syntax Tests', () => {
const parser = new PostgresSQL(); const parser = new PostgresSQL();
test('Select Statement', () => { test('Select Statement', () => {
const sql = 'select id,name from user1;'; const sql = 'select id, t_name from user1;';
const result = parser.validate(sql); const result = parser.validate(sql);
expect(result.length).toBe(0); expect(result.length).toBe(0);
@ -15,4 +15,11 @@ describe('Generic SQL Syntax Tests', () => {
const result = parser.validate(sql); const result = parser.validate(sql);
expect(result.length).toBe(0); expect(result.length).toBe(0);
}); });
test('Select 1+1', () => {
const sql = 'SELECT 1+1;';
const result = parser.validate(sql);
expect(result.length).toBe(0);
});
}); });

View File

@ -1,4 +1,5 @@
import PostgreSQLParserVisitor from "../../../src/lib/pgsql/PostgreSQLParserVisitor"; import { AbstractParseTreeVisitor } from "antlr4ts/tree/AbstractParseTreeVisitor";
import { PostgreSQLParserVisitor } from "../../../src/lib/pgsql/PostgreSQLParserVisitor";
import PostgresSQL from "../../../src/parser/pgsql"; import PostgresSQL from "../../../src/parser/pgsql";
describe('Generic SQL Visitor Tests', () => { describe('Generic SQL Visitor Tests', () => {
@ -12,11 +13,13 @@ describe('Generic SQL Visitor Tests', () => {
test('Visitor visitTableName', () => { test('Visitor visitTableName', () => {
let result = ''; let result = '';
class MyVisitor extends PostgreSQLParserVisitor<any> { class MyVisitor extends AbstractParseTreeVisitor<any> implements PostgreSQLParserVisitor<any> {
// eslint-disable-next-line camelcase protected defaultResult() {
visitTable_ref = (ctx): void => { return result;
result = ctx.getText().toLowerCase(); }
super.visitTable_ref?.(ctx);
visitTable_ref(ctx) {
result = ctx.text.toLowerCase();
} }
} }
const visitor: any = new MyVisitor(); const visitor: any = new MyVisitor();

View File

@ -7,6 +7,6 @@ describe('PLSQL Lexer tests', () => {
const tokens = parser.getAllTokens(sql); const tokens = parser.getAllTokens(sql);
test('token counts', () => { test('token counts', () => {
expect(tokens.length - 1).toBe(12); expect(tokens.length).toBe(12);
}); });
}); });

View File

@ -1,4 +1,4 @@
import PlSqlParserListener from '../../../src/lib/plsql/PlSqlParserListener'; import { PlSqlParserListener } from '../../../src/lib/plsql/PlSqlParserListener';
import PLSQL from '../../../src/parser/plsql'; import PLSQL from '../../../src/parser/plsql';
describe('PLSQL Listener Tests', () => { describe('PLSQL Listener Tests', () => {
@ -10,10 +10,10 @@ describe('PLSQL Listener Tests', () => {
test('Listener enterTableName', async () => { test('Listener enterTableName', async () => {
let result = ''; let result = '';
class MyListener extends PlSqlParserListener { class MyListener implements PlSqlParserListener {
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
enterTable_ref_list = (ctx): void => { enterTable_ref_list = (ctx): void => {
result = ctx.getText().toLowerCase(); result = ctx.text.toLowerCase();
} }
} }
const listenTableName: any = new MyListener(); const listenTableName: any = new MyListener();

View File

@ -1,4 +1,5 @@
import PlSqlParserVisitor from '../../../src/lib/plsql/PlSqlParserVisitor'; import { AbstractParseTreeVisitor } from 'antlr4ts/tree/AbstractParseTreeVisitor';
import { PlSqlParserVisitor } from '../../../src/lib/plsql/PlSqlParserVisitor';
import PLSQL from '../../../src/parser/plsql'; import PLSQL from '../../../src/parser/plsql';
describe('PLSQL Visitor Tests', () => { describe('PLSQL Visitor Tests', () => {
@ -10,11 +11,13 @@ describe('PLSQL Visitor Tests', () => {
test('Visitor visitTable_ref_list', () => { test('Visitor visitTable_ref_list', () => {
let result = ''; let result = '';
class MyVisitor extends PlSqlParserVisitor<any> { class MyVisitor extends AbstractParseTreeVisitor<any> implements PlSqlParserVisitor<any> {
protected defaultResult() {
return result;
}
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
visitTable_ref_list = (ctx): void => { visitTable_ref_list = (ctx): void => {
result = ctx.getText().toLowerCase(); result = ctx.text.toLowerCase();
super.visitTable_ref_list?.(ctx);
} }
} }
const visitor: any = new MyVisitor(); const visitor: any = new MyVisitor();

View File

@ -6,12 +6,12 @@ describe('SparkSQL Lexer tests', () => {
test('select id,name from user1;', () => { test('select id,name from user1;', () => {
const sql = `select id,name from user1;`; const sql = `select id,name from user1;`;
const tokens = parser.getAllTokens(sql); const tokens = parser.getAllTokens(sql);
expect(tokens.length - 1).toBe(10); expect(tokens.length).toBe(10);
}); });
test('SELECT * FROM t WHERE x = 1 AND y = 2;', () => { test('SELECT * FROM t WHERE x = 1 AND y = 2;', () => {
const sql = `SELECT * FROM t WHERE x = 1 AND y = 2;`; const sql = `SELECT * FROM t WHERE x = 1 AND y = 2;`;
const tokens = parser.getAllTokens(sql); const tokens = parser.getAllTokens(sql);
expect(tokens.length - 1).toBe(24); expect(tokens.length).toBe(24);
}); });
}); });

View File

@ -1,4 +1,4 @@
import SparkSqlListener from '../../../src/lib/spark/SparkSqlListener'; import { SparkSqlListener } from '../../../src/lib/spark/SparkSqlListener';
import SparkSQL from '../../../src/parser/spark'; import SparkSQL from '../../../src/parser/spark';
describe('Spark SQL Listener Tests', () => { describe('Spark SQL Listener Tests', () => {
@ -10,9 +10,9 @@ describe('Spark SQL Listener Tests', () => {
test('Listener enterTableName', () => { test('Listener enterTableName', () => {
let result = ''; let result = '';
class MyListener extends SparkSqlListener { class MyListener implements SparkSqlListener {
enterTableName = (ctx): void => { enterTableName = (ctx): void => {
result = ctx.getText().toLowerCase(); result = ctx.text.toLowerCase();
} }
} }
const listenTableName: any = new MyListener(); const listenTableName: any = new MyListener();

View File

@ -10,7 +10,7 @@ const validateTest = (sqls) => {
error(i, sql); error(i, sql);
error(result); error(result);
} }
expect(result.length).toBe(0); expect(result.find(i => i.message)).toBeUndefined();
}); });
}; };

View File

@ -1,4 +1,5 @@
import SparkSqlVisitor from '../../../src/lib/spark/SparkSqlVisitor'; import { AbstractParseTreeVisitor } from 'antlr4ts/tree/AbstractParseTreeVisitor';
import { SparkSqlVisitor } from '../../../src/lib/spark/SparkSqlVisitor';
import SparkSQL from '../../../src/parser/spark'; import SparkSQL from '../../../src/parser/spark';
describe('Spark SQL Visitor Tests', () => { describe('Spark SQL Visitor Tests', () => {
@ -12,10 +13,12 @@ describe('Spark SQL Visitor Tests', () => {
test('Visitor visitTableName', () => { test('Visitor visitTableName', () => {
let result = ''; let result = '';
class MyVisitor extends SparkSqlVisitor<any> { class MyVisitor extends AbstractParseTreeVisitor<any> implements SparkSqlVisitor<any> {
protected defaultResult() {
return result;
}
visitTableName = (ctx): void => { visitTableName = (ctx): void => {
result = ctx.getText().toLowerCase(); result = ctx.text.toLowerCase();
super.visitTableName?.(ctx);
} }
} }
const visitor: any = new MyVisitor(); const visitor: any = new MyVisitor();

View File

@ -7,6 +7,6 @@ describe('trinoSQL Lexer tests', () => {
const tokens = parser.getAllTokens(sql); const tokens = parser.getAllTokens(sql);
test('token counts', () => { test('token counts', () => {
expect(tokens.length - 1).toBe(7); expect(tokens.length).toBe(7);
}); });
}); });

View File

@ -1,5 +1,5 @@
import trinoSQL from '../../../src/parser/trinosql'; import trinoSQL from '../../../src/parser/trinosql';
import TrinoSqlParserListener from '../../../src/lib/trinosql/TrinoSqlListener'; import { TrinoSqlListener } from '../../../src/lib/trinosql/TrinoSqlListener';
describe('trino SQL Listener Tests', () => { describe('trino SQL Listener Tests', () => {
const expectTableName = 'user1'; const expectTableName = 'user1';
@ -10,14 +10,10 @@ describe('trino SQL Listener Tests', () => {
test('Listener enterTableName', async () => { test('Listener enterTableName', async () => {
let result = ''; let result = '';
class MyListener extends TrinoSqlParserListener { class MyListener implements TrinoSqlListener {
constructor() {
super()
}
enterTableName = (ctx): void => { enterTableName = (ctx): void => {
result = ctx.getText().toLowerCase(); result = ctx.text.toLowerCase();
}; };
} }
const listenTableName = new MyListener(); const listenTableName = new MyListener();

Some files were not shown because too many files have changed in this diff Show More