feat: add generic and plsql basic parser file
This commit is contained in:
parent
68800312d3
commit
f85163892a
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,5 +3,5 @@ package-lock.json
|
||||
.DS_Store
|
||||
.vscode
|
||||
.history
|
||||
lib/
|
||||
dist/
|
||||
src/**/.antlr
|
@ -8,3 +8,4 @@ package-lock.json
|
||||
site
|
||||
src/
|
||||
docs
|
||||
lib/grammar
|
||||
|
15
CONTRIBUTING.md
Normal file
15
CONTRIBUTING.md
Normal file
@ -0,0 +1,15 @@
|
||||
# dt-sql-parser
|
||||
|
||||
summary
|
||||
|
||||
## How to contribute
|
||||
|
||||
## Prerequisites
|
||||
|
||||
## Semantic Versioning
|
||||
|
||||
## Branch Organization
|
||||
|
||||
## Release Process
|
||||
|
||||
## Source Code Organization
|
33
NeREADME.md
Normal file
33
NeREADME.md
Normal file
@ -0,0 +1,33 @@
|
||||
# dt-sql-parser
|
||||
|
||||
[![NPM version][npm-image]][npm-url]
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/dt-sql-parser.svg?style=flat-square
|
||||
[npm-url]: https://www.npmjs.com/package/dt-sql-parser
|
||||
|
||||
## Installation
|
||||
|
||||
## Usage
|
||||
|
||||
### Basic
|
||||
|
||||
### Syntax validation
|
||||
|
||||
### Visitor
|
||||
|
||||
### Listener
|
||||
|
||||
## Example
|
||||
|
||||
## Roadmap
|
||||
|
||||
- Unify parser generate to Antlr4
|
||||
- Generic SQL
|
||||
- Flink SQL
|
||||
- Libra SQL
|
||||
- TiDB
|
||||
MySQL Compatible Syntax
|
||||
|
||||
## Contributing
|
||||
|
||||
## License
|
@ -3,15 +3,14 @@ const exec = require('child_process').exec;
|
||||
|
||||
const antlr4 = path.resolve(__dirname, 'antlr-4.8-complete.jar');
|
||||
const grammars = path.resolve(__dirname, '../src/grammar');
|
||||
const output = path.resolve(__dirname, '../src/parser');
|
||||
const output = path.resolve(__dirname, '../src/lib');
|
||||
|
||||
const entry = [
|
||||
'generic',
|
||||
'mysql',
|
||||
'hive',
|
||||
'plsql',
|
||||
'spark',
|
||||
'tsql',
|
||||
'impala',
|
||||
];
|
||||
|
||||
entry.forEach((language) => {
|
||||
|
@ -17,6 +17,5 @@
|
||||
- Generic SQL
|
||||
- Flink SQL
|
||||
- Libra SQL
|
||||
- Oracle SQL
|
||||
- TiDB
|
||||
MySQL Compatible Syntax
|
||||
|
@ -1,5 +1,13 @@
|
||||
# Tutorials
|
||||
|
||||
## Antlr4 installation
|
||||
|
||||
## How to extend new grammar
|
||||
|
||||
## How to expose Javascript interface in this project
|
||||
|
||||
## Integrate with Monaco Editor
|
||||
|
||||
## Reference
|
||||
|
||||
- <https://tomassetti.me/writing-a-browser-based-editor-using-monaco-and-antlr/>
|
||||
|
@ -27,7 +27,7 @@ module.exports = {
|
||||
// coverageDirectory: null,
|
||||
|
||||
// An array of regexp pattern strings used to skip coverage collection
|
||||
coveragePathIgnorePatterns: ["/node_modules/"],
|
||||
coveragePathIgnorePatterns: ['/node_modules/'],
|
||||
|
||||
// A list of reporter names that Jest uses when writing coverage reports
|
||||
// coverageReporters: [
|
||||
@ -129,7 +129,7 @@ module.exports = {
|
||||
// snapshotSerializers: [],
|
||||
|
||||
// The test environment that will be used for testing
|
||||
testEnvironment: "node",
|
||||
testEnvironment: 'node',
|
||||
|
||||
// Options that will be passed to the testEnvironment
|
||||
// testEnvironmentOptions: {},
|
||||
@ -144,7 +144,7 @@ module.exports = {
|
||||
// ],
|
||||
|
||||
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
|
||||
testPathIgnorePatterns: ["/node_modules/"],
|
||||
testPathIgnorePatterns: ['/node_modules/'],
|
||||
|
||||
// The regexp pattern or array of patterns that Jest uses to detect test files
|
||||
// testRegex: [],
|
||||
@ -163,11 +163,11 @@ module.exports = {
|
||||
|
||||
// A map from regular expressions to paths to transformers
|
||||
transform: {
|
||||
"^.+\\.(t|j)sx?$": "ts-jest",
|
||||
'^.+\\.(t|j)sx?$': 'ts-jest',
|
||||
},
|
||||
|
||||
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
|
||||
transformIgnorePatterns: ["/node_modules/"],
|
||||
transformIgnorePatterns: ['/node_modules/'],
|
||||
|
||||
// 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,
|
||||
|
14
lib/index.js
14
lib/index.js
@ -1,14 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./core"), exports);
|
||||
__exportStar(require("./utils"), exports);
|
@ -1,123 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.splitSql = exports.replaceStrFormIndexArr = void 0;
|
||||
function replaceStrFormIndexArr(str, replaceStr, indexArr) {
|
||||
let result = '';
|
||||
let index = 0;
|
||||
if (!indexArr || indexArr.length < 1) {
|
||||
return str;
|
||||
}
|
||||
for (let i = 0; i < indexArr.length; i++) {
|
||||
const indexItem = indexArr[i];
|
||||
const begin = indexItem.begin;
|
||||
result = result + str.substring(index, begin) + replaceStr;
|
||||
index = indexItem.end + 1;
|
||||
if (i == indexArr.length - 1) {
|
||||
result = result + str.substring(index);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
exports.replaceStrFormIndexArr = replaceStrFormIndexArr;
|
||||
function splitSql(sql) {
|
||||
let haveEnd = true;
|
||||
if (!sql.endsWith(';')) {
|
||||
sql += ';';
|
||||
haveEnd = false;
|
||||
}
|
||||
function pushSql(parser, sql) {
|
||||
if (!haveEnd && parser.index == sql.length - 1) {
|
||||
parser.sqls.push(parser.index - 1);
|
||||
parser.queue = '';
|
||||
}
|
||||
else {
|
||||
parser.sqls.push(parser.index);
|
||||
parser.queue = '';
|
||||
}
|
||||
}
|
||||
// 处理引号
|
||||
function quoteToken(parser, sql) {
|
||||
const queue = parser.queue;
|
||||
const endsWith = queue[queue.length - 1];
|
||||
if (endsWith == '\'' || endsWith == '"') {
|
||||
const nextToken = sql.indexOf(endsWith, parser.index + 1);
|
||||
if (nextToken != -1) {
|
||||
parser.index = nextToken;
|
||||
parser.queue = '';
|
||||
}
|
||||
else {
|
||||
parser.index = sql.length - 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// 处理单行注释
|
||||
function singleLineCommentToken(parser, sql) {
|
||||
let queue = parser.queue;
|
||||
if (queue.endsWith('--')) {
|
||||
const nextToken = sql.indexOf('\n', parser.index + 1);
|
||||
if (nextToken != -1) {
|
||||
parser.index = nextToken;
|
||||
queue = '';
|
||||
}
|
||||
else {
|
||||
parser.index = sql.length - 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// 处理多行注释
|
||||
function multipleLineCommentToken(parser, sql) {
|
||||
const queue = parser.queue;
|
||||
if (queue.endsWith('/*')) {
|
||||
const nextToken = sql.indexOf('*/', parser.index + 1);
|
||||
if (nextToken != -1) {
|
||||
parser.index = nextToken + 1;
|
||||
parser.queue = '';
|
||||
}
|
||||
else {
|
||||
parser.index = sql.length - 1;
|
||||
parser.queue = '';
|
||||
}
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
function splitToken(parser, sql) {
|
||||
const queue = parser.queue;
|
||||
if (queue.endsWith(';')) {
|
||||
pushSql(parser, sql);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
const parser = {
|
||||
index: 0,
|
||||
queue: '',
|
||||
sqls: [],
|
||||
};
|
||||
for (parser.index = 0; parser.index < sql.length; parser.index++) {
|
||||
const char = sql[parser.index];
|
||||
parser.queue += char;
|
||||
const tokenFuncs = [
|
||||
quoteToken,
|
||||
singleLineCommentToken,
|
||||
multipleLineCommentToken,
|
||||
splitToken,
|
||||
];
|
||||
for (let i = 0; i < tokenFuncs.length; i++) {
|
||||
tokenFuncs[i](parser, sql);
|
||||
}
|
||||
if (parser.index == sql.length - 1 && parser.queue) {
|
||||
pushSql(parser, sql);
|
||||
}
|
||||
}
|
||||
return parser.sqls;
|
||||
}
|
||||
exports.splitSql = splitSql;
|
@ -12,10 +12,10 @@
|
||||
"impala",
|
||||
"bigdata"
|
||||
],
|
||||
"main": "lib/index.js",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"antlr": "node build/antlr4.js",
|
||||
"build": "npm test && rm -rf lib && tsc",
|
||||
"antlr4": "node build/antlr4.js",
|
||||
"build": "npm test && rm -rf dist && tsc",
|
||||
"eslint": "eslint ./src/**/*.ts",
|
||||
"check-types": "tsc --skipLibCheck",
|
||||
"test": "jest"
|
||||
|
@ -1,63 +0,0 @@
|
||||
import { Token, Lexer } from 'antlr4';
|
||||
|
||||
import ParserErrorListener, { ParserError } from './parserErrorListener';
|
||||
|
||||
/**
|
||||
* Custom Parser class, subclass needs extends it.
|
||||
*/
|
||||
export default abstract class BaseParser {
|
||||
/**
|
||||
* Create antrl4 Lexer object
|
||||
* @param input source string
|
||||
*/
|
||||
public abstract createLexer(input: string): Lexer;
|
||||
|
||||
/**
|
||||
* Create Parser by lexer
|
||||
* @param lexer Lexer
|
||||
*/
|
||||
public abstract createParserFromLexer(lexer: Lexer);
|
||||
|
||||
public getAllTokens(input: string): Token[] {
|
||||
return this.createLexer(input).getAllTokens();
|
||||
};
|
||||
|
||||
public createParser(input: string) {
|
||||
const lexer = this.createLexer(input);
|
||||
return this.createParserFromLexer(lexer);
|
||||
}
|
||||
|
||||
public parserTree(input: string) {
|
||||
const lexer = this.createLexer(input);
|
||||
const parser: any = this.createParserFromLexer(lexer);
|
||||
parser.buildParseTrees = true;
|
||||
return parser;
|
||||
}
|
||||
|
||||
/**
|
||||
* It convert tree to string, it's convenient to use in unit test.
|
||||
* @param string input
|
||||
*/
|
||||
public parserTreeToString(input: string): string {
|
||||
const parser = this.parserTree(input);
|
||||
const tree = parser.statement();
|
||||
return tree.toStringTree(parser.ruleNames);
|
||||
}
|
||||
|
||||
public validate(input: string): ParserError[] {
|
||||
const lexerError = []; const syntaxErrors = [];
|
||||
const lexer = this.createLexer(input);
|
||||
lexer.removeErrorListeners();
|
||||
lexer.addErrorListener(new ParserErrorListener(lexerError));
|
||||
|
||||
const parser: any = this.createParserFromLexer(lexer);
|
||||
parser.buildParseTrees = true;
|
||||
|
||||
parser.removeErrorListeners();
|
||||
parser.addErrorListener(new ParserErrorListener(syntaxErrors));
|
||||
|
||||
parser.statement();
|
||||
|
||||
return lexerError.concat(syntaxErrors);
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
import { Token, Recognizer } from 'antlr4';
|
||||
import { ErrorListener } from 'antlr4/error';
|
||||
|
||||
export interface ParserError {
|
||||
startLine: number;
|
||||
endLine: number;
|
||||
startCol: number;
|
||||
endCol: number;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export default class ParserErrorListener extends ErrorListener {
|
||||
private _errors: ParserError[] = [];
|
||||
|
||||
constructor(errors: ParserError[]) {
|
||||
super();
|
||||
this._errors = errors;
|
||||
}
|
||||
|
||||
syntaxError(
|
||||
recognizer: Recognizer, offendingSymbol: Token, line: number,
|
||||
charPositionInLine: number, msg: string, e: any,
|
||||
) {
|
||||
let endCol = charPositionInLine + 1;
|
||||
if (offendingSymbol.text !== null) {
|
||||
endCol = charPositionInLine + offendingSymbol.text.length;
|
||||
}
|
||||
this._errors.push({
|
||||
startLine: line,
|
||||
endLine: line,
|
||||
startCol: charPositionInLine,
|
||||
endCol: endCol,
|
||||
message: msg,
|
||||
});
|
||||
}
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
export * as mySQLParser from './mysql';
|
||||
export * as tSQLParser from './tsql';
|
@ -1,17 +0,0 @@
|
||||
import { InputStream, CommonTokenStream, Lexer } from 'antlr4';
|
||||
import { MySQLLexer } from '../parser/MySQLLexer';
|
||||
import { MySQLParser } from '../parser/MySQLParser';
|
||||
|
||||
import BaseParser from './common/baseParser';
|
||||
|
||||
export default class MySQL extends BaseParser {
|
||||
public createLexer(input: string): Lexer {
|
||||
const chars = new InputStream(input.toUpperCase());
|
||||
const lexer = <unknown> new MySQLLexer(chars) as Lexer;
|
||||
return lexer;
|
||||
}
|
||||
public createParserFromLexer(lexer: Lexer) {
|
||||
const tokenStream = new CommonTokenStream(lexer);
|
||||
return new MySQLParser(tokenStream);
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
import { InputStream, CommonTokenStream, Lexer } from 'antlr4';
|
||||
import { TSqlParser } from '../parser/TSqlParser';
|
||||
import { TSqlLexer } from '../parser/TSqlLexer';
|
||||
|
||||
import BaseParser from './common/baseParser';
|
||||
|
||||
export default class TSQLParser extends BaseParser {
|
||||
public createLexer(input: string): Lexer {
|
||||
const chars = new InputStream(input.toUpperCase());
|
||||
const lexer = <unknown> new TSqlLexer(chars) as Lexer;
|
||||
return lexer;
|
||||
}
|
||||
public createParserFromLexer(lexer: Lexer) {
|
||||
const tokenStream = new CommonTokenStream(lexer);
|
||||
return new TSqlParser(tokenStream);
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
lexer grammar MySQLLexer;
|
||||
lexer grammar SqlLexer;
|
||||
|
||||
channels { MYSQLCOMMENT, ERRORCHANNEL }
|
||||
|
@ -23,13 +23,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
parser grammar MySQLParser;
|
||||
parser grammar SqlParser;
|
||||
|
||||
options { tokenVocab=MySQLLexer; }
|
||||
options { tokenVocab=SqlLexer; }
|
||||
|
||||
|
||||
// Top Level Description
|
||||
|
||||
program: statement EOF;
|
||||
|
||||
statement
|
||||
: sqlStatements? MINUSMINUS? EOF
|
||||
;
|
@ -1,4 +0,0 @@
|
||||
grammar helloSQL;
|
||||
r: 'hello' ID ;
|
||||
ID: [a-z]+ ;
|
||||
WS: [ \t\r\n]+ -> skip ;
|
1540
src/grammar/hive/HiveSql.g4
Normal file
1540
src/grammar/hive/HiveSql.g4
Normal file
File diff suppressed because it is too large
Load Diff
435
src/grammar/hive/HiveSqlLexer.g4
Normal file
435
src/grammar/hive/HiveSqlLexer.g4
Normal file
@ -0,0 +1,435 @@
|
||||
lexer grammar HiveSqlLexer;
|
||||
|
||||
// Lexer rules
|
||||
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
|
||||
T_ACTIVITY_COUNT : A C T I V I T Y '_' C O U N T ;
|
||||
T_CUME_DIST : C U M E '_' D I S T ;
|
||||
T_CURRENT_DATE : C U R R E N T '_' D A T E ;
|
||||
T_CURRENT_TIMESTAMP : C U R R E N T '_' T I M E S T A M P ;
|
||||
T_CURRENT_USER : C U R R E N T '_' U S E R ;
|
||||
T_DENSE_RANK : D E N S E '_' R A N K ;
|
||||
T_FIRST_VALUE : F I R S T '_' V A L U E;
|
||||
T_LAG : L A G ;
|
||||
T_LAST_VALUE : L A S T '_' V A L U E;
|
||||
T_LEAD : L E A D ;
|
||||
T_MAX_PART_STRING : M A X '_' P A R T '_' S T R I N G ;
|
||||
T_MIN_PART_STRING : M I N '_' P A R T '_' S T R I N G ;
|
||||
T_MAX_PART_INT : M A X '_' P A R T '_' I N T ;
|
||||
T_MIN_PART_INT : M I N '_' P A R T '_' I N T ;
|
||||
T_MAX_PART_DATE : M A X '_' P A R T '_' D A T E ;
|
||||
T_MIN_PART_DATE : M I N '_' P A R T '_' D A T E ;
|
||||
T_PART_COUNT : P A R T '_' C O U N T ;
|
||||
T_PART_LOC : P A R T '_' L O C ;
|
||||
T_RANK : R A N K ;
|
||||
T_ROW_NUMBER : R O W '_' N U M B E R;
|
||||
T_STDEV : S T D E V ;
|
||||
T_SYSDATE : S Y S D A T E ;
|
||||
T_VARIANCE : V A R I A N C E ;
|
||||
T_USER : U S E R;
|
||||
|
||||
T_ADD : '+' ;
|
||||
T_COLON : ':' ;
|
||||
T_COMMA : ',' ;
|
||||
T_PIPE : '||' ;
|
||||
T_DIV : '/' ;
|
||||
T_DOT2 : '..' ;
|
||||
T_EQUAL : '=' ;
|
||||
T_EQUAL2 : '==' ;
|
||||
T_NOTEQUAL : '<>' ;
|
||||
T_NOTEQUAL2 : '!=' ;
|
||||
T_GREATER : '>' ;
|
||||
T_GREATEREQUAL : '>=' ;
|
||||
T_LESS : '<' ;
|
||||
T_LESSEQUAL : '<=' ;
|
||||
T_MUL : '*' ;
|
||||
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
|
||||
;
|
||||
L_S_STRING : '\'' (('\'' '\'') | ('\\' '\'') | ~('\''))* '\'' // Single quoted string literal
|
||||
;
|
||||
L_D_STRING : '"' (L_STR_ESC_D | .)*? '"' // Double quoted string literal
|
||||
;
|
||||
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)
|
||||
;
|
||||
|
||||
L_LABEL : ([a-zA-Z] | L_DIGIT | '_')* ':'
|
||||
;
|
||||
|
||||
fragment
|
||||
L_ID_PART :
|
||||
[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 A : ('a'|'A') ;
|
||||
fragment B : ('b'|'B') ;
|
||||
fragment C : ('c'|'C') ;
|
||||
fragment D : ('d'|'D') ;
|
||||
fragment E : ('e'|'E') ;
|
||||
fragment F : ('f'|'F') ;
|
||||
fragment G : ('g'|'G') ;
|
||||
fragment H : ('h'|'H') ;
|
||||
fragment I : ('i'|'I') ;
|
||||
fragment J : ('j'|'J') ;
|
||||
fragment K : ('k'|'K') ;
|
||||
fragment L : ('l'|'L') ;
|
||||
fragment M : ('m'|'M') ;
|
||||
fragment N : ('n'|'N') ;
|
||||
fragment O : ('o'|'O') ;
|
||||
fragment P : ('p'|'P') ;
|
||||
fragment Q : ('q'|'Q') ;
|
||||
fragment R : ('r'|'R') ;
|
||||
fragment S : ('s'|'S') ;
|
||||
fragment T : ('t'|'T') ;
|
||||
fragment U : ('u'|'U') ;
|
||||
fragment V : ('v'|'V') ;
|
||||
fragment W : ('w'|'W') ;
|
||||
fragment X : ('x'|'X') ;
|
||||
fragment Y : ('y'|'Y') ;
|
||||
fragment Z : ('z'|'Z') ;
|
2369
src/grammar/plsql/PlSqlLexer.g4
Normal file
2369
src/grammar/plsql/PlSqlLexer.g4
Normal file
File diff suppressed because it is too large
Load Diff
6763
src/grammar/plsql/PlSqlParser.g4
Normal file
6763
src/grammar/plsql/PlSqlParser.g4
Normal file
File diff suppressed because it is too large
Load Diff
3
src/grammar/spark/README.md
Normal file
3
src/grammar/spark/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Spark SQL
|
||||
|
||||
Grammar file from: <https://github.com/apache/spark/blob/master/sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,902 +0,0 @@
|
||||
/*
|
||||
T-SQL (Transact-SQL, MSSQL) grammar.
|
||||
The MIT License (MIT).
|
||||
Copyright (c) 2017, Mark Adams (madams51703@gmail.com)
|
||||
Copyright (c) 2015-2017, Ivan Kochurkin (kvanttt@gmail.com), Positive Technologies.
|
||||
Copyright (c) 2016, Scott Ure (scott@redstormsoftware.com).
|
||||
Copyright (c) 2016, Rui Zhang (ruizhang.ccs@gmail.com).
|
||||
Copyright (c) 2016, Marcus Henriksson (kuseman80@gmail.com).
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
lexer grammar TSqlLexer;
|
||||
|
||||
// Basic keywords (from https://msdn.microsoft.com/en-us/library/ms189822.aspx)
|
||||
ABSENT: 'ABSENT';
|
||||
ADD: 'ADD';
|
||||
AES: 'AES';
|
||||
ALL: 'ALL';
|
||||
ALLOW_CONNECTIONS: 'ALLOW_CONNECTIONS';
|
||||
ALLOW_MULTIPLE_EVENT_LOSS: 'ALLOW_MULTIPLE_EVENT_LOSS';
|
||||
ALLOW_SINGLE_EVENT_LOSS: 'ALLOW_SINGLE_EVENT_LOSS';
|
||||
ALTER: 'ALTER';
|
||||
AND: 'AND';
|
||||
ANONYMOUS: 'ANONYMOUS';
|
||||
ANY: 'ANY';
|
||||
APPEND: 'APPEND';
|
||||
APPLICATION: 'APPLICATION';
|
||||
AS: 'AS';
|
||||
ASC: 'ASC';
|
||||
ASYMMETRIC: 'ASYMMETRIC';
|
||||
ASYNCHRONOUS_COMMIT: 'ASYNCHRONOUS_COMMIT';
|
||||
AUTHORIZATION: 'AUTHORIZATION';
|
||||
AUTHENTICATION: 'AUTHENTICATION';
|
||||
AUTOMATED_BACKUP_PREFERENCE: 'AUTOMATED_BACKUP_PREFERENCE';
|
||||
AUTOMATIC: 'AUTOMATIC';
|
||||
AVAILABILITY_MODE: 'AVAILABILITY_MODE';
|
||||
BACKSLASH: '\\';
|
||||
BACKUP: 'BACKUP';
|
||||
BEFORE: 'BEFORE';
|
||||
BEGIN: 'BEGIN';
|
||||
BETWEEN: 'BETWEEN';
|
||||
BLOCK: 'BLOCK';
|
||||
BLOCKSIZE: 'BLOCKSIZE';
|
||||
BLOCKING_HIERARCHY: 'BLOCKING_HIERARCHY';
|
||||
BREAK: 'BREAK';
|
||||
BROWSE: 'BROWSE';
|
||||
BUFFER: 'BUFFER';
|
||||
BUFFERCOUNT: 'BUFFERCOUNT';
|
||||
BULK: 'BULK';
|
||||
BY: 'BY';
|
||||
CACHE: 'CACHE';
|
||||
CALLED: 'CALLED';
|
||||
CASCADE: 'CASCADE';
|
||||
CASE: 'CASE';
|
||||
CERTIFICATE: 'CERTIFICATE';
|
||||
CHANGETABLE: 'CHANGETABLE';
|
||||
CHANGES: 'CHANGES';
|
||||
CHECK: 'CHECK';
|
||||
CHECKPOINT: 'CHECKPOINT';
|
||||
CHECK_POLICY: 'CHECK_POLICY';
|
||||
CHECK_EXPIRATION: 'CHECK_EXPIRATION';
|
||||
CLASSIFIER_FUNCTION: 'CLASSIFIER_FUNCTION';
|
||||
CLOSE: 'CLOSE';
|
||||
CLUSTER: 'CLUSTER';
|
||||
CLUSTERED: 'CLUSTERED';
|
||||
COALESCE: 'COALESCE';
|
||||
COLLATE: 'COLLATE';
|
||||
COLUMN: 'COLUMN';
|
||||
COMPRESSION: 'COMPRESSION';
|
||||
COMMIT: 'COMMIT';
|
||||
COMPUTE: 'COMPUTE';
|
||||
CONFIGURATION: 'CONFIGURATION';
|
||||
CONSTRAINT: 'CONSTRAINT';
|
||||
CONTAINMENT: 'CONTAINMENT';
|
||||
CONTAINS: 'CONTAINS';
|
||||
CONTAINSTABLE: 'CONTAINSTABLE';
|
||||
CONTEXT: 'CONTEXT';
|
||||
CONTINUE: 'CONTINUE';
|
||||
CONTINUE_AFTER_ERROR: 'CONTINUE_AFTER_ERROR';
|
||||
CONTRACT: 'CONTRACT';
|
||||
CONTRACT_NAME: 'CONTRACT_NAME';
|
||||
CONVERSATION: 'CONVERSATION';
|
||||
CONVERT: 'TRY_'? 'CONVERT';
|
||||
COPY_ONLY: 'COPY_ONLY';
|
||||
CREATE: 'CREATE';
|
||||
CROSS: 'CROSS';
|
||||
CURRENT: 'CURRENT';
|
||||
CURRENT_DATE: 'CURRENT_DATE';
|
||||
CURRENT_TIME: 'CURRENT_TIME';
|
||||
CURRENT_TIMESTAMP: 'CURRENT_TIMESTAMP';
|
||||
CURRENT_USER: 'CURRENT_USER';
|
||||
CURSOR: 'CURSOR';
|
||||
CYCLE: 'CYCLE';
|
||||
DATA_COMPRESSION: 'DATA_COMPRESSION';
|
||||
DATA_SOURCE: 'DATA_SOURCE';
|
||||
DATABASE: 'DATABASE';
|
||||
DATABASE_MIRRORING: 'DATABASE_MIRRORING';
|
||||
DBCC: 'DBCC';
|
||||
DEALLOCATE: 'DEALLOCATE';
|
||||
DECLARE: 'DECLARE';
|
||||
DEFAULT: 'DEFAULT';
|
||||
DEFAULT_DATABASE: 'DEFAULT_DATABASE';
|
||||
DEFAULT_SCHEMA: 'DEFAULT_SCHEMA';
|
||||
DELETE: 'DELETE';
|
||||
DENY: 'DENY';
|
||||
DESC: 'DESC';
|
||||
DIAGNOSTICS: 'DIAGNOSTICS';
|
||||
DIFFERENTIAL: 'DIFFERENTIAL';
|
||||
DISK: 'DISK';
|
||||
DISTINCT: 'DISTINCT';
|
||||
DISTRIBUTED: 'DISTRIBUTED';
|
||||
DOUBLE: 'DOUBLE';
|
||||
DOUBLE_BACK_SLASH: '\\\\';
|
||||
DOUBLE_FORWARD_SLASH: '//';
|
||||
DROP: 'DROP';
|
||||
DTC_SUPPORT: 'DTC_SUPPORT';
|
||||
DUMP: 'DUMP';
|
||||
ELSE: 'ELSE';
|
||||
ENABLED: 'ENABLED';
|
||||
END: 'END';
|
||||
ENDPOINT: 'ENDPOINT';
|
||||
ERRLVL: 'ERRLVL';
|
||||
ESCAPE: 'ESCAPE';
|
||||
ERROR: 'ERROR';
|
||||
EVENT: 'EVENT';
|
||||
EVENTDATA: 'EVENTDATA' '(' ')';
|
||||
EVENT_RETENTION_MODE: 'EVENT_RETENTION_MODE';
|
||||
EXCEPT: 'EXCEPT';
|
||||
EXECUTABLE_FILE: 'EXECUTABLE_FILE';
|
||||
EXECUTE: 'EXEC' 'UTE'?;
|
||||
EXISTS: 'EXISTS';
|
||||
EXPIREDATE: 'EXPIREDATE';
|
||||
EXIT: 'EXIT';
|
||||
EXTENSION: 'EXTENSION';
|
||||
EXTERNAL: 'EXTERNAL';
|
||||
EXTERNAL_ACCESS: 'EXTERNAL_ACCESS';
|
||||
FAILOVER: 'FAILOVER';
|
||||
FAILURECONDITIONLEVEL: 'FAILURECONDITIONLEVEL';
|
||||
FAN_IN: 'FAN_IN';
|
||||
FETCH: 'FETCH';
|
||||
FILE: 'FILE';
|
||||
FILENAME: 'FILENAME';
|
||||
FILLFACTOR: 'FILLFACTOR';
|
||||
FILE_SNAPSHOT: 'FILE_SNAPSHOT';
|
||||
FOR: 'FOR';
|
||||
FORCESEEK: 'FORCESEEK';
|
||||
FORCE_SERVICE_ALLOW_DATA_LOSS: 'FORCE_SERVICE_ALLOW_DATA_LOSS';
|
||||
FOREIGN: 'FOREIGN';
|
||||
FREETEXT: 'FREETEXT';
|
||||
FREETEXTTABLE: 'FREETEXTTABLE';
|
||||
FROM: 'FROM';
|
||||
FULL: 'FULL';
|
||||
FUNCTION: 'FUNCTION';
|
||||
GET: 'GET';
|
||||
GOTO: 'GOTO';
|
||||
GOVERNOR: 'GOVERNOR';
|
||||
GRANT: 'GRANT';
|
||||
GROUP: 'GROUP';
|
||||
HAVING: 'HAVING';
|
||||
HASHED: 'HASHED';
|
||||
HEALTHCHECKTIMEOUT: 'HEALTHCHECKTIMEOUT';
|
||||
IDENTITY: 'IDENTITY';
|
||||
IDENTITYCOL: 'IDENTITYCOL';
|
||||
IDENTITY_INSERT: 'IDENTITY_INSERT';
|
||||
IF: 'IF';
|
||||
IIF: 'IIF';
|
||||
IN: 'IN';
|
||||
INCLUDE: 'INCLUDE';
|
||||
INCREMENT: 'INCREMENT';
|
||||
INDEX: 'INDEX';
|
||||
INFINITE: 'INFINITE';
|
||||
INIT: 'INIT';
|
||||
INNER: 'INNER';
|
||||
INSERT: 'INSERT';
|
||||
INSTEAD: 'INSTEAD';
|
||||
INTERSECT: 'INTERSECT';
|
||||
INTO: 'INTO';
|
||||
IPV4_ADDR: [']? IPV4_OCTECT DOT IPV4_OCTECT DOT IPV4_OCTECT DOT IPV4_OCTECT [']?;
|
||||
IPV6_ADDR: [']?[0-9A-F]?[0-9A-F]?[0-9A-F]?[0-9A-F]?[:][0-9A-F]?[0-9A-F]?[0-9A-F]?[0-9A-F]?[:][0-9A-F]?[0-9A-F]?[0-9A-F]?[0-9A-F]?[:][0-9A-F]?[0-9A-F]?[0-9A-F]?[0-9A-F]?[:][0-9A-F]?[0-9A-F]?[0-9A-F]?[0-9A-F]?[:][0-9A-F]?[0-9A-F]?[0-9A-F]?[0-9A-F]?[:][0-9A-F]?[0-9A-F]?[0-9A-F]?[0-9A-F]?[:][0-9A-F]?[0-9A-F]?[0-9A-F]?[0-9A-F]?[']?;
|
||||
IS: 'IS';
|
||||
ISNULL: 'ISNULL';
|
||||
JOIN: 'JOIN';
|
||||
KERBEROS: 'KERBEROS';
|
||||
KEY: 'KEY';
|
||||
KEY_PATH: 'KEY_PATH';
|
||||
KEY_STORE_PROVIDER_NAME: 'KEY_STORE_PROVIDER_NAME';
|
||||
KILL: 'KILL';
|
||||
LANGUAGE: 'LANGUAGE';
|
||||
LEFT: 'LEFT';
|
||||
LIBRARY: 'LIBRARY';
|
||||
LIFETIME: 'LIFETIME';
|
||||
LIKE: 'LIKE';
|
||||
LINENO: 'LINENO';
|
||||
LINUX: 'LINUX';
|
||||
LISTENER_IP: 'LISTENER_IP';
|
||||
LISTENER_PORT: 'LISTENER_PORT';
|
||||
LOAD: 'LOAD';
|
||||
LOCAL_SERVICE_NAME: 'LOCAL_SERVICE_NAME';
|
||||
LOG: 'LOG';
|
||||
MATCHED: 'MATCHED';
|
||||
MASTER: 'MASTER';
|
||||
MAX_MEMORY: 'MAX_MEMORY';
|
||||
MAXTRANSFER: 'MAXTRANSFER';
|
||||
MAXVALUE: 'MAXVALUE';
|
||||
MAX_DISPATCH_LATENCY: 'MAX_DISPATCH_LATENCY';
|
||||
MAX_EVENT_SIZE: 'MAX_EVENT_SIZE';
|
||||
MAX_SIZE: 'MAX_SIZE';
|
||||
MAX_OUTSTANDING_IO_PER_VOLUME: 'MAX_OUTSTANDING_IO_PER_VOLUME';
|
||||
MEDIADESCRIPTION: 'MEDIADESCRIPTION';
|
||||
MEDIANAME: 'MEDIANAME';
|
||||
MEMBER: 'MEMBER';
|
||||
MEMORY_PARTITION_MODE: 'MEMORY_PARTITION_MODE';
|
||||
MERGE: 'MERGE';
|
||||
MESSAGE_FORWARDING: 'MESSAGE_FORWARDING';
|
||||
MESSAGE_FORWARD_SIZE: 'MESSAGE_FORWARD_SIZE';
|
||||
MINVALUE: 'MINVALUE';
|
||||
MIRROR: 'MIRROR';
|
||||
MUST_CHANGE: 'MUST_CHANGE';
|
||||
NATIONAL: 'NATIONAL';
|
||||
NEGOTIATE: 'NEGOTIATE';
|
||||
NOCHECK: 'NOCHECK';
|
||||
NOFORMAT: 'NOFORMAT';
|
||||
NOINIT: 'NOINIT';
|
||||
NONCLUSTERED: 'NONCLUSTERED';
|
||||
NONE: 'NONE';
|
||||
NOREWIND: 'NOREWIND';
|
||||
NOSKIP: 'NOSKIP';
|
||||
NOUNLOAD: 'NOUNLOAD';
|
||||
NO_CHECKSUM: 'NO_CHECKSUM';
|
||||
NO_COMPRESSION: 'NO_COMPRESSION';
|
||||
NO_EVENT_LOSS: 'NO_EVENT_LOSS';
|
||||
NOT: 'NOT';
|
||||
NOTIFICATION: 'NOTIFICATION';
|
||||
NTLM: 'NTLM';
|
||||
NULL: 'NULL';
|
||||
NULLIF: 'NULLIF';
|
||||
OF: 'OF';
|
||||
OFF: 'OFF';
|
||||
OFFSETS: 'OFFSETS';
|
||||
OLD_PASSWORD: 'OLD_PASSWORD';
|
||||
ON: 'ON';
|
||||
ON_FAILURE: 'ON_FAILURE';
|
||||
OPEN: 'OPEN';
|
||||
OPENDATASOURCE: 'OPENDATASOURCE';
|
||||
OPENQUERY: 'OPENQUERY';
|
||||
OPENROWSET: 'OPENROWSET';
|
||||
OPENXML: 'OPENXML';
|
||||
OPTION: 'OPTION';
|
||||
OR: 'OR';
|
||||
ORDER: 'ORDER';
|
||||
OUTER: 'OUTER';
|
||||
OVER: 'OVER';
|
||||
PAGE: 'PAGE';
|
||||
PARAM_NODE: 'PARAM_NODE';
|
||||
PARTIAL: 'PARTIAL';
|
||||
PASSWORD: 'PASSWORD';
|
||||
PERCENT: 'PERCENT';
|
||||
PERMISSION_SET: 'PERMISSION_SET';
|
||||
PER_CPU: 'PER_CPU';
|
||||
PER_DB: 'PER_DB';
|
||||
PER_NODE: 'PER_NODE';
|
||||
PIVOT: 'PIVOT';
|
||||
PLAN: 'PLAN';
|
||||
PLATFORM: 'PLATFORM';
|
||||
POLICY: 'POLICY';
|
||||
PRECISION: 'PRECISION';
|
||||
PREDICATE: 'PREDICATE';
|
||||
PRIMARY: 'PRIMARY';
|
||||
PRINT: 'PRINT';
|
||||
PROC: 'PROC';
|
||||
PROCEDURE: 'PROCEDURE';
|
||||
PROCESS: 'PROCESS';
|
||||
PUBLIC: 'PUBLIC';
|
||||
PYTHON: 'PYTHON';
|
||||
R: 'R';
|
||||
RAISERROR: 'RAISERROR';
|
||||
RAW: 'RAW';
|
||||
READ: 'READ';
|
||||
READTEXT: 'READTEXT';
|
||||
READ_WRITE_FILEGROUPS: 'READ_WRITE_FILEGROUPS';
|
||||
RECONFIGURE: 'RECONFIGURE';
|
||||
REFERENCES: 'REFERENCES';
|
||||
REGENERATE: 'REGENERATE';
|
||||
RELATED_CONVERSATION: 'RELATED_CONVERSATION';
|
||||
RELATED_CONVERSATION_GROUP: 'RELATED_CONVERSATION_GROUP';
|
||||
REPLICATION: 'REPLICATION';
|
||||
REQUIRED: 'REQUIRED';
|
||||
RESET: 'RESET';
|
||||
RESTART: 'RESTART';
|
||||
RESTORE: 'RESTORE';
|
||||
RESTRICT: 'RESTRICT';
|
||||
RESUME: 'RESUME';
|
||||
RETAINDAYS: 'RETAINDAYS';
|
||||
RETURN: 'RETURN';
|
||||
RETURNS: 'RETURNS';
|
||||
REVERT: 'REVERT';
|
||||
REVOKE: 'REVOKE';
|
||||
REWIND: 'REWIND';
|
||||
RIGHT: 'RIGHT';
|
||||
ROLLBACK: 'ROLLBACK';
|
||||
ROLE: 'ROLE';
|
||||
ROWCOUNT: 'ROWCOUNT';
|
||||
ROWGUIDCOL: 'ROWGUIDCOL';
|
||||
RSA_512: 'RSA_512';
|
||||
RSA_1024: 'RSA_1024';
|
||||
RSA_2048: 'RSA_2048';
|
||||
RSA_3072: 'RSA_3072';
|
||||
RSA_4096: 'RSA_4096';
|
||||
SAFETY: 'SAFETY';
|
||||
RULE: 'RULE';
|
||||
SAFE: 'SAFE';
|
||||
SAVE: 'SAVE';
|
||||
SCHEDULER: 'SCHEDULER';
|
||||
SCHEMA: 'SCHEMA';
|
||||
SCHEME: 'SCHEME';
|
||||
SECURITYAUDIT: 'SECURITYAUDIT';
|
||||
SELECT: 'SELECT';
|
||||
SEMANTICKEYPHRASETABLE: 'SEMANTICKEYPHRASETABLE';
|
||||
SEMANTICSIMILARITYDETAILSTABLE: 'SEMANTICSIMILARITYDETAILSTABLE';
|
||||
SEMANTICSIMILARITYTABLE: 'SEMANTICSIMILARITYTABLE';
|
||||
SERVER: 'SERVER';
|
||||
SERVICE: 'SERVICE';
|
||||
SERVICE_BROKER: 'SERVICE_BROKER';
|
||||
SERVICE_NAME: 'SERVICE_NAME';
|
||||
SESSION: 'SESSION';
|
||||
SESSION_USER: 'SESSION_USER';
|
||||
SET: 'SET';
|
||||
SETUSER: 'SETUSER';
|
||||
SHUTDOWN: 'SHUTDOWN';
|
||||
SID: 'SID';
|
||||
SKIP_KEYWORD: 'SKIP';
|
||||
SOFTNUMA: 'SOFTNUMA';
|
||||
SOME: 'SOME';
|
||||
SOURCE: 'SOURCE';
|
||||
SPECIFICATION: 'SPECIFICATION';
|
||||
SPLIT: 'SPLIT';
|
||||
SQLDUMPERFLAGS: 'SQLDUMPERFLAGS';
|
||||
SQLDUMPERPATH: 'SQLDUMPERPATH';
|
||||
SQLDUMPERTIMEOUT: 'SQLDUMPERTIMEOUTS';
|
||||
STATISTICS: 'STATISTICS';
|
||||
STATE: 'STATE';
|
||||
STATS: 'STATS';
|
||||
START: 'START';
|
||||
STARTED: 'STARTED';
|
||||
STARTUP_STATE: 'STARTUP_STATE';
|
||||
STOP: 'STOP';
|
||||
STOPPED: 'STOPPED';
|
||||
STOP_ON_ERROR: 'STOP_ON_ERROR';
|
||||
SUPPORTED: 'SUPPORTED';
|
||||
SYSTEM_USER: 'SYSTEM_USER';
|
||||
TABLE: 'TABLE';
|
||||
TABLESAMPLE: 'TABLESAMPLE';
|
||||
TAPE: 'TAPE';
|
||||
TARGET: 'TARGET';
|
||||
TCP: 'TCP';
|
||||
TEXTSIZE: 'TEXTSIZE';
|
||||
THEN: 'THEN';
|
||||
TO: 'TO';
|
||||
TOP: 'TOP';
|
||||
TRACK_CAUSALITY: 'TRACK_CAUSALITY';
|
||||
TRAN: 'TRAN';
|
||||
TRANSACTION: 'TRANSACTION';
|
||||
TRANSFER: 'TRANSFER';
|
||||
TRIGGER: 'TRIGGER';
|
||||
TRUNCATE: 'TRUNCATE';
|
||||
TSEQUAL: 'TSEQUAL';
|
||||
UNCHECKED: 'UNCHECKED';
|
||||
UNION: 'UNION';
|
||||
UNIQUE: 'UNIQUE';
|
||||
UNLOCK: 'UNLOCK';
|
||||
UNPIVOT: 'UNPIVOT';
|
||||
UNSAFE: 'UNSAFE';
|
||||
UPDATE: 'UPDATE';
|
||||
UPDATETEXT: 'UPDATETEXT';
|
||||
URL: 'URL';
|
||||
USE: 'USE';
|
||||
USED: 'USED';
|
||||
USER: 'USER';
|
||||
VALUES: 'VALUES';
|
||||
VARYING: 'VARYING';
|
||||
VERBOSELOGGING: 'VERBOSELOGGING';
|
||||
VIEW: 'VIEW';
|
||||
VISIBILITY: 'VISIBILITY';
|
||||
WAITFOR: 'WAITFOR';
|
||||
WHEN: 'WHEN';
|
||||
WHERE: 'WHERE';
|
||||
WHILE: 'WHILE';
|
||||
WINDOWS: 'WINDOWS';
|
||||
WITH: 'WITH';
|
||||
WITHIN: 'WITHIN';
|
||||
WITHOUT: 'WITHOUT';
|
||||
WITNESS: 'WITNESS';
|
||||
WRITETEXT: 'WRITETEXT';
|
||||
|
||||
// Additional keywords. They can be id, please keep them in sync with the parser.
|
||||
ABSOLUTE: 'ABSOLUTE';
|
||||
ACCENT_SENSITIVITY: 'ACCENT_SENSITIVITY';
|
||||
ACTION: 'ACTION';
|
||||
ACTIVATION: 'ACTIVATION';
|
||||
ACTIVE: 'ACTIVE';
|
||||
ADDRESS: 'ADDRESS';
|
||||
AES_128: 'AES_128';
|
||||
AES_192: 'AES_192';
|
||||
AES_256: 'AES_256';
|
||||
AFFINITY: 'AFFINITY';
|
||||
AFTER: 'AFTER';
|
||||
AGGREGATE: 'AGGREGATE';
|
||||
ALGORITHM: 'ALGORITHM';
|
||||
ALLOW_ENCRYPTED_VALUE_MODIFICATIONS: 'ALLOW_ENCRYPTED_VALUE_MODIFICATIONS';
|
||||
ALLOW_SNAPSHOT_ISOLATION: 'ALLOW_SNAPSHOT_ISOLATION';
|
||||
ALLOWED: 'ALLOWED';
|
||||
ANSI_NULL_DEFAULT: 'ANSI_NULL_DEFAULT';
|
||||
ANSI_NULLS: 'ANSI_NULLS';
|
||||
ANSI_PADDING: 'ANSI_PADDING';
|
||||
ANSI_WARNINGS: 'ANSI_WARNINGS';
|
||||
APPLICATION_LOG: 'APPLICATION_LOG';
|
||||
APPLY: 'APPLY';
|
||||
ARITHABORT: 'ARITHABORT';
|
||||
ASSEMBLY: 'ASSEMBLY';
|
||||
AUDIT: 'AUDIT';
|
||||
AUDIT_GUID: 'AUDIT_GUID';
|
||||
AUTO: 'AUTO';
|
||||
AUTO_CLEANUP: 'AUTO_CLEANUP';
|
||||
AUTO_CLOSE: 'AUTO_CLOSE';
|
||||
AUTO_CREATE_STATISTICS: 'AUTO_CREATE_STATISTICS';
|
||||
AUTO_SHRINK: 'AUTO_SHRINK';
|
||||
AUTO_UPDATE_STATISTICS: 'AUTO_UPDATE_STATISTICS';
|
||||
AUTO_UPDATE_STATISTICS_ASYNC: 'AUTO_UPDATE_STATISTICS_ASYNC';
|
||||
AVAILABILITY: 'AVAILABILITY';
|
||||
AVG: 'AVG';
|
||||
BACKUP_PRIORITY: 'BACKUP_PRIORITY';
|
||||
BEGIN_DIALOG: 'BEGIN_DIALOG';
|
||||
BIGINT: 'BIGINT';
|
||||
BINARY_BASE64: 'BINARY BASE64';
|
||||
BINARY_CHECKSUM: 'BINARY_CHECKSUM';
|
||||
BINDING: 'BINDING';
|
||||
BLOB_STORAGE: 'BLOB_STORAGE';
|
||||
BROKER: 'BROKER';
|
||||
BROKER_INSTANCE: 'BROKER_INSTANCE';
|
||||
BULK_LOGGED: 'BULK_LOGGED';
|
||||
CALLER: 'CALLER';
|
||||
CAP_CPU_PERCENT: 'CAP_CPU_PERCENT';
|
||||
CAST: 'TRY_'? 'CAST';
|
||||
CATALOG: 'CATALOG';
|
||||
CATCH: 'CATCH';
|
||||
CHANGE_RETENTION: 'CHANGE_RETENTION';
|
||||
CHANGE_TRACKING: 'CHANGE_TRACKING';
|
||||
CHECKSUM: 'CHECKSUM';
|
||||
CHECKSUM_AGG: 'CHECKSUM_AGG';
|
||||
CLEANUP: 'CLEANUP';
|
||||
COLLECTION: 'COLLECTION';
|
||||
COLUMN_MASTER_KEY: 'COLUMN_MASTER_KEY';
|
||||
COMMITTED: 'COMMITTED';
|
||||
COMPATIBILITY_LEVEL: 'COMPATIBILITY_LEVEL';
|
||||
CONCAT: 'CONCAT';
|
||||
CONCAT_NULL_YIELDS_NULL: 'CONCAT_NULL_YIELDS_NULL';
|
||||
CONTENT: 'CONTENT';
|
||||
CONTROL: 'CONTROL';
|
||||
COOKIE: 'COOKIE';
|
||||
COUNT: 'COUNT';
|
||||
COUNT_BIG: 'COUNT_BIG';
|
||||
COUNTER: 'COUNTER';
|
||||
CPU: 'CPU';
|
||||
CREATE_NEW: 'CREATE_NEW';
|
||||
CREATION_DISPOSITION: 'CREATION_DISPOSITION';
|
||||
CREDENTIAL: 'CREDENTIAL';
|
||||
CRYPTOGRAPHIC: 'CRYPTOGRAPHIC';
|
||||
CURSOR_CLOSE_ON_COMMIT: 'CURSOR_CLOSE_ON_COMMIT';
|
||||
CURSOR_DEFAULT: 'CURSOR_DEFAULT';
|
||||
DATA: 'DATA';
|
||||
DATE_CORRELATION_OPTIMIZATION: 'DATE_CORRELATION_OPTIMIZATION';
|
||||
DATEADD: 'DATEADD';
|
||||
DATEDIFF: 'DATEDIFF';
|
||||
DATENAME: 'DATENAME';
|
||||
DATEPART: 'DATEPART';
|
||||
DAYS: 'DAYS';
|
||||
DB_CHAINING: 'DB_CHAINING';
|
||||
DB_FAILOVER: 'DB_FAILOVER';
|
||||
DECRYPTION: 'DECRYPTION';
|
||||
DEFAULT_DOUBLE_QUOTE: ["]'DEFAULT'["];
|
||||
DEFAULT_FULLTEXT_LANGUAGE: 'DEFAULT_FULLTEXT_LANGUAGE';
|
||||
DEFAULT_LANGUAGE: 'DEFAULT_LANGUAGE';
|
||||
DELAY: 'DELAY';
|
||||
DELAYED_DURABILITY: 'DELAYED_DURABILITY';
|
||||
DELETED: 'DELETED';
|
||||
DENSE_RANK: 'DENSE_RANK';
|
||||
DEPENDENTS: 'DEPENDENTS';
|
||||
DES: 'DES';
|
||||
DESCRIPTION: 'DESCRIPTION';
|
||||
DESX: 'DESX';
|
||||
DHCP: 'DHCP';
|
||||
DIALOG: 'DIALOG';
|
||||
DIRECTORY_NAME: 'DIRECTORY_NAME';
|
||||
DISABLE: 'DISABLE';
|
||||
DISABLE_BROKER: 'DISABLE_BROKER';
|
||||
DISABLED: 'DISABLED';
|
||||
DISK_DRIVE: [A-Z][:];
|
||||
DOCUMENT: 'DOCUMENT';
|
||||
DYNAMIC: 'DYNAMIC';
|
||||
ELEMENTS: 'ELEMENTS';
|
||||
EMERGENCY: 'EMERGENCY';
|
||||
EMPTY: 'EMPTY';
|
||||
ENABLE: 'ENABLE';
|
||||
ENABLE_BROKER: 'ENABLE_BROKER';
|
||||
ENCRYPTED_VALUE: 'ENCRYPTED_VALUE';
|
||||
ENCRYPTION: 'ENCRYPTION';
|
||||
ENDPOINT_URL: 'ENDPOINT_URL';
|
||||
ERROR_BROKER_CONVERSATIONS: 'ERROR_BROKER_CONVERSATIONS';
|
||||
EXCLUSIVE: 'EXCLUSIVE';
|
||||
EXECUTABLE: 'EXECUTABLE';
|
||||
EXIST: 'EXIST';
|
||||
EXPAND: 'EXPAND';
|
||||
EXPIRY_DATE: 'EXPIRY_DATE';
|
||||
EXPLICIT: 'EXPLICIT';
|
||||
FAIL_OPERATION: 'FAIL_OPERATION';
|
||||
FAILOVER_MODE: 'FAILOVER_MODE';
|
||||
FAILURE: 'FAILURE';
|
||||
FAILURE_CONDITION_LEVEL: 'FAILURE_CONDITION_LEVEL';
|
||||
FAST: 'FAST';
|
||||
FAST_FORWARD: 'FAST_FORWARD';
|
||||
FILEGROUP: 'FILEGROUP';
|
||||
FILEGROWTH: 'FILEGROWTH';
|
||||
FILEPATH: 'FILEPATH';
|
||||
FILESTREAM: 'FILESTREAM';
|
||||
FILTER: 'FILTER';
|
||||
FIRST: 'FIRST';
|
||||
FIRST_VALUE: 'FIRST_VALUE';
|
||||
FOLLOWING: 'FOLLOWING';
|
||||
FORCE: 'FORCE';
|
||||
FORCE_FAILOVER_ALLOW_DATA_LOSS: 'FORCE_FAILOVER_ALLOW_DATA_LOSS';
|
||||
FORCED: 'FORCED';
|
||||
FORMAT: 'FORMAT';
|
||||
FORWARD_ONLY: 'FORWARD_ONLY';
|
||||
FULLSCAN: 'FULLSCAN';
|
||||
FULLTEXT: 'FULLTEXT';
|
||||
GB: 'GB';
|
||||
GETDATE: 'GETDATE';
|
||||
GETUTCDATE: 'GETUTCDATE';
|
||||
GLOBAL: 'GLOBAL';
|
||||
GO: 'GO';
|
||||
GROUP_MAX_REQUESTS: 'GROUP_MAX_REQUESTS';
|
||||
GROUPING: 'GROUPING';
|
||||
GROUPING_ID: 'GROUPING_ID';
|
||||
HADR: 'HADR';
|
||||
HASH: 'HASH';
|
||||
HEALTH_CHECK_TIMEOUT: 'HEALTH_CHECK_TIMEOUT';
|
||||
HIGH: 'HIGH';
|
||||
HONOR_BROKER_PRIORITY: 'HONOR_BROKER_PRIORITY';
|
||||
HOURS: 'HOURS';
|
||||
IDENTITY_VALUE: 'IDENTITY_VALUE';
|
||||
IGNORE_NONCLUSTERED_COLUMNSTORE_INDEX: 'IGNORE_NONCLUSTERED_COLUMNSTORE_INDEX';
|
||||
IMMEDIATE: 'IMMEDIATE';
|
||||
IMPERSONATE: 'IMPERSONATE';
|
||||
IMPORTANCE: 'IMPORTANCE';
|
||||
INCLUDE_NULL_VALUES: 'INCLUDE_NULL_VALUES';
|
||||
INCREMENTAL: 'INCREMENTAL';
|
||||
INITIATOR: 'INITIATOR';
|
||||
INPUT: 'INPUT';
|
||||
INSENSITIVE: 'INSENSITIVE';
|
||||
INSERTED: 'INSERTED';
|
||||
INT: 'INT';
|
||||
IP: 'IP';
|
||||
ISOLATION: 'ISOLATION';
|
||||
JOB: 'JOB';
|
||||
JSON: 'JSON';
|
||||
KB: 'KB';
|
||||
KEEP: 'KEEP';
|
||||
KEEPFIXED: 'KEEPFIXED';
|
||||
KEY_SOURCE: 'KEY_SOURCE';
|
||||
KEYS: 'KEYS';
|
||||
KEYSET: 'KEYSET';
|
||||
LAG: 'LAG';
|
||||
LAST: 'LAST';
|
||||
LAST_VALUE: 'LAST_VALUE';
|
||||
LEAD: 'LEAD';
|
||||
LEVEL: 'LEVEL';
|
||||
LIST: 'LIST';
|
||||
LISTENER: 'LISTENER';
|
||||
LISTENER_URL: 'LISTENER_URL';
|
||||
LOB_COMPACTION: 'LOB_COMPACTION';
|
||||
LOCAL: 'LOCAL';
|
||||
LOCATION: 'LOCATION';
|
||||
LOCK: 'LOCK';
|
||||
LOCK_ESCALATION: 'LOCK_ESCALATION';
|
||||
LOGIN: 'LOGIN';
|
||||
LOOP: 'LOOP';
|
||||
LOW: 'LOW';
|
||||
MANUAL: 'MANUAL';
|
||||
MARK: 'MARK';
|
||||
MATERIALIZED: 'MATERIALIZED';
|
||||
MAX: 'MAX';
|
||||
MAX_CPU_PERCENT: 'MAX_CPU_PERCENT';
|
||||
MAX_DOP: 'MAX_DOP';
|
||||
MAX_FILES: 'MAX_FILES';
|
||||
MAX_IOPS_PER_VOLUME: 'MAX_IOPS_PER_VOLUME';
|
||||
MAX_MEMORY_PERCENT: 'MAX_MEMORY_PERCENT';
|
||||
MAX_PROCESSES: 'MAX_PROCESSES';
|
||||
MAX_QUEUE_READERS: 'MAX_QUEUE_READERS';
|
||||
MAX_ROLLOVER_FILES: 'MAX_ROLLOVER_FILES';
|
||||
MAXDOP: 'MAXDOP';
|
||||
MAXRECURSION: 'MAXRECURSION';
|
||||
MAXSIZE: 'MAXSIZE';
|
||||
MB: 'MB';
|
||||
MEDIUM: 'MEDIUM';
|
||||
MEMORY_OPTIMIZED_DATA: 'MEMORY_OPTIMIZED_DATA';
|
||||
MESSAGE: 'MESSAGE';
|
||||
MIN: 'MIN';
|
||||
MIN_ACTIVE_ROWVERSION: 'MIN_ACTIVE_ROWVERSION';
|
||||
MIN_CPU_PERCENT: 'MIN_CPU_PERCENT';
|
||||
MIN_IOPS_PER_VOLUME: 'MIN_IOPS_PER_VOLUME';
|
||||
MIN_MEMORY_PERCENT: 'MIN_MEMORY_PERCENT';
|
||||
MINUTES: 'MINUTES';
|
||||
MIRROR_ADDRESS: 'MIRROR_ADDRESS';
|
||||
MIXED_PAGE_ALLOCATION: 'MIXED_PAGE_ALLOCATION';
|
||||
MODE: 'MODE';
|
||||
MODIFY: 'MODIFY';
|
||||
MOVE: 'MOVE';
|
||||
MULTI_USER: 'MULTI_USER';
|
||||
NAME: 'NAME';
|
||||
NESTED_TRIGGERS: 'NESTED_TRIGGERS';
|
||||
NEW_ACCOUNT: 'NEW_ACCOUNT';
|
||||
NEW_BROKER: 'NEW_BROKER';
|
||||
NEW_PASSWORD: 'NEW_PASSWORD';
|
||||
NEXT: 'NEXT';
|
||||
NO: 'NO';
|
||||
NO_TRUNCATE: 'NO_TRUNCATE';
|
||||
NO_WAIT: 'NO_WAIT';
|
||||
NOCOUNT: 'NOCOUNT';
|
||||
NODES: 'NODES';
|
||||
NOEXPAND: 'NOEXPAND';
|
||||
NON_TRANSACTED_ACCESS: 'NON_TRANSACTED_ACCESS';
|
||||
NORECOMPUTE: 'NORECOMPUTE';
|
||||
NORECOVERY: 'NORECOVERY';
|
||||
NOWAIT: 'NOWAIT';
|
||||
NTILE: 'NTILE';
|
||||
NUMANODE: 'NUMANODE';
|
||||
NUMBER: 'NUMBER';
|
||||
NUMERIC_ROUNDABORT: 'NUMERIC_ROUNDABORT';
|
||||
OBJECT: 'OBJECT';
|
||||
OFFLINE: 'OFFLINE';
|
||||
OFFSET: 'OFFSET';
|
||||
OLD_ACCOUNT: 'OLD_ACCOUNT';
|
||||
ONLINE: 'ONLINE';
|
||||
ONLY: 'ONLY';
|
||||
OPEN_EXISTING: 'OPEN_EXISTING';
|
||||
OPTIMISTIC: 'OPTIMISTIC';
|
||||
OPTIMIZE: 'OPTIMIZE';
|
||||
OUT: 'OUT';
|
||||
OUTPUT: 'OUTPUT';
|
||||
OVERRIDE: 'OVERRIDE';
|
||||
OWNER: 'OWNER';
|
||||
PAGE_VERIFY: 'PAGE_VERIFY';
|
||||
PARAMETERIZATION: 'PARAMETERIZATION';
|
||||
PARTITION: 'PARTITION';
|
||||
PARTITIONS: 'PARTITIONS';
|
||||
PARTNER: 'PARTNER';
|
||||
PATH: 'PATH';
|
||||
POISON_MESSAGE_HANDLING: 'POISON_MESSAGE_HANDLING';
|
||||
POOL: 'POOL';
|
||||
PORT: 'PORT';
|
||||
PRECEDING: 'PRECEDING';
|
||||
PRIMARY_ROLE: 'PRIMARY_ROLE';
|
||||
PRIOR: 'PRIOR';
|
||||
PRIORITY: 'PRIORITY';
|
||||
PRIORITY_LEVEL: 'PRIORITY_LEVEL';
|
||||
PRIVATE: 'PRIVATE';
|
||||
PRIVATE_KEY: 'PRIVATE_KEY';
|
||||
PRIVILEGES: 'PRIVILEGES';
|
||||
PROCEDURE_NAME: 'PROCEDURE_NAME';
|
||||
PROPERTY: 'PROPERTY';
|
||||
PROVIDER: 'PROVIDER';
|
||||
PROVIDER_KEY_NAME: 'PROVIDER_KEY_NAME';
|
||||
QUERY: 'QUERY';
|
||||
QUEUE: 'QUEUE';
|
||||
QUEUE_DELAY: 'QUEUE_DELAY';
|
||||
QUOTED_IDENTIFIER: 'QUOTED_IDENTIFIER';
|
||||
RANGE: 'RANGE';
|
||||
RANK: 'RANK';
|
||||
RC2: 'RC2';
|
||||
RC4: 'RC4';
|
||||
RC4_128: 'RC4_128';
|
||||
READ_COMMITTED_SNAPSHOT: 'READ_COMMITTED_SNAPSHOT';
|
||||
READ_ONLY: 'READ_ONLY';
|
||||
READ_ONLY_ROUTING_LIST: 'READ_ONLY_ROUTING_LIST';
|
||||
READ_WRITE: 'READ_WRITE';
|
||||
READONLY: 'READONLY';
|
||||
REBUILD: 'REBUILD';
|
||||
RECEIVE: 'RECEIVE';
|
||||
RECOMPILE: 'RECOMPILE';
|
||||
RECOVERY: 'RECOVERY';
|
||||
RECURSIVE_TRIGGERS: 'RECURSIVE_TRIGGERS';
|
||||
RELATIVE: 'RELATIVE';
|
||||
REMOTE: 'REMOTE';
|
||||
REMOTE_SERVICE_NAME: 'REMOTE_SERVICE_NAME';
|
||||
REMOVE: 'REMOVE';
|
||||
REORGANIZE: 'REORGANIZE';
|
||||
REPEATABLE: 'REPEATABLE';
|
||||
REPLICA: 'REPLICA';
|
||||
REQUEST_MAX_CPU_TIME_SEC: 'REQUEST_MAX_CPU_TIME_SEC';
|
||||
REQUEST_MAX_MEMORY_GRANT_PERCENT: 'REQUEST_MAX_MEMORY_GRANT_PERCENT';
|
||||
REQUEST_MEMORY_GRANT_TIMEOUT_SEC: 'REQUEST_MEMORY_GRANT_TIMEOUT_SEC';
|
||||
REQUIRED_SYNCHRONIZED_SECONDARIES_TO_COMMIT: 'REQUIRED_SYNCHRONIZED_SECONDARIES_TO_COMMIT';
|
||||
RESERVE_DISK_SPACE: 'RESERVE_DISK_SPACE';
|
||||
RESOURCE: 'RESOURCE';
|
||||
RESOURCE_MANAGER_LOCATION: 'RESOURCE_MANAGER_LOCATION';
|
||||
RESTRICTED_USER: 'RESTRICTED_USER';
|
||||
RETENTION: 'RETENTION';
|
||||
ROBUST: 'ROBUST';
|
||||
ROOT: 'ROOT';
|
||||
ROUTE: 'ROUTE';
|
||||
ROW: 'ROW';
|
||||
ROW_NUMBER: 'ROW_NUMBER';
|
||||
ROWGUID: 'ROWGUID';
|
||||
ROWS: 'ROWS';
|
||||
SAMPLE: 'SAMPLE';
|
||||
SCHEMABINDING: 'SCHEMABINDING';
|
||||
SCOPED: 'SCOPED';
|
||||
SCROLL: 'SCROLL';
|
||||
SCROLL_LOCKS: 'SCROLL_LOCKS';
|
||||
SEARCH: 'SEARCH';
|
||||
SECONDARY: 'SECONDARY';
|
||||
SECONDARY_ONLY: 'SECONDARY_ONLY';
|
||||
SECONDARY_ROLE: 'SECONDARY_ROLE';
|
||||
SECONDS: 'SECONDS';
|
||||
SECRET: 'SECRET';
|
||||
SECURITY: 'SECURITY';
|
||||
SECURITY_LOG: 'SECURITY_LOG';
|
||||
SEEDING_MODE: 'SEEDING_MODE';
|
||||
SELF: 'SELF';
|
||||
SEMI_SENSITIVE: 'SEMI_SENSITIVE';
|
||||
SEND: 'SEND';
|
||||
SENT: 'SENT';
|
||||
SEQUENCE: 'SEQUENCE';
|
||||
SERIALIZABLE: 'SERIALIZABLE';
|
||||
SESSION_TIMEOUT: 'SESSION_TIMEOUT';
|
||||
SETERROR: 'SETERROR';
|
||||
SHARE: 'SHARE';
|
||||
SHOWPLAN: 'SHOWPLAN';
|
||||
SIGNATURE: 'SIGNATURE';
|
||||
SIMPLE: 'SIMPLE';
|
||||
SINGLE_USER: 'SINGLE_USER';
|
||||
SIZE: 'SIZE';
|
||||
SMALLINT: 'SMALLINT';
|
||||
SNAPSHOT: 'SNAPSHOT';
|
||||
SPATIAL_WINDOW_MAX_CELLS: 'SPATIAL_WINDOW_MAX_CELLS';
|
||||
STANDBY: 'STANDBY';
|
||||
START_DATE: 'START_DATE';
|
||||
STATIC: 'STATIC';
|
||||
STATS_STREAM: 'STATS_STREAM';
|
||||
STATUS: 'STATUS';
|
||||
STATUSONLY: 'STATUSONLY';
|
||||
STDEV: 'STDEV';
|
||||
STDEVP: 'STDEVP';
|
||||
STOPLIST: 'STOPLIST';
|
||||
STRING_AGG: 'STRING_AGG';
|
||||
STUFF: 'STUFF';
|
||||
SUBJECT: 'SUBJECT';
|
||||
SUBSCRIPTION: 'SUBSCRIPTION';
|
||||
SUM: 'SUM';
|
||||
SUSPEND: 'SUSPEND';
|
||||
SYMMETRIC: 'SYMMETRIC';
|
||||
SYNCHRONOUS_COMMIT: 'SYNCHRONOUS_COMMIT';
|
||||
SYNONYM: 'SYNONYM';
|
||||
SYSTEM: 'SYSTEM';
|
||||
TAKE: 'TAKE';
|
||||
TARGET_RECOVERY_TIME: 'TARGET_RECOVERY_TIME';
|
||||
TB: 'TB';
|
||||
TEXTIMAGE_ON: 'TEXTIMAGE_ON';
|
||||
THROW: 'THROW';
|
||||
TIES: 'TIES';
|
||||
TIME: 'TIME';
|
||||
TIMEOUT: 'TIMEOUT';
|
||||
TIMER: 'TIMER';
|
||||
TINYINT: 'TINYINT';
|
||||
TORN_PAGE_DETECTION: 'TORN_PAGE_DETECTION';
|
||||
TRANSFORM_NOISE_WORDS: 'TRANSFORM_NOISE_WORDS';
|
||||
TRIPLE_DES: 'TRIPLE_DES';
|
||||
TRIPLE_DES_3KEY: 'TRIPLE_DES_3KEY';
|
||||
TRUSTWORTHY: 'TRUSTWORTHY';
|
||||
TRY: 'TRY';
|
||||
TSQL: 'TSQL';
|
||||
TWO_DIGIT_YEAR_CUTOFF: 'TWO_DIGIT_YEAR_CUTOFF';
|
||||
TYPE: 'TYPE';
|
||||
TYPE_WARNING: 'TYPE_WARNING';
|
||||
UNBOUNDED: 'UNBOUNDED';
|
||||
UNCOMMITTED: 'UNCOMMITTED';
|
||||
UNKNOWN: 'UNKNOWN';
|
||||
UNLIMITED: 'UNLIMITED';
|
||||
UOW: 'UOW';
|
||||
USING: 'USING';
|
||||
VALID_XML: 'VALID_XML';
|
||||
VALIDATION: 'VALIDATION';
|
||||
VALUE: 'VALUE';
|
||||
VAR: 'VAR';
|
||||
VARP: 'VARP';
|
||||
VIEW_METADATA: 'VIEW_METADATA';
|
||||
VIEWS: 'VIEWS';
|
||||
WAIT: 'WAIT';
|
||||
WELL_FORMED_XML: 'WELL_FORMED_XML';
|
||||
WITHOUT_ARRAY_WRAPPER: 'WITHOUT_ARRAY_WRAPPER';
|
||||
WORK: 'WORK';
|
||||
WORKLOAD: 'WORKLOAD';
|
||||
XML: 'XML';
|
||||
XMLDATA: 'XMLDATA';
|
||||
XMLNAMESPACES: 'XMLNAMESPACES';
|
||||
XMLSCHEMA: 'XMLSCHEMA';
|
||||
XSINIL: 'XSINIL';
|
||||
|
||||
DOLLAR_ACTION: '$ACTION';
|
||||
|
||||
SPACE: [ \t\r\n]+ -> skip;
|
||||
// https://docs.microsoft.com/en-us/sql/t-sql/language-elements/slash-star-comment-transact-sql
|
||||
COMMENT: '/*' (COMMENT | .)*? '*/' -> channel(HIDDEN);
|
||||
LINE_COMMENT: '--' ~[\r\n]* -> channel(HIDDEN);
|
||||
|
||||
// TODO: ID can be not only Latin.
|
||||
DOUBLE_QUOTE_ID: '"' ~'"'+ '"';
|
||||
SINGLE_QUOTE: '\'';
|
||||
SQUARE_BRACKET_ID: '[' ~']'+ ']';
|
||||
LOCAL_ID: '@' ([A-Z_$@#0-9] | FullWidthLetter)+;
|
||||
DECIMAL: DEC_DIGIT+;
|
||||
ID: ( [A-Z_#] | FullWidthLetter) ( [A-Z_#$@0-9] | FullWidthLetter )*;
|
||||
QUOTED_URL: '\''([A-Z][A-Z]+[:]) '//'(([A-Z]+[.]|[A-Z]+)|IPV4_ADDR) [:] DECIMAL '\'';
|
||||
QUOTED_HOST_AND_PORT:'\''(([A-Z]+[.]|[A-Z]+)|IPV4_ADDR) ([:] DECIMAL) '\'';
|
||||
STRING: 'N'? '\'' (~'\'' | '\'\'')* '\'';
|
||||
BINARY: '0' 'X' HEX_DIGIT*;
|
||||
FLOAT: DEC_DOT_DEC;
|
||||
REAL: (DECIMAL | DEC_DOT_DEC) ('E' [+-]? DEC_DIGIT+);
|
||||
|
||||
EQUAL: '=';
|
||||
|
||||
GREATER: '>';
|
||||
LESS: '<';
|
||||
EXCLAMATION: '!';
|
||||
|
||||
PLUS_ASSIGN: '+=';
|
||||
MINUS_ASSIGN: '-=';
|
||||
MULT_ASSIGN: '*=';
|
||||
DIV_ASSIGN: '/=';
|
||||
MOD_ASSIGN: '%=';
|
||||
AND_ASSIGN: '&=';
|
||||
XOR_ASSIGN: '^=';
|
||||
OR_ASSIGN: '|=';
|
||||
|
||||
DOUBLE_BAR: '||';
|
||||
DOT: '.';
|
||||
UNDERLINE: '_';
|
||||
AT: '@';
|
||||
SHARP: '#';
|
||||
DOLLAR: '$';
|
||||
LR_BRACKET: '(';
|
||||
RR_BRACKET: ')';
|
||||
COMMA: ',';
|
||||
SEMI: ';';
|
||||
COLON: ':';
|
||||
STAR: '*';
|
||||
DIVIDE: '/';
|
||||
MODULE: '%';
|
||||
PLUS: '+';
|
||||
MINUS: '-';
|
||||
BIT_NOT: '~';
|
||||
BIT_OR: '|';
|
||||
BIT_AND: '&';
|
||||
BIT_XOR: '^';
|
||||
|
||||
fragment LETTER: [A-Z_];
|
||||
fragment IPV6_OCTECT: [0-9A-F][0-9A-F][0-9A-F][0-9A-F];
|
||||
IPV4_OCTECT: [0-9]?[0-9]?[0-9];
|
||||
fragment DEC_DOT_DEC: (DEC_DIGIT+ '.' DEC_DIGIT+ | DEC_DIGIT+ '.' | '.' DEC_DIGIT+);
|
||||
fragment HEX_DIGIT: [0-9A-F];
|
||||
fragment DEC_DIGIT: [0-9];
|
||||
|
||||
fragment FullWidthLetter
|
||||
: '\u00c0'..'\u00d6'
|
||||
| '\u00d8'..'\u00f6'
|
||||
| '\u00f8'..'\u00ff'
|
||||
| '\u0100'..'\u1fff'
|
||||
| '\u2c00'..'\u2fff'
|
||||
| '\u3040'..'\u318f'
|
||||
| '\u3300'..'\u337f'
|
||||
| '\u3400'..'\u3fff'
|
||||
| '\u4e00'..'\u9fff'
|
||||
| '\ua000'..'\ud7ff'
|
||||
| '\uf900'..'\ufaff'
|
||||
| '\uff00'..'\ufff0'
|
||||
// | '\u10000'..'\u1F9FF' //not support four bytes chars
|
||||
// | '\u20000'..'\u2FA1F'
|
||||
;
|
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
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
@ -1,2 +1,2 @@
|
||||
export * from './core';
|
||||
export * from './parser';
|
||||
export * from './utils';
|
||||
|
3175
src/lib/generic/SqlLexer.interp
Normal file
3175
src/lib/generic/SqlLexer.interp
Normal file
File diff suppressed because one or more lines are too long
9901
src/lib/generic/SqlLexer.js
Normal file
9901
src/lib/generic/SqlLexer.js
Normal file
File diff suppressed because it is too large
Load Diff
2074
src/lib/generic/SqlLexer.tokens
Normal file
2074
src/lib/generic/SqlLexer.tokens
Normal file
File diff suppressed because it is too large
Load Diff
2423
src/lib/generic/SqlParser.interp
Normal file
2423
src/lib/generic/SqlParser.interp
Normal file
File diff suppressed because one or more lines are too long
87886
src/lib/generic/SqlParser.js
Normal file
87886
src/lib/generic/SqlParser.js
Normal file
File diff suppressed because one or more lines are too long
2074
src/lib/generic/SqlParser.tokens
Normal file
2074
src/lib/generic/SqlParser.tokens
Normal file
File diff suppressed because it is too large
Load Diff
4929
src/lib/generic/SqlParserListener.js
Normal file
4929
src/lib/generic/SqlParserListener.js
Normal file
File diff suppressed because it is too large
Load Diff
3292
src/lib/generic/SqlParserVisitor.js
Normal file
3292
src/lib/generic/SqlParserVisitor.js
Normal file
File diff suppressed because it is too large
Load Diff
985
src/lib/hive/HiveSql.interp
Normal file
985
src/lib/hive/HiveSql.interp
Normal file
File diff suppressed because one or more lines are too long
384
src/lib/hive/HiveSql.tokens
Normal file
384
src/lib/hive/HiveSql.tokens
Normal file
@ -0,0 +1,384 @@
|
||||
T__0=1
|
||||
T__1=2
|
||||
T__2=3
|
||||
T__3=4
|
||||
T__4=5
|
||||
T__5=6
|
||||
T__6=7
|
||||
T__7=8
|
||||
T__8=9
|
||||
T__9=10
|
||||
T_GO=11
|
||||
T_BEGIN=12
|
||||
T_SEMICOLON=13
|
||||
T_END=14
|
||||
T_EXCEPTION=15
|
||||
T_WHEN=16
|
||||
L_ID=17
|
||||
T_THEN=18
|
||||
T_NULL=19
|
||||
T_SET=20
|
||||
T_COMMA=21
|
||||
T_COLON=22
|
||||
T_EQUAL=23
|
||||
T_OPEN_P=24
|
||||
T_CLOSE_P=25
|
||||
T_ALLOCATE=26
|
||||
T_CURSOR=27
|
||||
T_FOR=28
|
||||
T_RESULT=29
|
||||
T_PROCEDURE=30
|
||||
T_ASSOCIATE=31
|
||||
T_LOCATOR=32
|
||||
T_LOCATORS=33
|
||||
T_WITH=34
|
||||
T_TRANSACTION=35
|
||||
T_BREAK=36
|
||||
T_CALL=37
|
||||
T_DECLARE=38
|
||||
T_AS=39
|
||||
T_CONSTANT=40
|
||||
T_CONDITION=41
|
||||
T_IS=42
|
||||
T_RETURN=43
|
||||
T_ONLY=44
|
||||
T_TO=45
|
||||
T_CALLER=46
|
||||
T_CLIENT=47
|
||||
T_WITHOUT=48
|
||||
T_CONTINUE=49
|
||||
T_EXIT=50
|
||||
T_HANDLER=51
|
||||
T_SQLEXCEPTION=52
|
||||
T_SQLWARNING=53
|
||||
T_NOT=54
|
||||
T_FOUND=55
|
||||
T_GLOBAL=56
|
||||
T_TEMPORARY=57
|
||||
T_TABLE=58
|
||||
T_CREATE=59
|
||||
T_IF=60
|
||||
T_EXISTS=61
|
||||
T_LOCAL=62
|
||||
T_MULTISET=63
|
||||
T_VOLATILE=64
|
||||
T_LIKE=65
|
||||
T_CONSTRAINT=66
|
||||
T_PRIMARY=67
|
||||
T_KEY=68
|
||||
T_UNIQUE=69
|
||||
T_REFERENCES=70
|
||||
T_IDENTITY=71
|
||||
L_INT=72
|
||||
T_AUTO_INCREMENT=73
|
||||
T_ENABLE=74
|
||||
T_CLUSTERED=75
|
||||
T_ASC=76
|
||||
T_DESC=77
|
||||
T_FOREIGN=78
|
||||
T_ON=79
|
||||
T_UPDATE=80
|
||||
T_DELETE=81
|
||||
T_NO=82
|
||||
T_ACTION=83
|
||||
T_RESTRICT=84
|
||||
T_DEFAULT=85
|
||||
T_CASCADE=86
|
||||
T_LOG=87
|
||||
T_FALLBACK=88
|
||||
T_COMMIT=89
|
||||
T_PRESERVE=90
|
||||
T_ROWS=91
|
||||
T_SEGMENT=92
|
||||
T_CREATION=93
|
||||
T_IMMEDIATE=94
|
||||
T_DEFERRED=95
|
||||
T_PCTFREE=96
|
||||
T_PCTUSED=97
|
||||
T_INITRANS=98
|
||||
T_MAXTRANS=99
|
||||
T_NOCOMPRESS=100
|
||||
T_LOGGING=101
|
||||
T_NOLOGGING=102
|
||||
T_STORAGE=103
|
||||
T_TABLESPACE=104
|
||||
T_INDEX=105
|
||||
T_IN=106
|
||||
T_REPLACE=107
|
||||
T_DISTRIBUTE=108
|
||||
T_BY=109
|
||||
T_HASH=110
|
||||
T_LOGGED=111
|
||||
T_COMPRESS=112
|
||||
T_YES=113
|
||||
T_DEFINITION=114
|
||||
T_DROP=115
|
||||
T_DATA=116
|
||||
T_STORED=117
|
||||
T_ROW=118
|
||||
T_FORMAT=119
|
||||
T_DELIMITED=120
|
||||
T_FIELDS=121
|
||||
T_TERMINATED=122
|
||||
T_ESCAPED=123
|
||||
T_COLLECTION=124
|
||||
T_ITEMS=125
|
||||
T_MAP=126
|
||||
T_KEYS=127
|
||||
T_LINES=128
|
||||
T_DEFINED=129
|
||||
T_TEXTIMAGE_ON=130
|
||||
T_COMMENT=131
|
||||
T_CHARACTER=132
|
||||
T_CHARSET=133
|
||||
T_ENGINE=134
|
||||
T_ALTER=135
|
||||
T_ADD2=136
|
||||
T_CHAR=137
|
||||
T_BIGINT=138
|
||||
T_BINARY_DOUBLE=139
|
||||
T_BINARY_FLOAT=140
|
||||
T_BINARY_INTEGER=141
|
||||
T_BIT=142
|
||||
T_DATE=143
|
||||
T_DATETIME=144
|
||||
T_DEC=145
|
||||
T_DECIMAL=146
|
||||
T_DOUBLE=147
|
||||
T_PRECISION=148
|
||||
T_FLOAT=149
|
||||
T_INT=150
|
||||
T_INT2=151
|
||||
T_INT4=152
|
||||
T_INT8=153
|
||||
T_INTEGER=154
|
||||
T_NCHAR=155
|
||||
T_NVARCHAR=156
|
||||
T_NUMBER=157
|
||||
T_NUMERIC=158
|
||||
T_PLS_INTEGER=159
|
||||
T_REAL=160
|
||||
T_RESULT_SET_LOCATOR=161
|
||||
T_VARYING=162
|
||||
T_SIMPLE_FLOAT=163
|
||||
T_SIMPLE_DOUBLE=164
|
||||
T_SIMPLE_INTEGER=165
|
||||
T_SMALLINT=166
|
||||
T_SMALLDATETIME=167
|
||||
T_STRING=168
|
||||
T_SYS_REFCURSOR=169
|
||||
T_TIMESTAMP=170
|
||||
T_TINYINT=171
|
||||
T_VARCHAR=172
|
||||
T_VARCHAR2=173
|
||||
T_XML=174
|
||||
T_TYPE=175
|
||||
T_ROWTYPE=176
|
||||
T_MAX=177
|
||||
T_BYTE=178
|
||||
T_CASESPECIFIC=179
|
||||
T_CS=180
|
||||
T_DATABASE=181
|
||||
T_SCHEMA=182
|
||||
T_LOCATION=183
|
||||
T_OR=184
|
||||
T_FUNCTION=185
|
||||
T_RETURNS=186
|
||||
T_PACKAGE=187
|
||||
T_PROC=188
|
||||
T_BODY=189
|
||||
T_OUT=190
|
||||
T_INOUT=191
|
||||
T_LANGUAGE=192
|
||||
T_SQL=193
|
||||
T_SECURITY=194
|
||||
T_CREATOR=195
|
||||
T_DEFINER=196
|
||||
T_INVOKER=197
|
||||
T_OWNER=198
|
||||
T_DYNAMIC=199
|
||||
T_SETS=200
|
||||
T_EXEC=201
|
||||
T_EXECUTE=202
|
||||
T_INTO=203
|
||||
T_ELSE=204
|
||||
T_ELSIF=205
|
||||
T_ELSEIF=206
|
||||
T_INCLUDE=207
|
||||
T_INSERT=208
|
||||
T_OVERWRITE=209
|
||||
T_VALUES=210
|
||||
T_DIRECTORY=211
|
||||
T_GET=212
|
||||
T_DIAGNOSTICS=213
|
||||
T_MESSAGE_TEXT=214
|
||||
T_ROW_COUNT=215
|
||||
T_GRANT=216
|
||||
T_ROLE=217
|
||||
T_LEAVE=218
|
||||
T_OBJECT=219
|
||||
T_AT=220
|
||||
T_OPEN=221
|
||||
T_FETCH=222
|
||||
T_FROM=223
|
||||
T_COLLECT=224
|
||||
T_STATISTICS=225
|
||||
T_STATS=226
|
||||
T_COLUMN=227
|
||||
T_CLOSE=228
|
||||
T_CMP=229
|
||||
T_SUM=230
|
||||
T_COPY=231
|
||||
T_HDFS=232
|
||||
T_BATCHSIZE=233
|
||||
T_DELIMITER=234
|
||||
T_SQLINSERT=235
|
||||
T_IGNORE=236
|
||||
T_WORK=237
|
||||
T_PRINT=238
|
||||
T_QUIT=239
|
||||
T_RAISE=240
|
||||
T_RESIGNAL=241
|
||||
T_SQLSTATE=242
|
||||
T_VALUE=243
|
||||
T_ROLLBACK=244
|
||||
T_CURRENT=245
|
||||
T_CURRENT_SCHEMA=246
|
||||
T_ANSI_NULLS=247
|
||||
T_ANSI_PADDING=248
|
||||
T_NOCOUNT=249
|
||||
T_QUOTED_IDENTIFIER=250
|
||||
T_XACT_ABORT=251
|
||||
T_OFF=252
|
||||
T_QUERY_BAND=253
|
||||
T_NONE=254
|
||||
T_SESSION=255
|
||||
T_SIGNAL=256
|
||||
T_SUMMARY=257
|
||||
T_TOP=258
|
||||
T_LIMIT=259
|
||||
T_TRUNCATE=260
|
||||
T_USE=261
|
||||
T_WHILE=262
|
||||
T_DO=263
|
||||
T_LOOP=264
|
||||
T_REVERSE=265
|
||||
T_DOT2=266
|
||||
T_STEP=267
|
||||
L_LABEL=268
|
||||
T_LESS=269
|
||||
T_GREATER=270
|
||||
T_USING=271
|
||||
T_UNION=272
|
||||
T_ALL=273
|
||||
T_EXCEPT=274
|
||||
T_INTERSECT=275
|
||||
T_SELECT=276
|
||||
T_SEL=277
|
||||
T_DISTINCT=278
|
||||
T_TITLE=279
|
||||
L_S_STRING=280
|
||||
T_INNER=281
|
||||
T_JOIN=282
|
||||
T_LEFT=283
|
||||
T_RIGHT=284
|
||||
T_FULL=285
|
||||
T_OUTER=286
|
||||
T_WHERE=287
|
||||
T_GROUP=288
|
||||
T_HAVING=289
|
||||
T_QUALIFY=290
|
||||
T_ORDER=291
|
||||
T_RR=292
|
||||
T_RS=293
|
||||
T_UR=294
|
||||
T_AND=295
|
||||
T_KEEP=296
|
||||
T_EXCLUSIVE=297
|
||||
T_SHARE=298
|
||||
T_LOCKS=299
|
||||
T_MERGE=300
|
||||
T_MATCHED=301
|
||||
T_DESCRIBE=302
|
||||
T_BETWEEN=303
|
||||
T_EQUAL2=304
|
||||
T_NOTEQUAL=305
|
||||
T_NOTEQUAL2=306
|
||||
T_LESSEQUAL=307
|
||||
T_GREATEREQUAL=308
|
||||
T_RLIKE=309
|
||||
T_REGEXP=310
|
||||
T_MUL=311
|
||||
T_DIV=312
|
||||
T_ADD=313
|
||||
T_SUB=314
|
||||
T_INTERVAL=315
|
||||
T_DAY=316
|
||||
T_DAYS=317
|
||||
T_MICROSECOND=318
|
||||
T_MICROSECONDS=319
|
||||
T_SECOND=320
|
||||
T_SECONDS=321
|
||||
T_PIPE=322
|
||||
T_CONCAT=323
|
||||
T_CASE=324
|
||||
T_ISOPEN=325
|
||||
T_NOTFOUND=326
|
||||
T_AVG=327
|
||||
T_COUNT=328
|
||||
T_COUNT_BIG=329
|
||||
T_CUME_DIST=330
|
||||
T_DENSE_RANK=331
|
||||
T_FIRST_VALUE=332
|
||||
T_LAG=333
|
||||
T_LAST_VALUE=334
|
||||
T_LEAD=335
|
||||
T_MIN=336
|
||||
T_RANK=337
|
||||
T_ROW_NUMBER=338
|
||||
T_STDEV=339
|
||||
T_VAR=340
|
||||
T_VARIANCE=341
|
||||
T_OVER=342
|
||||
T_PARTITION=343
|
||||
T_ACTIVITY_COUNT=344
|
||||
T_CAST=345
|
||||
T_CURRENT_DATE=346
|
||||
T_CURRENT_TIMESTAMP=347
|
||||
T_CURRENT_USER=348
|
||||
T_USER=349
|
||||
T_MAX_PART_STRING=350
|
||||
T_MIN_PART_STRING=351
|
||||
T_MAX_PART_INT=352
|
||||
T_MIN_PART_INT=353
|
||||
T_MAX_PART_DATE=354
|
||||
T_MIN_PART_DATE=355
|
||||
T_PART_COUNT=356
|
||||
T_PART_LOC=357
|
||||
T_TRIM=358
|
||||
T_SUBSTRING=359
|
||||
T_SYSDATE=360
|
||||
T_HIVE=361
|
||||
T_HOST=362
|
||||
L_FILE=363
|
||||
L_D_STRING=364
|
||||
L_DEC=365
|
||||
T_TRUE=366
|
||||
T_FALSE=367
|
||||
T_DIR=368
|
||||
T_FILE=369
|
||||
T_FILES=370
|
||||
T_NEW=371
|
||||
T_PWD=372
|
||||
T_SESSIONS=373
|
||||
T_SUBDIR=374
|
||||
'@'=1
|
||||
'#'=2
|
||||
'/'=3
|
||||
'%'=4
|
||||
'.'=5
|
||||
'*'=6
|
||||
'!'=7
|
||||
';'=8
|
||||
'-'=9
|
||||
'+'=10
|
47
src/lib/hive/HiveSqlLexer.interp
Normal file
47
src/lib/hive/HiveSqlLexer.interp
Normal file
@ -0,0 +1,47 @@
|
||||
token literal names:
|
||||
null
|
||||
'@'
|
||||
'#'
|
||||
'/'
|
||||
'%'
|
||||
'.'
|
||||
'*'
|
||||
'!'
|
||||
';'
|
||||
'-'
|
||||
'+'
|
||||
|
||||
token symbolic names:
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
|
||||
rule names:
|
||||
T__0
|
||||
T__1
|
||||
T__2
|
||||
T__3
|
||||
T__4
|
||||
T__5
|
||||
T__6
|
||||
T__7
|
||||
T__8
|
||||
T__9
|
||||
|
||||
channel names:
|
||||
DEFAULT_TOKEN_CHANNEL
|
||||
HIDDEN
|
||||
|
||||
mode names:
|
||||
DEFAULT_MODE
|
||||
|
||||
atn:
|
||||
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 12, 43, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 2, 2, 12, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 3, 2, 2, 2, 42, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 3, 23, 3, 2, 2, 2, 5, 25, 3, 2, 2, 2, 7, 27, 3, 2, 2, 2, 9, 29, 3, 2, 2, 2, 11, 31, 3, 2, 2, 2, 13, 33, 3, 2, 2, 2, 15, 35, 3, 2, 2, 2, 17, 37, 3, 2, 2, 2, 19, 39, 3, 2, 2, 2, 21, 41, 3, 2, 2, 2, 23, 24, 7, 66, 2, 2, 24, 4, 3, 2, 2, 2, 25, 26, 7, 37, 2, 2, 26, 6, 3, 2, 2, 2, 27, 28, 7, 49, 2, 2, 28, 8, 3, 2, 2, 2, 29, 30, 7, 39, 2, 2, 30, 10, 3, 2, 2, 2, 31, 32, 7, 48, 2, 2, 32, 12, 3, 2, 2, 2, 33, 34, 7, 44, 2, 2, 34, 14, 3, 2, 2, 2, 35, 36, 7, 35, 2, 2, 36, 16, 3, 2, 2, 2, 37, 38, 7, 61, 2, 2, 38, 18, 3, 2, 2, 2, 39, 40, 7, 47, 2, 2, 40, 20, 3, 2, 2, 2, 41, 42, 7, 45, 2, 2, 42, 22, 3, 2, 2, 2, 3, 2, 2]
|
85
src/lib/hive/HiveSqlLexer.js
Normal file
85
src/lib/hive/HiveSqlLexer.js
Normal file
@ -0,0 +1,85 @@
|
||||
// Generated from /Users/ziv/Workspace/dt-sql-parser/src/grammar/hive/HiveSql.g4 by ANTLR 4.8
|
||||
// jshint ignore: start
|
||||
var antlr4 = require('antlr4/index');
|
||||
|
||||
|
||||
|
||||
var serializedATN = ["\u0003\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964",
|
||||
"\u0002\f+\b\u0001\u0004\u0002\t\u0002\u0004\u0003\t\u0003\u0004\u0004",
|
||||
"\t\u0004\u0004\u0005\t\u0005\u0004\u0006\t\u0006\u0004\u0007\t\u0007",
|
||||
"\u0004\b\t\b\u0004\t\t\t\u0004\n\t\n\u0004\u000b\t\u000b\u0003\u0002",
|
||||
"\u0003\u0002\u0003\u0003\u0003\u0003\u0003\u0004\u0003\u0004\u0003\u0005",
|
||||
"\u0003\u0005\u0003\u0006\u0003\u0006\u0003\u0007\u0003\u0007\u0003\b",
|
||||
"\u0003\b\u0003\t\u0003\t\u0003\n\u0003\n\u0003\u000b\u0003\u000b\u0002",
|
||||
"\u0002\f\u0003\u0003\u0005\u0004\u0007\u0005\t\u0006\u000b\u0007\r\b",
|
||||
"\u000f\t\u0011\n\u0013\u000b\u0015\f\u0003\u0002\u0002\u0002*\u0002",
|
||||
"\u0003\u0003\u0002\u0002\u0002\u0002\u0005\u0003\u0002\u0002\u0002\u0002",
|
||||
"\u0007\u0003\u0002\u0002\u0002\u0002\t\u0003\u0002\u0002\u0002\u0002",
|
||||
"\u000b\u0003\u0002\u0002\u0002\u0002\r\u0003\u0002\u0002\u0002\u0002",
|
||||
"\u000f\u0003\u0002\u0002\u0002\u0002\u0011\u0003\u0002\u0002\u0002\u0002",
|
||||
"\u0013\u0003\u0002\u0002\u0002\u0002\u0015\u0003\u0002\u0002\u0002\u0003",
|
||||
"\u0017\u0003\u0002\u0002\u0002\u0005\u0019\u0003\u0002\u0002\u0002\u0007",
|
||||
"\u001b\u0003\u0002\u0002\u0002\t\u001d\u0003\u0002\u0002\u0002\u000b",
|
||||
"\u001f\u0003\u0002\u0002\u0002\r!\u0003\u0002\u0002\u0002\u000f#\u0003",
|
||||
"\u0002\u0002\u0002\u0011%\u0003\u0002\u0002\u0002\u0013\'\u0003\u0002",
|
||||
"\u0002\u0002\u0015)\u0003\u0002\u0002\u0002\u0017\u0018\u0007B\u0002",
|
||||
"\u0002\u0018\u0004\u0003\u0002\u0002\u0002\u0019\u001a\u0007%\u0002",
|
||||
"\u0002\u001a\u0006\u0003\u0002\u0002\u0002\u001b\u001c\u00071\u0002",
|
||||
"\u0002\u001c\b\u0003\u0002\u0002\u0002\u001d\u001e\u0007\'\u0002\u0002",
|
||||
"\u001e\n\u0003\u0002\u0002\u0002\u001f \u00070\u0002\u0002 \f\u0003",
|
||||
"\u0002\u0002\u0002!\"\u0007,\u0002\u0002\"\u000e\u0003\u0002\u0002\u0002",
|
||||
"#$\u0007#\u0002\u0002$\u0010\u0003\u0002\u0002\u0002%&\u0007=\u0002",
|
||||
"\u0002&\u0012\u0003\u0002\u0002\u0002\'(\u0007/\u0002\u0002(\u0014\u0003",
|
||||
"\u0002\u0002\u0002)*\u0007-\u0002\u0002*\u0016\u0003\u0002\u0002\u0002",
|
||||
"\u0003\u0002\u0002"].join("");
|
||||
|
||||
|
||||
var atn = new antlr4.atn.ATNDeserializer().deserialize(serializedATN);
|
||||
|
||||
var decisionsToDFA = atn.decisionToState.map( function(ds, index) { return new antlr4.dfa.DFA(ds, index); });
|
||||
|
||||
function HiveSqlLexer(input) {
|
||||
antlr4.Lexer.call(this, input);
|
||||
this._interp = new antlr4.atn.LexerATNSimulator(this, atn, decisionsToDFA, new antlr4.PredictionContextCache());
|
||||
return this;
|
||||
}
|
||||
|
||||
HiveSqlLexer.prototype = Object.create(antlr4.Lexer.prototype);
|
||||
HiveSqlLexer.prototype.constructor = HiveSqlLexer;
|
||||
|
||||
Object.defineProperty(HiveSqlLexer.prototype, "atn", {
|
||||
get : function() {
|
||||
return atn;
|
||||
}
|
||||
});
|
||||
|
||||
HiveSqlLexer.EOF = antlr4.Token.EOF;
|
||||
HiveSqlLexer.T__0 = 1;
|
||||
HiveSqlLexer.T__1 = 2;
|
||||
HiveSqlLexer.T__2 = 3;
|
||||
HiveSqlLexer.T__3 = 4;
|
||||
HiveSqlLexer.T__4 = 5;
|
||||
HiveSqlLexer.T__5 = 6;
|
||||
HiveSqlLexer.T__6 = 7;
|
||||
HiveSqlLexer.T__7 = 8;
|
||||
HiveSqlLexer.T__8 = 9;
|
||||
HiveSqlLexer.T__9 = 10;
|
||||
|
||||
HiveSqlLexer.prototype.channelNames = [ "DEFAULT_TOKEN_CHANNEL", "HIDDEN" ];
|
||||
|
||||
HiveSqlLexer.prototype.modeNames = [ "DEFAULT_MODE" ];
|
||||
|
||||
HiveSqlLexer.prototype.literalNames = [ null, "'@'", "'#'", "'/'", "'%'",
|
||||
"'.'", "'*'", "'!'", "';'", "'-'",
|
||||
"'+'" ];
|
||||
|
||||
HiveSqlLexer.prototype.symbolicNames = [ ];
|
||||
|
||||
HiveSqlLexer.prototype.ruleNames = [ "T__0", "T__1", "T__2", "T__3", "T__4",
|
||||
"T__5", "T__6", "T__7", "T__8", "T__9" ];
|
||||
|
||||
HiveSqlLexer.prototype.grammarFileName = "HiveSql.g4";
|
||||
|
||||
|
||||
exports.HiveSqlLexer = HiveSqlLexer;
|
||||
|
20
src/lib/hive/HiveSqlLexer.tokens
Normal file
20
src/lib/hive/HiveSqlLexer.tokens
Normal file
@ -0,0 +1,20 @@
|
||||
T__0=1
|
||||
T__1=2
|
||||
T__2=3
|
||||
T__3=4
|
||||
T__4=5
|
||||
T__5=6
|
||||
T__6=7
|
||||
T__7=8
|
||||
T__8=9
|
||||
T__9=10
|
||||
'@'=1
|
||||
'#'=2
|
||||
'/'=3
|
||||
'%'=4
|
||||
'.'=5
|
||||
'*'=6
|
||||
'!'=7
|
||||
';'=8
|
||||
'-'=9
|
||||
'+'=10
|
2058
src/lib/hive/HiveSqlListener.js
Normal file
2058
src/lib/hive/HiveSqlListener.js
Normal file
File diff suppressed because it is too large
Load Diff
37756
src/lib/hive/HiveSqlParser.js
Normal file
37756
src/lib/hive/HiveSqlParser.js
Normal file
File diff suppressed because one or more lines are too long
1378
src/lib/hive/HiveSqlVisitor.js
Normal file
1378
src/lib/hive/HiveSqlVisitor.js
Normal file
File diff suppressed because it is too large
Load Diff
16
src/lib/plsql/PlSqlBaseLexer.js
Normal file
16
src/lib/plsql/PlSqlBaseLexer.js
Normal file
@ -0,0 +1,16 @@
|
||||
const Lexer = require('antlr4').Lexer;
|
||||
|
||||
function PlSqlBaseLexer(...args) {
|
||||
Lexer.call(this, ...args);
|
||||
return this;
|
||||
}
|
||||
|
||||
PlSqlBaseLexer.prototype = Object.create(Lexer.prototype);
|
||||
PlSqlBaseLexer.prototype.constructor = PlSqlBaseLexer;
|
||||
|
||||
PlSqlBaseLexer.prototype.IsNewlineAtPos = function(pos) {
|
||||
const la = this._input.LA(pos);
|
||||
return la == -1 || la == '\n';
|
||||
};
|
||||
|
||||
exports.PlSqlBaseLexer = PlSqlBaseLexer;
|
27
src/lib/plsql/PlSqlBaseParser.js
Normal file
27
src/lib/plsql/PlSqlBaseParser.js
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
const Parser = require('antlr4').Parser;
|
||||
|
||||
function PlSqlBaseParser(...args) {
|
||||
Parser.call(this, ...args);
|
||||
this._isVersion10 = false;
|
||||
this._isVersion12 = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
PlSqlBaseParser.prototype = Object.create(Parser.prototype);
|
||||
PlSqlBaseParser.prototype.constructor = PlSqlBaseParser;
|
||||
|
||||
PlSqlBaseParser.prototype.isVersion10 = function() {
|
||||
return this._isVersion10;
|
||||
};
|
||||
PlSqlBaseParser.prototype.isVersion12 = function() {
|
||||
return this._isVersion12;
|
||||
};
|
||||
PlSqlBaseParser.prototype.setVersion10 = function(value) {
|
||||
this._isVersion10 = value;
|
||||
};
|
||||
PlSqlBaseParser.prototype.setVersion12 = function(value) {
|
||||
this._isVersion12 = value;
|
||||
};
|
||||
|
||||
exports.PlSqlBaseParser = PlSqlBaseParser;
|
6791
src/lib/plsql/PlSqlLexer.interp
Normal file
6791
src/lib/plsql/PlSqlLexer.interp
Normal file
File diff suppressed because one or more lines are too long
23834
src/lib/plsql/PlSqlLexer.js
Normal file
23834
src/lib/plsql/PlSqlLexer.js
Normal file
File diff suppressed because it is too large
Load Diff
4484
src/lib/plsql/PlSqlLexer.tokens
Normal file
4484
src/lib/plsql/PlSqlLexer.tokens
Normal file
File diff suppressed because it is too large
Load Diff
5268
src/lib/plsql/PlSqlParser.interp
Normal file
5268
src/lib/plsql/PlSqlParser.interp
Normal file
File diff suppressed because one or more lines are too long
100054
src/lib/plsql/PlSqlParser.js
Normal file
100054
src/lib/plsql/PlSqlParser.js
Normal file
File diff suppressed because one or more lines are too long
4484
src/lib/plsql/PlSqlParser.tokens
Normal file
4484
src/lib/plsql/PlSqlParser.tokens
Normal file
File diff suppressed because it is too large
Load Diff
6792
src/lib/plsql/PlSqlParserListener.js
Normal file
6792
src/lib/plsql/PlSqlParserListener.js
Normal file
File diff suppressed because it is too large
Load Diff
4534
src/lib/plsql/PlSqlParserVisitor.js
Normal file
4534
src/lib/plsql/PlSqlParserVisitor.js
Normal file
File diff suppressed because it is too large
Load Diff
111
src/parser/common/BasicParser.ts
Normal file
111
src/parser/common/BasicParser.ts
Normal file
@ -0,0 +1,111 @@
|
||||
import { Token, Lexer } from 'antlr4';
|
||||
import { ParseTreeWalker } from 'antlr4/tree';
|
||||
|
||||
import ParserErrorListener, {
|
||||
ParserError,
|
||||
ErrorHandler,
|
||||
ParserErrorCollector,
|
||||
} from './parserErrorListener';
|
||||
|
||||
/**
|
||||
* Custom Parser class, subclass needs extends it.
|
||||
*/
|
||||
export default abstract class BasicParser<C = any> {
|
||||
private _parser;
|
||||
|
||||
public parse(
|
||||
input: string,
|
||||
errorListener?: ErrorHandler,
|
||||
) {
|
||||
const parser = this.createParser(input);
|
||||
this._parser = parser;
|
||||
|
||||
parser.removeErrorListeners();
|
||||
parser.addErrorListener(new ParserErrorListener(errorListener));
|
||||
|
||||
const parserTree = parser.program();
|
||||
|
||||
return parserTree;
|
||||
}
|
||||
|
||||
public validate(input: string): ParserError[] {
|
||||
const lexerError = []; const syntaxErrors = [];
|
||||
|
||||
const parser = this.createParser(input);
|
||||
this._parser = parser;
|
||||
|
||||
parser.removeErrorListeners();
|
||||
parser.addErrorListener(new ParserErrorCollector(syntaxErrors));
|
||||
|
||||
parser.program();
|
||||
|
||||
return lexerError.concat(syntaxErrors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create antrl4 Lexer object
|
||||
* @param input source string
|
||||
*/
|
||||
public abstract createLexer(input: string): Lexer;
|
||||
|
||||
/**
|
||||
* Create Parser by lexer
|
||||
* @param lexer Lexer
|
||||
*/
|
||||
public abstract createParserFromLexer(lexer: Lexer);
|
||||
|
||||
/**
|
||||
* Visit parser tree
|
||||
* @param parserTree
|
||||
*/
|
||||
// public abstract visit(visitor: any, parserTree: any);
|
||||
|
||||
/**
|
||||
* The source string
|
||||
* @param input string
|
||||
*/
|
||||
public getAllTokens(input: string): Token[] {
|
||||
return this.createLexer(input).getAllTokens();
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Parser instance by input string
|
||||
* @param input
|
||||
*/
|
||||
public createParser(input: string) {
|
||||
const lexer = this.createLexer(input);
|
||||
const parser: any = this.createParserFromLexer(lexer);
|
||||
parser.buildParseTrees = true;
|
||||
this._parser = parser;
|
||||
|
||||
return parser;
|
||||
}
|
||||
|
||||
/**
|
||||
* It convert tree to string, it's convenient to use in unit test.
|
||||
* @param string input
|
||||
*/
|
||||
public parserTreeToString(input: string): string {
|
||||
const parser = this.createParser(input);
|
||||
this._parser = parser;
|
||||
|
||||
const tree = parser.statement();
|
||||
return tree.toStringTree(parser.ruleNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get List-like style tree string
|
||||
* @param parserTree
|
||||
*/
|
||||
public toString(parserTree: any): string {
|
||||
return parserTree.toStringTree(this._parser.ruleNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param listener Listener instance extends ParserListener
|
||||
* @param parserTree parser Tree
|
||||
*/
|
||||
public listen(listener: any, parserTree: any) {
|
||||
ParseTreeWalker.DEFAULT.walk(listener, parserTree);
|
||||
}
|
||||
}
|
84
src/parser/common/parserErrorListener.ts
Normal file
84
src/parser/common/parserErrorListener.ts
Normal file
@ -0,0 +1,84 @@
|
||||
import { Token, Recognizer } from 'antlr4';
|
||||
import { ErrorListener } from 'antlr4/error';
|
||||
|
||||
export interface ParserError {
|
||||
startLine: number;
|
||||
endLine: number;
|
||||
startCol: number;
|
||||
endCol: number;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface SyntaxError {
|
||||
recognizer: Recognizer;
|
||||
offendingSymbol: Token;
|
||||
line: number;
|
||||
charPositionInLine: number;
|
||||
msg: string;
|
||||
e: any;
|
||||
}
|
||||
|
||||
export type ErrorHandler = (err: ParserError, errOption: SyntaxError) => void;
|
||||
|
||||
export class ParserErrorCollector extends ErrorListener {
|
||||
private _errors: ParserError[];
|
||||
|
||||
constructor(error: ParserError[]) {
|
||||
super();
|
||||
this._errors = error;
|
||||
}
|
||||
|
||||
syntaxError(
|
||||
recognizer: Recognizer, offendingSymbol: Token, line: number,
|
||||
charPositionInLine: number, msg: string, e: any,
|
||||
) {
|
||||
let endCol = charPositionInLine + 1;
|
||||
if (offendingSymbol &&offendingSymbol.text !== null) {
|
||||
endCol = charPositionInLine + offendingSymbol.text.length;
|
||||
}
|
||||
this._errors.push({
|
||||
startLine: line,
|
||||
endLine: line,
|
||||
startCol: charPositionInLine,
|
||||
endCol: endCol,
|
||||
message: msg,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export default class ParserErrorListener extends ErrorListener {
|
||||
private _errorHandler;
|
||||
|
||||
constructor(errorListener: ErrorHandler) {
|
||||
super();
|
||||
this._errorHandler = errorListener;
|
||||
}
|
||||
|
||||
syntaxError(
|
||||
recognizer: Recognizer, offendingSymbol: Token, line: number,
|
||||
charPositionInLine: number, msg: string, e: any,
|
||||
) {
|
||||
let endCol = charPositionInLine + 1;
|
||||
if (offendingSymbol &&offendingSymbol.text !== null) {
|
||||
endCol = charPositionInLine + offendingSymbol.text.length;
|
||||
}
|
||||
if (this._errorHandler) {
|
||||
this._errorHandler({
|
||||
startLine: line,
|
||||
endLine: line,
|
||||
startCol: charPositionInLine,
|
||||
endCol: endCol,
|
||||
message: msg,
|
||||
}, {
|
||||
e,
|
||||
line,
|
||||
msg,
|
||||
recognizer,
|
||||
offendingSymbol,
|
||||
charPositionInLine,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
20
src/parser/generic.ts
Normal file
20
src/parser/generic.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { InputStream, CommonTokenStream, Lexer } from 'antlr4';
|
||||
import { SqlLexer } from '../lib/generic/SqlLexer';
|
||||
import { SqlParser } from '../lib/generic/SqlParser';
|
||||
export * from '../lib/generic/SqlParserVisitor';
|
||||
export * from '../lib/generic/SqlParserListener';
|
||||
|
||||
import BasicParser from './common/BasicParser';
|
||||
|
||||
export default class GenericSQL extends BasicParser {
|
||||
public createLexer(input: string): Lexer {
|
||||
const chars = new InputStream(input.toUpperCase()); // Some Lexer only support uppercase token, So you need transform
|
||||
const lexer = <unknown> new SqlLexer(chars) as Lexer;
|
||||
return lexer;
|
||||
}
|
||||
public createParserFromLexer(lexer: Lexer) {
|
||||
const tokenStream = new CommonTokenStream(lexer);
|
||||
return new SqlParser(tokenStream);
|
||||
}
|
||||
}
|
||||
|
20
src/parser/hive.ts
Normal file
20
src/parser/hive.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { InputStream, CommonTokenStream, Lexer } from 'antlr4';
|
||||
import { HiveSqlLexer } from '../lib/hive/HiveSqlLexer';
|
||||
import { HiveSqlParser } from '../lib/hive/HiveSqlParser';
|
||||
export * from '../lib/hive/HiveSqlListener';
|
||||
export * from '../lib/hive/HiveSqlVisitor';
|
||||
|
||||
import BasicParser from './common/BasicParser';
|
||||
|
||||
export default class HiveSQL extends BasicParser {
|
||||
public createLexer(input: string): Lexer {
|
||||
const chars = new InputStream(input);
|
||||
const lexer = <unknown> new HiveSqlLexer(chars) as Lexer;
|
||||
return lexer;
|
||||
}
|
||||
public createParserFromLexer(lexer: Lexer) {
|
||||
const tokenStream = new CommonTokenStream(lexer);
|
||||
return new HiveSqlParser(tokenStream);
|
||||
}
|
||||
}
|
||||
|
3
src/parser/index.ts
Normal file
3
src/parser/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export * from './generic';
|
||||
export * from './plsql';
|
||||
export * from './hive';
|
19
src/parser/plsql.ts
Normal file
19
src/parser/plsql.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { InputStream, CommonTokenStream, Lexer } from 'antlr4';
|
||||
import { PlSqlLexer } from '../lib/plsql/PlSqlLexer';
|
||||
import { PlSqlParser } from '../lib/plsql/PlSqlParser';
|
||||
export * from '../lib/plsql/PlSqlParserListener';
|
||||
export * from '../lib/plsql/PlSqlParserVisitor';
|
||||
|
||||
import BasicParser from './common/BasicParser';
|
||||
|
||||
export default class PLSQLParser extends BasicParser {
|
||||
public createLexer(input: string): Lexer {
|
||||
const chars = new InputStream(input.toUpperCase());
|
||||
const lexer = <unknown> new PlSqlLexer(chars) as Lexer;
|
||||
return lexer;
|
||||
}
|
||||
public createParserFromLexer(lexer: Lexer) {
|
||||
const tokenStream = new CommonTokenStream(lexer);
|
||||
return new PlSqlParser(tokenStream);
|
||||
}
|
||||
}
|
12
test/parser/generic/lexer.test.ts
Normal file
12
test/parser/generic/lexer.test.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import SQLParser from '../../../src/parser/generic';
|
||||
|
||||
describe('GenericSQL Lexer tests', () => {
|
||||
const mysqlParser = new SQLParser();
|
||||
|
||||
const sql = 'select id,name,sex from user1;';
|
||||
const tokens = mysqlParser.getAllTokens(sql);
|
||||
|
||||
test('token counts', () => {
|
||||
expect(tokens.length).toBe(12);
|
||||
});
|
||||
});
|
22
test/parser/generic/listener.test.ts
Normal file
22
test/parser/generic/listener.test.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import SQLParser, { SqlParserListener } from '../../../src/parser/generic';
|
||||
|
||||
describe('Generic SQL Listener Tests', () => {
|
||||
const expectTableName = 'user1';
|
||||
const sql = `select id,name,sex from ${expectTableName};`;
|
||||
const parser = new SQLParser();
|
||||
|
||||
const parserTree = parser.parse(sql);
|
||||
|
||||
test('Listener enterTableName', async () => {
|
||||
let result = '';
|
||||
class MyListener extends SqlParserListener {
|
||||
enterTableName(ctx): void {
|
||||
result = ctx.getText().toLowerCase();
|
||||
}
|
||||
}
|
||||
const listenTableName: any = new MyListener();
|
||||
|
||||
await parser.listen(listenTableName, parserTree);
|
||||
expect(result).toBe(expectTableName);
|
||||
});
|
||||
});
|
18
test/parser/generic/syntax.test.ts
Normal file
18
test/parser/generic/syntax.test.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import SQLParser from '../../../src/parser/generic';
|
||||
|
||||
describe('Generic SQL Syntax Tests', () => {
|
||||
const parser = new SQLParser();
|
||||
|
||||
test('Select Statement', () => {
|
||||
const sql = 'select id,name from user1;';
|
||||
const result = parser.validate(sql);
|
||||
|
||||
expect(result.length).toBe(0);
|
||||
});
|
||||
|
||||
test('Select 1+1', () => {
|
||||
const sql = 'SELECT 1+1;';
|
||||
const result = parser.validate(sql);
|
||||
expect(result.length).toBe(0);
|
||||
});
|
||||
});
|
27
test/parser/generic/visitor.test.ts
Normal file
27
test/parser/generic/visitor.test.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import SQLParser, { SqlParserVisitor } from '../../../src/parser/generic';
|
||||
|
||||
describe('Generic SQL Visitor Tests', () => {
|
||||
const expectTableName = 'user1';
|
||||
const sql = `select id,name,sex from ${expectTableName};`;
|
||||
const parser = new SQLParser();
|
||||
|
||||
const parserTree = parser.parse(sql, (error) => {
|
||||
console.log('Parse error:', error);
|
||||
});
|
||||
|
||||
console.log('Parser tree string:', parser.toString(parserTree));
|
||||
|
||||
test('Visitor visitTableName', () => {
|
||||
let result = '';
|
||||
class MyVisitor extends SqlParserVisitor {
|
||||
visitTableName(ctx): void {
|
||||
result = ctx.getText().toLowerCase();
|
||||
super.visitTableName(ctx);
|
||||
}
|
||||
}
|
||||
const visitor: any = new MyVisitor();
|
||||
visitor.visit(parserTree);
|
||||
|
||||
expect(result).toBe(expectTableName);
|
||||
});
|
||||
});
|
12
test/parser/hive/lexer.test.ts
Normal file
12
test/parser/hive/lexer.test.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import SQLParser from '../../../src/parser/hive';
|
||||
|
||||
describe('HiveSQL Lexer tests', () => {
|
||||
const parser = new SQLParser();
|
||||
// select id,name,sex from user1;
|
||||
const sql = 'SELECT * FROM t1';
|
||||
const tokens = parser.getAllTokens(sql);
|
||||
|
||||
test('token counts', () => {
|
||||
expect(tokens.length).toBe(12);
|
||||
});
|
||||
});
|
22
test/parser/hive/listener.test.ts
Normal file
22
test/parser/hive/listener.test.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import SQLParser, { HiveSqlListener } from '../../../src/parser/hive';
|
||||
|
||||
describe('Hive SQL Listener Tests', () => {
|
||||
const expectTableName = 'user1';
|
||||
const sql = `select id,name,sex from ${expectTableName};`;
|
||||
const parser = new SQLParser();
|
||||
|
||||
const parserTree = parser.parse(sql);
|
||||
|
||||
test('Listener enterTableName', async () => {
|
||||
let result = '';
|
||||
class MyListener extends HiveSqlListener {
|
||||
enterTableName(ctx): void {
|
||||
result = ctx.getText().toLowerCase();
|
||||
}
|
||||
}
|
||||
const listenTableName: any = new MyListener();
|
||||
|
||||
await parser.listen(listenTableName, parserTree);
|
||||
expect(result).toBe(expectTableName);
|
||||
});
|
||||
});
|
18
test/parser/hive/syntax.test.ts
Normal file
18
test/parser/hive/syntax.test.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import SQLParser from '../../../src/parser/hive';
|
||||
|
||||
describe('Hive SQL Syntax Tests', () => {
|
||||
const parser = new SQLParser();
|
||||
|
||||
test('Select Statement', () => {
|
||||
const sql = 'SELECT * FROM employee WHERE salary>30000;';
|
||||
const result = parser.validate(sql);
|
||||
|
||||
expect(result.length).toBe(0);
|
||||
});
|
||||
|
||||
test('Select 1+1', () => {
|
||||
const sql = 'SELECT 1+1;';
|
||||
const result = parser.validate(sql);
|
||||
expect(result.length).toBe(0);
|
||||
});
|
||||
});
|
27
test/parser/hive/visitor.test.ts
Normal file
27
test/parser/hive/visitor.test.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import SQLParser, { HiveSqlVisitor } from '../../../src/parser/hive';
|
||||
|
||||
describe('Generic SQL Visitor Tests', () => {
|
||||
const expectTableName = 'user1';
|
||||
const sql = `select id,name,sex from ${expectTableName};`;
|
||||
const parser = new SQLParser();
|
||||
|
||||
const parserTree = parser.parse(sql, (error) => {
|
||||
console.log('Parse error:', error);
|
||||
});
|
||||
|
||||
console.log('Parser tree string:', parser.toString(parserTree));
|
||||
|
||||
test('Visitor visitTableName', () => {
|
||||
let result = '';
|
||||
class MyVisitor extends HiveSqlVisitor {
|
||||
visitTable_name(ctx): void {
|
||||
result = ctx.getText().toLowerCase();
|
||||
super.visitTable_name(ctx);
|
||||
}
|
||||
}
|
||||
const visitor: any = new MyVisitor();
|
||||
visitor.visit(parserTree);
|
||||
|
||||
expect(result).toBe(expectTableName);
|
||||
});
|
||||
});
|
12
test/parser/plsql/lexer.test.ts
Normal file
12
test/parser/plsql/lexer.test.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import SQLParser from '../../../src/parser/plsql';
|
||||
|
||||
describe('PLSQL Lexer tests', () => {
|
||||
const parser = new SQLParser();
|
||||
|
||||
const sql = 'select id,name,sex from user1;';
|
||||
const tokens = parser.getAllTokens(sql);
|
||||
|
||||
test('token counts', () => {
|
||||
expect(tokens.length).toBe(12);
|
||||
});
|
||||
});
|
22
test/parser/plsql/listener.test.ts
Normal file
22
test/parser/plsql/listener.test.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import SQLParser, { PlSqlParserListener } from '../../../src/parser/plsql';
|
||||
|
||||
describe('PLSQL Listener Tests', () => {
|
||||
const expectTableName = 'user1';
|
||||
const sql = `select id,name,sex from ${expectTableName};`;
|
||||
const parser = new SQLParser();
|
||||
|
||||
const parserTree = parser.parse(sql);
|
||||
|
||||
test('Listener enterTableName', async () => {
|
||||
let result = '';
|
||||
class MyListener extends PlSqlParserListener {
|
||||
enterTable_ref_list(ctx): void {
|
||||
result = ctx.getText().toLowerCase();
|
||||
}
|
||||
}
|
||||
const listenTableName: any = new MyListener();
|
||||
|
||||
await parser.listen(listenTableName, parserTree);
|
||||
expect(result).toBe(expectTableName);
|
||||
});
|
||||
});
|
23
test/parser/plsql/syntax.test.ts
Normal file
23
test/parser/plsql/syntax.test.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import SQLParser from '../../../src/parser/plsql';
|
||||
|
||||
describe('PLSQL Syntax Tests', () => {
|
||||
const parser = new SQLParser();
|
||||
|
||||
test('Test simple select Statement', () => {
|
||||
const sql = 'select id,name from user1;';
|
||||
const result = parser.validate(sql);
|
||||
|
||||
expect(result.length).toBe(0);
|
||||
});
|
||||
|
||||
test(`Test select, where, order by`, () => {
|
||||
const sql = `
|
||||
select eid, emp_last, mgr_id, reportlevel
|
||||
from reports_to_101 r, auto a
|
||||
where r.c1 = a.c2
|
||||
order by reportlevel, eid
|
||||
`;
|
||||
const result = parser.validate(sql);
|
||||
expect(result.length).toBe(0);
|
||||
});
|
||||
});
|
23
test/parser/plsql/visitor.test.ts
Normal file
23
test/parser/plsql/visitor.test.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import SQLParser, { PlSqlParserVisitor } from '../../../src/parser/plsql';
|
||||
|
||||
describe('PLSQL Visitor Tests', () => {
|
||||
const expectTableName = 'user1';
|
||||
const sql = `select id,name,sex from ${expectTableName};`;
|
||||
const parser = new SQLParser();
|
||||
|
||||
const parserTree = parser.parse(sql);
|
||||
|
||||
test('Visitor visitTable_ref_list', () => {
|
||||
let result = '';
|
||||
class MyVisitor extends PlSqlParserVisitor {
|
||||
visitTable_ref_list(ctx): void {
|
||||
result = ctx.getText().toLowerCase();
|
||||
super.visitTable_ref_list(ctx);
|
||||
}
|
||||
}
|
||||
const visitor: any = new MyVisitor();
|
||||
visitor.visit(parserTree);
|
||||
|
||||
expect(result).toBe(expectTableName);
|
||||
});
|
||||
});
|
@ -1,16 +0,0 @@
|
||||
import MySQLParser from '../../../src/core/mysql';
|
||||
|
||||
describe('MySQL Lexer tests', () => {
|
||||
const mysqlParser = new MySQLParser();
|
||||
|
||||
const sql = 'select id,name,sex from user1;';
|
||||
const tokens = mysqlParser.getAllTokens(sql);
|
||||
|
||||
test('token counts', () => {
|
||||
expect(tokens.length).toBe(12);
|
||||
});
|
||||
|
||||
test('token counts', () => {
|
||||
expect(tokens.length).toBe(12);
|
||||
});
|
||||
});
|
@ -1,24 +0,0 @@
|
||||
import MySQLParser from '../../../src/core/mysql';
|
||||
|
||||
describe('MySQL Parser tests', () => {
|
||||
const mysql = new MySQLParser();
|
||||
|
||||
test('Select * FROM Statement', () => {
|
||||
const sql = 'SELECT * FROM tb;';
|
||||
const result = mysql.parserTreeToString(sql);
|
||||
expect(result).toEqual(`
|
||||
(statement (sqlStatements (
|
||||
sqlStatement (
|
||||
dmlStatement (
|
||||
selectStatement (
|
||||
querySpecification SELECT (selectElements *) (
|
||||
fromClause FROM (
|
||||
tableSources (tableSource (
|
||||
tableSourceItem (tableName (
|
||||
fullId (uid (
|
||||
simpleId TB
|
||||
)
|
||||
))))))))))) (emptyStatement ;)) <EOF>
|
||||
)`);
|
||||
});
|
||||
});
|
@ -1,11 +0,0 @@
|
||||
import MySQLParser from '../../../src/core/mysql';
|
||||
|
||||
describe('MySQL Syntax tests', () => {
|
||||
const mysql = new MySQLParser();
|
||||
test('Select Statement', () => {
|
||||
const sql = 'select id,name from user1;';
|
||||
const result = mysql.validate(sql);
|
||||
|
||||
expect(result.length).toBe(0);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user