@plurnk/plurnk-mimetypes-text-postgresql 0.3.0
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/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/TextPostgresql.d.ts +7 -0
- package/dist/TextPostgresql.d.ts.map +1 -0
- package/dist/TextPostgresql.js +198 -0
- package/dist/TextPostgresql.js.map +1 -0
- package/dist/generated/PostgreSQLLexer.d.ts +640 -0
- package/dist/generated/PostgreSQLLexer.d.ts.map +1 -0
- package/dist/generated/PostgreSQLLexer.js +3359 -0
- package/dist/generated/PostgreSQLLexer.js.map +1 -0
- package/dist/generated/PostgreSQLLexerBase.d.ts +33 -0
- package/dist/generated/PostgreSQLLexerBase.d.ts.map +1 -0
- package/dist/generated/PostgreSQLLexerBase.js +92 -0
- package/dist/generated/PostgreSQLLexerBase.js.map +1 -0
- package/dist/generated/PostgreSQLParser.d.ts +10568 -0
- package/dist/generated/PostgreSQLParser.d.ts.map +1 -0
- package/dist/generated/PostgreSQLParser.js +93755 -0
- package/dist/generated/PostgreSQLParser.js.map +1 -0
- package/dist/generated/PostgreSQLParserBase.d.ts +9 -0
- package/dist/generated/PostgreSQLParserBase.d.ts.map +1 -0
- package/dist/generated/PostgreSQLParserBase.js +106 -0
- package/dist/generated/PostgreSQLParserBase.js.map +1 -0
- package/dist/generated/PostgreSQLParserVisitor.d.ts +5086 -0
- package/dist/generated/PostgreSQLParserVisitor.d.ts.map +1 -0
- package/dist/generated/PostgreSQLParserVisitor.js +4362 -0
- package/dist/generated/PostgreSQLParserVisitor.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/grammar/PostgreSQLLexer.g4 +1476 -0
- package/grammar/PostgreSQLParser.g4 +5469 -0
- package/package.json +64 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Lexer, CharStream } from "antlr4ng";
|
|
2
|
+
interface IStack<T> {
|
|
3
|
+
push(item: T): void;
|
|
4
|
+
pop(): T | undefined;
|
|
5
|
+
peek(): T | undefined;
|
|
6
|
+
size(): number;
|
|
7
|
+
}
|
|
8
|
+
declare class Stack<T> implements IStack<T> {
|
|
9
|
+
private storage;
|
|
10
|
+
private capacity;
|
|
11
|
+
constructor(capacity?: number);
|
|
12
|
+
push(item: T): void;
|
|
13
|
+
pop(): T | undefined;
|
|
14
|
+
peek(): T | undefined;
|
|
15
|
+
size(): number;
|
|
16
|
+
}
|
|
17
|
+
export default abstract class PostgreSQLLexerBase extends Lexer {
|
|
18
|
+
protected tags: Stack<string>;
|
|
19
|
+
constructor(input: CharStream);
|
|
20
|
+
PushTag(): void;
|
|
21
|
+
IsTag(): boolean;
|
|
22
|
+
PopTag(): void;
|
|
23
|
+
UnterminatedBlockCommentDebugAssert(): void;
|
|
24
|
+
CheckLaMinus(): boolean;
|
|
25
|
+
CheckLaStar(): boolean;
|
|
26
|
+
CharIsLetter(): boolean;
|
|
27
|
+
HandleNumericFail(): void;
|
|
28
|
+
HandleLessLessGreaterGreater(): void;
|
|
29
|
+
CheckIfUtf32Letter(): boolean;
|
|
30
|
+
IsSemiColon(): boolean;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=PostgreSQLLexerBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgreSQLLexerBase.d.ts","sourceRoot":"","sources":["../../src/generated/PostgreSQLLexerBase.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAe,KAAK,EAAE,UAAU,EAA4B,MAAM,UAAU,CAAC;AAIpF,UAAU,MAAM,CAAC,CAAC;IAChB,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IACpB,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC;IACrB,IAAI,IAAI,CAAC,GAAG,SAAS,CAAC;IACtB,IAAI,IAAI,MAAM,CAAC;CAChB;AAED,cAAM,KAAK,CAAC,CAAC,CAAE,YAAW,MAAM,CAAC,CAAC,CAAC;IACjC,OAAO,CAAC,OAAO,CAAW;IAC1B,OAAO,CAAC,QAAQ,CAAS;gBAEb,QAAQ,GAAE,MAAiB;IAIvC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI;IAOnB,GAAG,IAAI,CAAC,GAAG,SAAS;IAIpB,IAAI,IAAI,CAAC,GAAG,SAAS;IAIrB,IAAI,IAAI,MAAM;CAGf;AAGD,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,mBAAoB,SAAQ,KAAK;IAC3D,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAe;gBAEhC,KAAK,EAAE,UAAU;IAItB,OAAO,IAAI,IAAI;IAIf,KAAK,IAAI,OAAO;IAIhB,MAAM,IAAI,IAAI;IAId,mCAAmC,IAAI,IAAI;IAI3C,YAAY,IAAI,OAAO;IAIvB,WAAW,IAAI,OAAO;IAItB,YAAY,IAAI,OAAO;IAIvB,iBAAiB,IAAI,IAAI;IAMzB,4BAA4B,IAAI,IAAI;IAKpC,kBAAkB,IAAI,OAAO;IAO7B,WAAW,IAAI,OAAO;CAGhC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/*
|
|
2
|
+
PostgreSQL grammar.
|
|
3
|
+
The MIT License (MIT).
|
|
4
|
+
Copyright (c) 2021-2023, Oleksii Kovalov (Oleksii.Kovalov@outlook.com).
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
The above copyright notice and this permission notice shall be included in
|
|
12
|
+
all copies or substantial portions of the Software.
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
|
20
|
+
*/
|
|
21
|
+
import { Lexer } from "antlr4ng";
|
|
22
|
+
import { PostgreSQLLexer } from "./PostgreSQLLexer.js";
|
|
23
|
+
class Stack {
|
|
24
|
+
storage = [];
|
|
25
|
+
capacity;
|
|
26
|
+
constructor(capacity = Infinity) {
|
|
27
|
+
this.capacity = capacity;
|
|
28
|
+
}
|
|
29
|
+
push(item) {
|
|
30
|
+
if (this.size() === this.capacity) {
|
|
31
|
+
throw Error("Stack has reached max capacity, you cannot add more items");
|
|
32
|
+
}
|
|
33
|
+
this.storage.push(item);
|
|
34
|
+
}
|
|
35
|
+
pop() {
|
|
36
|
+
return this.storage.pop();
|
|
37
|
+
}
|
|
38
|
+
peek() {
|
|
39
|
+
return this.storage[this.size() - 1];
|
|
40
|
+
}
|
|
41
|
+
size() {
|
|
42
|
+
return this.storage.length;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export default class PostgreSQLLexerBase extends Lexer {
|
|
46
|
+
tags = new Stack();
|
|
47
|
+
constructor(input) {
|
|
48
|
+
super(input);
|
|
49
|
+
}
|
|
50
|
+
PushTag() {
|
|
51
|
+
this.tags.push(this.text);
|
|
52
|
+
}
|
|
53
|
+
IsTag() {
|
|
54
|
+
return this.text === this.tags.peek();
|
|
55
|
+
}
|
|
56
|
+
PopTag() {
|
|
57
|
+
this.tags.pop();
|
|
58
|
+
}
|
|
59
|
+
UnterminatedBlockCommentDebugAssert() {
|
|
60
|
+
console.assert(this.inputStream.LA(1) === -1 /*EOF*/);
|
|
61
|
+
}
|
|
62
|
+
CheckLaMinus() {
|
|
63
|
+
return this.inputStream.LA(1) !== '-'.charCodeAt(0);
|
|
64
|
+
}
|
|
65
|
+
CheckLaStar() {
|
|
66
|
+
return this.inputStream.LA(1) !== '*'.charCodeAt(0);
|
|
67
|
+
}
|
|
68
|
+
CharIsLetter() {
|
|
69
|
+
return /^[a-zA-Z]$/.test(String.fromCharCode(this.inputStream.LA(-1)));
|
|
70
|
+
}
|
|
71
|
+
HandleNumericFail() {
|
|
72
|
+
this.inputStream.seek(this.inputStream.index - 2);
|
|
73
|
+
// Assuming PostgreSQLLexer.Integral to be an enum or token type
|
|
74
|
+
this.type = PostgreSQLLexer.Integral; // Adjust as per actual token type definition
|
|
75
|
+
}
|
|
76
|
+
HandleLessLessGreaterGreater() {
|
|
77
|
+
if (this.text.toString() === "<<")
|
|
78
|
+
this.type = PostgreSQLLexer.LESS_LESS;
|
|
79
|
+
if (this.text.toString() === ">>")
|
|
80
|
+
this.type = PostgreSQLLexer.GREATER_GREATER;
|
|
81
|
+
}
|
|
82
|
+
CheckIfUtf32Letter() {
|
|
83
|
+
const highSurrogate = String.fromCharCode(this.inputStream.LA(-2));
|
|
84
|
+
const lowSurrogate = String.fromCharCode(this.inputStream.LA(-1));
|
|
85
|
+
const combined = highSurrogate + lowSurrogate;
|
|
86
|
+
return /^[a-zA-Z]$/.test(combined);
|
|
87
|
+
}
|
|
88
|
+
IsSemiColon() {
|
|
89
|
+
return ';' === String.fromCharCode(this.inputStream.LA(1));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=PostgreSQLLexerBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgreSQLLexerBase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