dt-sql-parser 4.0.0 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -12
- package/dist/index.js +2 -12
- package/dist/lib/index.d.ts +0 -2
- package/dist/lib/index.js +0 -2
- package/dist/lib/mysql/MySqlParser.js +21 -21
- package/dist/lib/mysql/MySqlParserListener.d.ts +9 -9
- package/dist/lib/mysql/MySqlParserVisitor.d.ts +5 -5
- package/dist/parser/index.d.ts +0 -1
- package/dist/parser/index.js +0 -1
- package/package.json +6 -2
- package/dist/lib/plsql/PlSqlBaseLexer.d.ts +0 -4
- package/dist/lib/plsql/PlSqlBaseLexer.js +0 -7
- package/dist/lib/plsql/PlSqlBaseParser.d.ts +0 -11
- package/dist/lib/plsql/PlSqlBaseParser.js +0 -22
- package/dist/lib/plsql/PlSqlLexer.d.ts +0 -2381
- package/dist/lib/plsql/PlSqlLexer.js +0 -16441
- package/dist/lib/plsql/PlSqlParser.d.ts +0 -17080
- package/dist/lib/plsql/PlSqlParser.js +0 -184485
- package/dist/lib/plsql/PlSqlParserListener.d.ts +0 -8003
- package/dist/lib/plsql/PlSqlParserListener.js +0 -11
- package/dist/lib/plsql/PlSqlParserVisitor.d.ts +0 -5095
- package/dist/lib/plsql/PlSqlParserVisitor.js +0 -12
- package/dist/parser/plsql.d.ts +0 -14
- package/dist/parser/plsql.js +0 -27
- package/dist/utils/index.d.ts +0 -19
- package/dist/utils/index.js +0 -170
- package/dist/utils/token.d.ts +0 -59
- package/dist/utils/token.js +0 -48
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// Generated from dt-sql-parser/src/grammar/plsql/PlSqlParser.g4 by ANTLR 4.13.1
|
|
2
|
-
// @ts-nocheck
|
|
3
|
-
import { AbstractParseTreeVisitor } from "antlr4ng";
|
|
4
|
-
/**
|
|
5
|
-
* This interface defines a complete generic visitor for a parse tree produced
|
|
6
|
-
* by `PlSqlParser`.
|
|
7
|
-
*
|
|
8
|
-
* @param <Result> The return type of the visit operation. Use `void` for
|
|
9
|
-
* operations with no return type.
|
|
10
|
-
*/
|
|
11
|
-
export class PlSqlParserVisitor extends AbstractParseTreeVisitor {
|
|
12
|
-
}
|
package/dist/parser/plsql.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { CharStream, CommonTokenStream, Token } from 'antlr4ng';
|
|
2
|
-
import { CandidatesCollection } from 'antlr4-c3';
|
|
3
|
-
import { PlSqlLexer } from '../lib/plsql/PlSqlLexer';
|
|
4
|
-
import { PlSqlParser, ProgramContext } from '../lib/plsql/PlSqlParser';
|
|
5
|
-
import { BasicSQL } from './common/basicSQL';
|
|
6
|
-
import { Suggestions } from './common/types';
|
|
7
|
-
export declare class PLSQL extends BasicSQL<PlSqlLexer, ProgramContext, PlSqlParser> {
|
|
8
|
-
protected createLexerFromCharStream(charStreams: CharStream): PlSqlLexer;
|
|
9
|
-
protected createParserFromTokenStream(tokenStream: CommonTokenStream): PlSqlParser;
|
|
10
|
-
protected preferredRules: Set<number>;
|
|
11
|
-
protected get splitListener(): any;
|
|
12
|
-
protected createEntityCollector(input: string, caretTokenIndex?: number): any;
|
|
13
|
-
protected processCandidates(candidates: CandidatesCollection, allTokens: Token[], caretTokenIndex: number): Suggestions<Token>;
|
|
14
|
-
}
|
package/dist/parser/plsql.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { PlSqlLexer } from '../lib/plsql/PlSqlLexer';
|
|
2
|
-
import { PlSqlParser } from '../lib/plsql/PlSqlParser';
|
|
3
|
-
import { BasicSQL } from './common/basicSQL';
|
|
4
|
-
export class PLSQL extends BasicSQL {
|
|
5
|
-
constructor() {
|
|
6
|
-
super(...arguments);
|
|
7
|
-
this.preferredRules = new Set();
|
|
8
|
-
}
|
|
9
|
-
createLexerFromCharStream(charStreams) {
|
|
10
|
-
return new PlSqlLexer(charStreams);
|
|
11
|
-
}
|
|
12
|
-
createParserFromTokenStream(tokenStream) {
|
|
13
|
-
return new PlSqlParser(tokenStream);
|
|
14
|
-
}
|
|
15
|
-
get splitListener() {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
createEntityCollector(input, caretTokenIndex) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
processCandidates(candidates, allTokens, caretTokenIndex) {
|
|
22
|
-
return {
|
|
23
|
-
syntax: [],
|
|
24
|
-
keywords: [],
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
}
|
package/dist/utils/index.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Legacy_Token } from './token';
|
|
2
|
-
/**
|
|
3
|
-
* @param {String} sql
|
|
4
|
-
* @deprecated use parser.createLexer() instead.
|
|
5
|
-
*/
|
|
6
|
-
declare function legacy_lexer(input: string): Legacy_Token[];
|
|
7
|
-
/**
|
|
8
|
-
* split sql
|
|
9
|
-
* @param {String} sql
|
|
10
|
-
* @deprecated use parser.splitSQLByStatement() instead.
|
|
11
|
-
*/
|
|
12
|
-
declare function legacy_splitSql(sql: string): string[];
|
|
13
|
-
/**
|
|
14
|
-
* clean comment
|
|
15
|
-
* @param {String} sql
|
|
16
|
-
* @deprecated will be removed in future.
|
|
17
|
-
*/
|
|
18
|
-
declare function legacy_cleanSql(sql: string): string;
|
|
19
|
-
export { legacy_cleanSql, legacy_splitSql, legacy_lexer };
|
package/dist/utils/index.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { Legacy_TokenType, Legacy_TokenReg } from './token';
|
|
2
|
-
/**
|
|
3
|
-
* @param {String} sql
|
|
4
|
-
* @deprecated use parser.createLexer() instead.
|
|
5
|
-
*/
|
|
6
|
-
function legacy_lexer(input) {
|
|
7
|
-
let current = 0;
|
|
8
|
-
let line = 1;
|
|
9
|
-
const tokens = [];
|
|
10
|
-
const extract = (currentChar, validator, TokenType) => {
|
|
11
|
-
let value = '';
|
|
12
|
-
const start = current;
|
|
13
|
-
while (validator.test(currentChar)) {
|
|
14
|
-
value += currentChar;
|
|
15
|
-
currentChar = input[++current];
|
|
16
|
-
}
|
|
17
|
-
return {
|
|
18
|
-
type: TokenType,
|
|
19
|
-
start: start,
|
|
20
|
-
end: current,
|
|
21
|
-
lineNumber: line,
|
|
22
|
-
value: value,
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
const matchFunction = () => {
|
|
26
|
-
const bracketNum = [current];
|
|
27
|
-
for (let i = current + 1; i < input.length; i++) {
|
|
28
|
-
const currentChar = input[i];
|
|
29
|
-
if (currentChar === '\n') {
|
|
30
|
-
line++;
|
|
31
|
-
}
|
|
32
|
-
if (Legacy_TokenReg.LeftSmallBracket.test(currentChar)) {
|
|
33
|
-
bracketNum.push(i);
|
|
34
|
-
}
|
|
35
|
-
if (Legacy_TokenReg.RightSmallBracket.test(currentChar)) {
|
|
36
|
-
const start = bracketNum.pop();
|
|
37
|
-
const end = i + 1;
|
|
38
|
-
if (bracketNum.length === 0) {
|
|
39
|
-
current = end;
|
|
40
|
-
tokens.push({
|
|
41
|
-
type: Legacy_TokenType.FunctionArguments,
|
|
42
|
-
value: input.slice(start, end),
|
|
43
|
-
start,
|
|
44
|
-
lineNumber: line,
|
|
45
|
-
end,
|
|
46
|
-
});
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
const matchQuotation = (currentChar, validator, TokenType) => {
|
|
53
|
-
do {
|
|
54
|
-
if (currentChar === '\n') {
|
|
55
|
-
line++;
|
|
56
|
-
}
|
|
57
|
-
currentChar = input[++current];
|
|
58
|
-
} while (!validator.test(currentChar));
|
|
59
|
-
++current;
|
|
60
|
-
};
|
|
61
|
-
while (current < input.length) {
|
|
62
|
-
let char = input[current];
|
|
63
|
-
if (char === '\n') {
|
|
64
|
-
line++;
|
|
65
|
-
current++;
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
if (Legacy_TokenReg.LeftSmallBracket.test(char)) {
|
|
69
|
-
matchFunction();
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
if (Legacy_TokenReg.BackQuotation.test(char)) {
|
|
73
|
-
matchQuotation(char, Legacy_TokenReg.BackQuotation, Legacy_TokenType.BackQuotation);
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
if (Legacy_TokenReg.SingleQuotation.test(char)) {
|
|
77
|
-
matchQuotation(char, Legacy_TokenReg.SingleQuotation, Legacy_TokenType.SingleQuotation);
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
if (Legacy_TokenReg.DoubleQuotation.test(char)) {
|
|
81
|
-
matchQuotation(char, Legacy_TokenReg.DoubleQuotation, Legacy_TokenType.DoubleQuotation);
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
if (char === '-' && input[current + 1] === '-') {
|
|
85
|
-
let value = '';
|
|
86
|
-
const start = current;
|
|
87
|
-
while (char !== '\n' && current < input.length) {
|
|
88
|
-
value += char;
|
|
89
|
-
char = input[++current];
|
|
90
|
-
}
|
|
91
|
-
tokens.push({
|
|
92
|
-
type: Legacy_TokenType.Comment,
|
|
93
|
-
value,
|
|
94
|
-
start: start,
|
|
95
|
-
lineNumber: line,
|
|
96
|
-
end: current,
|
|
97
|
-
});
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
if (char === '/' && input[current + 1] === '*') {
|
|
101
|
-
let value = '';
|
|
102
|
-
const start = current;
|
|
103
|
-
const startLine = line;
|
|
104
|
-
while (!(char === '/' && input[current - 1] === '*')) {
|
|
105
|
-
if (char === '\n') {
|
|
106
|
-
line++;
|
|
107
|
-
}
|
|
108
|
-
value += char;
|
|
109
|
-
char = input[++current];
|
|
110
|
-
}
|
|
111
|
-
value += char;
|
|
112
|
-
++current;
|
|
113
|
-
tokens.push({
|
|
114
|
-
type: Legacy_TokenType.Comment,
|
|
115
|
-
value,
|
|
116
|
-
start: start,
|
|
117
|
-
lineNumber: startLine,
|
|
118
|
-
end: current,
|
|
119
|
-
});
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
if (Legacy_TokenReg.StatementTerminator.test(char)) {
|
|
123
|
-
const newToken = extract(char, Legacy_TokenReg.StatementTerminator, Legacy_TokenType.StatementTerminator);
|
|
124
|
-
tokens.push(newToken);
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
current++;
|
|
128
|
-
}
|
|
129
|
-
return tokens;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* split sql
|
|
133
|
-
* @param {String} sql
|
|
134
|
-
* @deprecated use parser.splitSQLByStatement() instead.
|
|
135
|
-
*/
|
|
136
|
-
function legacy_splitSql(sql) {
|
|
137
|
-
const tokens = legacy_lexer(sql);
|
|
138
|
-
const sqlArr = [];
|
|
139
|
-
let startIndex = 0;
|
|
140
|
-
tokens.forEach((ele) => {
|
|
141
|
-
if (ele.type === Legacy_TokenType.StatementTerminator) {
|
|
142
|
-
sqlArr.push(sql.slice(startIndex, ele.end));
|
|
143
|
-
startIndex = ele.end;
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
if (startIndex < sql.length) {
|
|
147
|
-
sqlArr.push(sql.slice(startIndex));
|
|
148
|
-
}
|
|
149
|
-
return sqlArr;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* clean comment
|
|
153
|
-
* @param {String} sql
|
|
154
|
-
* @deprecated will be removed in future.
|
|
155
|
-
*/
|
|
156
|
-
function legacy_cleanSql(sql) {
|
|
157
|
-
sql = sql.trim();
|
|
158
|
-
const tokens = legacy_lexer(sql);
|
|
159
|
-
let resultSql = '';
|
|
160
|
-
let startIndex = 0;
|
|
161
|
-
tokens.forEach((ele) => {
|
|
162
|
-
if (ele.type === Legacy_TokenType.Comment) {
|
|
163
|
-
resultSql += sql.slice(startIndex, ele.start);
|
|
164
|
-
startIndex = ele.end + 1;
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
resultSql += sql.slice(startIndex);
|
|
168
|
-
return resultSql;
|
|
169
|
-
}
|
|
170
|
-
export { legacy_cleanSql, legacy_splitSql, legacy_lexer };
|
package/dist/utils/token.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated will be removed in future.
|
|
3
|
-
*/
|
|
4
|
-
export declare enum Legacy_TokenType {
|
|
5
|
-
/**
|
|
6
|
-
* Enclosed in single/double/back quotation, `` Symbol
|
|
7
|
-
* 'abc', "abc", `abc`
|
|
8
|
-
*/
|
|
9
|
-
SingleQuotation = "SingleQuotation",
|
|
10
|
-
DoubleQuotation = "DoubleQuotation",
|
|
11
|
-
BackQuotation = "BackQuotation",
|
|
12
|
-
/**
|
|
13
|
-
* Language element type
|
|
14
|
-
*/
|
|
15
|
-
Comment = "Comment",
|
|
16
|
-
/**
|
|
17
|
-
* Statement
|
|
18
|
-
*/
|
|
19
|
-
StatementTerminator = "StatementTerminator",
|
|
20
|
-
/**
|
|
21
|
-
* Others
|
|
22
|
-
*/
|
|
23
|
-
Error = "Error",
|
|
24
|
-
/**
|
|
25
|
-
* Left small Bracket
|
|
26
|
-
*/
|
|
27
|
-
LeftSmallBracket = "LeftSmallBracket",
|
|
28
|
-
/**
|
|
29
|
-
* Left small Bracket
|
|
30
|
-
*/
|
|
31
|
-
RightSmallBracket = "RightSmallBracket",
|
|
32
|
-
Comma = "Comma",
|
|
33
|
-
FunctionArguments = "FunctionArguments"
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* @deprecated will be removed in future.
|
|
37
|
-
* Token object
|
|
38
|
-
*/
|
|
39
|
-
export interface Legacy_Token {
|
|
40
|
-
type: Legacy_TokenType;
|
|
41
|
-
value: string;
|
|
42
|
-
start?: number;
|
|
43
|
-
end: number;
|
|
44
|
-
lineNumber: number;
|
|
45
|
-
message?: string;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* @deprecated will be removed in future.
|
|
49
|
-
* Token recognition rules
|
|
50
|
-
*/
|
|
51
|
-
export declare const Legacy_TokenReg: {
|
|
52
|
-
StatementTerminator: RegExp;
|
|
53
|
-
SingleQuotation: RegExp;
|
|
54
|
-
DoubleQuotation: RegExp;
|
|
55
|
-
BackQuotation: RegExp;
|
|
56
|
-
LeftSmallBracket: RegExp;
|
|
57
|
-
RightSmallBracket: RegExp;
|
|
58
|
-
Comma: RegExp;
|
|
59
|
-
};
|
package/dist/utils/token.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated will be removed in future.
|
|
3
|
-
*/
|
|
4
|
-
export var Legacy_TokenType;
|
|
5
|
-
(function (Legacy_TokenType) {
|
|
6
|
-
/**
|
|
7
|
-
* Enclosed in single/double/back quotation, `` Symbol
|
|
8
|
-
* 'abc', "abc", `abc`
|
|
9
|
-
*/
|
|
10
|
-
Legacy_TokenType["SingleQuotation"] = "SingleQuotation";
|
|
11
|
-
Legacy_TokenType["DoubleQuotation"] = "DoubleQuotation";
|
|
12
|
-
Legacy_TokenType["BackQuotation"] = "BackQuotation";
|
|
13
|
-
/**
|
|
14
|
-
* Language element type
|
|
15
|
-
*/
|
|
16
|
-
Legacy_TokenType["Comment"] = "Comment";
|
|
17
|
-
/**
|
|
18
|
-
* Statement
|
|
19
|
-
*/
|
|
20
|
-
Legacy_TokenType["StatementTerminator"] = "StatementTerminator";
|
|
21
|
-
/**
|
|
22
|
-
* Others
|
|
23
|
-
*/
|
|
24
|
-
Legacy_TokenType["Error"] = "Error";
|
|
25
|
-
/**
|
|
26
|
-
* Left small Bracket
|
|
27
|
-
*/
|
|
28
|
-
Legacy_TokenType["LeftSmallBracket"] = "LeftSmallBracket";
|
|
29
|
-
/**
|
|
30
|
-
* Left small Bracket
|
|
31
|
-
*/
|
|
32
|
-
Legacy_TokenType["RightSmallBracket"] = "RightSmallBracket";
|
|
33
|
-
Legacy_TokenType["Comma"] = "Comma";
|
|
34
|
-
Legacy_TokenType["FunctionArguments"] = "FunctionArguments";
|
|
35
|
-
})(Legacy_TokenType || (Legacy_TokenType = {}));
|
|
36
|
-
/**
|
|
37
|
-
* @deprecated will be removed in future.
|
|
38
|
-
* Token recognition rules
|
|
39
|
-
*/
|
|
40
|
-
export const Legacy_TokenReg = {
|
|
41
|
-
[Legacy_TokenType.StatementTerminator]: /[;]/,
|
|
42
|
-
[Legacy_TokenType.SingleQuotation]: /['|\']/,
|
|
43
|
-
[Legacy_TokenType.DoubleQuotation]: /["]/,
|
|
44
|
-
[Legacy_TokenType.BackQuotation]: /[`]/,
|
|
45
|
-
[Legacy_TokenType.LeftSmallBracket]: /[(]/,
|
|
46
|
-
[Legacy_TokenType.RightSmallBracket]: /[)]/,
|
|
47
|
-
[Legacy_TokenType.Comma]: /[,]/,
|
|
48
|
-
};
|