@flexiberry/berrycore 0.1.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/dist/adapter/cli-adapter.d.ts +37 -0
- package/dist/adapter/cli-adapter.js +119 -0
- package/dist/berry-core.d.ts +108 -0
- package/dist/berry-core.js +258 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +18 -0
- package/dist/interpreter/environment.d.ts +45 -0
- package/dist/interpreter/environment.js +96 -0
- package/dist/interpreter/errors.d.ts +16 -0
- package/dist/interpreter/errors.js +27 -0
- package/dist/interpreter/interpreter.d.ts +111 -0
- package/dist/interpreter/interpreter.js +682 -0
- package/dist/interpreter/interpreter.types.d.ts +182 -0
- package/dist/interpreter/interpreter.types.js +73 -0
- package/dist/parser/ast/ast.engine.d.ts +103 -0
- package/dist/parser/ast/ast.engine.js +526 -0
- package/dist/parser/ast/ast.types.d.ts +242 -0
- package/dist/parser/ast/ast.types.js +37 -0
- package/dist/parser/formatter/formatter.d.ts +44 -0
- package/dist/parser/formatter/formatter.js +214 -0
- package/dist/parser/tokenizer/reader/grammer/api.grammer.d.ts +2 -0
- package/dist/parser/tokenizer/reader/grammer/api.grammer.js +102 -0
- package/dist/parser/tokenizer/reader/grammer/capture.grammer.d.ts +2 -0
- package/dist/parser/tokenizer/reader/grammer/capture.grammer.js +21 -0
- package/dist/parser/tokenizer/reader/grammer/check.grammer.d.ts +2 -0
- package/dist/parser/tokenizer/reader/grammer/check.grammer.js +21 -0
- package/dist/parser/tokenizer/reader/grammer/comment.grammer.d.ts +2 -0
- package/dist/parser/tokenizer/reader/grammer/comment.grammer.js +13 -0
- package/dist/parser/tokenizer/reader/grammer/conditions.grammer.d.ts +2 -0
- package/dist/parser/tokenizer/reader/grammer/conditions.grammer.js +68 -0
- package/dist/parser/tokenizer/reader/grammer/input.grammer.d.ts +2 -0
- package/dist/parser/tokenizer/reader/grammer/input.grammer.js +17 -0
- package/dist/parser/tokenizer/reader/grammer/keyvalue.grammer.d.ts +2 -0
- package/dist/parser/tokenizer/reader/grammer/keyvalue.grammer.js +240 -0
- package/dist/parser/tokenizer/reader/grammer/link.grammer.d.ts +2 -0
- package/dist/parser/tokenizer/reader/grammer/link.grammer.js +17 -0
- package/dist/parser/tokenizer/reader/grammer/params.grammer.d.ts +2 -0
- package/dist/parser/tokenizer/reader/grammer/params.grammer.js +21 -0
- package/dist/parser/tokenizer/reader/grammer/step.grammer.d.ts +2 -0
- package/dist/parser/tokenizer/reader/grammer/step.grammer.js +25 -0
- package/dist/parser/tokenizer/reader/grammer/task.grammer.d.ts +2 -0
- package/dist/parser/tokenizer/reader/grammer/task.grammer.js +17 -0
- package/dist/parser/tokenizer/reader/grammer/var.grammer.d.ts +2 -0
- package/dist/parser/tokenizer/reader/grammer/var.grammer.js +47 -0
- package/dist/parser/tokenizer/reader/lexer.engine.d.ts +43 -0
- package/dist/parser/tokenizer/reader/lexer.engine.js +178 -0
- package/dist/parser/tokenizer/reader/lexer.types.d.ts +18 -0
- package/dist/parser/tokenizer/reader/lexer.types.js +1 -0
- package/dist/parser/tokenizer/token.d.ts +13 -0
- package/dist/parser/tokenizer/token.js +13 -0
- package/dist/parser/tokenizer/tokenType.d.ts +58 -0
- package/dist/parser/tokenizer/tokenType.js +64 -0
- package/dist/script/format-util.d.ts +33 -0
- package/dist/script/format-util.js +94 -0
- package/dist/script/postman.util.d.ts +88 -0
- package/dist/script/postman.util.js +176 -0
- package/dist/script/swagger.util.d.ts +80 -0
- package/dist/script/swagger.util.js +202 -0
- package/dist/util/store-util.d.ts +5 -0
- package/dist/util/store-util.js +22 -0
- package/package.json +25 -0
- package/readme.md +107 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { TokenType } from "../../tokenType.js";
|
|
2
|
+
export const conditionGrammer = {
|
|
3
|
+
name: "conditions",
|
|
4
|
+
regex: /^\s*(-)\s*(\d+|true|false|".*?"|'.*?'|`[\s\S]*?`|['"a-zA-Z$\.\-]*)\s*/, // Matches the leading dash and optional spaces
|
|
5
|
+
groups: [
|
|
6
|
+
{
|
|
7
|
+
tokenType: TokenType.Hyphen,
|
|
8
|
+
index: 1,
|
|
9
|
+
},
|
|
10
|
+
],
|
|
11
|
+
next: [
|
|
12
|
+
{
|
|
13
|
+
name: "conditions",
|
|
14
|
+
regex: /^\s*(\d+|true|false|".*?"|'.*?'|`[\s\S]*?`|['"a-zA-Z$\.\-]*)\s*(==|!=|>=|<=|>|<)\s*(\d+|true|false|".*?"|'.*?'|`[\s\S]*?`|['"a-zA-Z$\.\-]*)\s*/,
|
|
15
|
+
groups: [
|
|
16
|
+
{
|
|
17
|
+
tokenType: TokenType.Lhs,
|
|
18
|
+
index: 1,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
tokenType: TokenType.Operator,
|
|
22
|
+
index: 2,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
tokenType: TokenType.Rhs,
|
|
26
|
+
index: 3,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
next: [
|
|
30
|
+
{
|
|
31
|
+
name: "OR",
|
|
32
|
+
regex: /\s*(OR)\s*/,
|
|
33
|
+
groups: [],
|
|
34
|
+
next: [
|
|
35
|
+
{
|
|
36
|
+
name: "conditionsOr",
|
|
37
|
+
regex: /^\s*(OR)\s*(\d+|true|false|".*?"|'.*?'|`[\s\S]*?`|['"a-zA-Z$\.\-]*)\s*(==|!=|>=|<=|>|<)\s*(\d+|true|false|".*?"|'.*?'|`[\s\S]*?`|['"a-zA-Z$\.\-]*)\s*/,
|
|
38
|
+
groups: [
|
|
39
|
+
{
|
|
40
|
+
tokenType: TokenType.Or,
|
|
41
|
+
index: 1,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
tokenType: TokenType.Lhs,
|
|
45
|
+
index: 2,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
tokenType: TokenType.Operator,
|
|
49
|
+
index: 3,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
tokenType: TokenType.Rhs,
|
|
53
|
+
index: 4,
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
moveNextLine: false,
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
loopUntil: /\s*(OR)\s*/,
|
|
60
|
+
isMultiline: false,
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
// moveNextLine: true,
|
|
66
|
+
loopUntil: /^\s*(-)\s*(\d+|true|false|".*?"|'.*?'|`[\s\S]*?`|['"a-zA-Z$\.\-]*)\s*/,
|
|
67
|
+
isMultiline: false,
|
|
68
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TokenType } from "../../tokenType.js";
|
|
2
|
+
export const inputGrammer = {
|
|
3
|
+
name: "input",
|
|
4
|
+
regex: /^\s*(Input)\s+(.+?)\s*$/,
|
|
5
|
+
groups: [
|
|
6
|
+
{
|
|
7
|
+
tokenType: TokenType.Input,
|
|
8
|
+
index: 1,
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
tokenType: TokenType.InputPath,
|
|
12
|
+
index: 2,
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
isOptional: true,
|
|
16
|
+
isMultiline: false,
|
|
17
|
+
};
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { TokenType } from "../../tokenType.js";
|
|
2
|
+
export const keyValueGrammer = {
|
|
3
|
+
name: "keyValue",
|
|
4
|
+
regex: /^\s*(-)\s*['"a-zA-Z\-]*\s*:/, // Matches the leading dash and optional spaces
|
|
5
|
+
groups: [
|
|
6
|
+
{
|
|
7
|
+
tokenType: TokenType.Hyphen,
|
|
8
|
+
index: 1,
|
|
9
|
+
},
|
|
10
|
+
],
|
|
11
|
+
next: [
|
|
12
|
+
{
|
|
13
|
+
name: "quotedKey",
|
|
14
|
+
regex: /^-\s*(['"`])(.*?)(\1)\s*(:)/, // Matches 'key' or "key" followed by colon
|
|
15
|
+
groups: [
|
|
16
|
+
{
|
|
17
|
+
tokenType: TokenType.Quote,
|
|
18
|
+
index: 1,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
tokenType: TokenType.Identifier,
|
|
22
|
+
index: 2,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
tokenType: TokenType.Quote,
|
|
26
|
+
index: 3,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
tokenType: TokenType.Colon,
|
|
30
|
+
index: 4,
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
next: [
|
|
34
|
+
{
|
|
35
|
+
name: "value",
|
|
36
|
+
regex: /(['"])(.*?)(\1)/,
|
|
37
|
+
groups: [
|
|
38
|
+
{
|
|
39
|
+
tokenType: TokenType.Quote,
|
|
40
|
+
index: 1,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
tokenType: TokenType.Scalar,
|
|
44
|
+
index: 2,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
tokenType: TokenType.Quote,
|
|
48
|
+
index: 3,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
isOptional: true,
|
|
52
|
+
next: [
|
|
53
|
+
{
|
|
54
|
+
name: "decrypt",
|
|
55
|
+
regex: /^\s+(Decrypt)\s*$/,
|
|
56
|
+
groups: [
|
|
57
|
+
{
|
|
58
|
+
tokenType: TokenType.Decrypt,
|
|
59
|
+
index: 1,
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
isOptional: true,
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "multilineValue",
|
|
68
|
+
regex: /(`)([\s\S]*?)(`)/,
|
|
69
|
+
isOptional: true,
|
|
70
|
+
groups: [
|
|
71
|
+
{
|
|
72
|
+
tokenType: TokenType.Backtick,
|
|
73
|
+
index: 1,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
tokenType: TokenType.Scalar,
|
|
77
|
+
index: 2,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
tokenType: TokenType.Backtick,
|
|
81
|
+
index: 3,
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
start: /(`)([\s\S]*?)/,
|
|
85
|
+
end: /(`)([\s\S]*?)(`)/,
|
|
86
|
+
mergeLines: true,
|
|
87
|
+
next: [
|
|
88
|
+
{
|
|
89
|
+
name: "decrypt",
|
|
90
|
+
regex: /^\s+(Decrypt)\s*$/,
|
|
91
|
+
groups: [
|
|
92
|
+
{
|
|
93
|
+
tokenType: TokenType.Decrypt,
|
|
94
|
+
index: 1,
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
isOptional: true,
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "unquotedValue",
|
|
103
|
+
regex: /(?<!['"])([a-zA-Z_.\-][a-zA-Z0-9_.\-]*)(?!['"])/,
|
|
104
|
+
groups: [
|
|
105
|
+
{
|
|
106
|
+
tokenType: TokenType.Identifier,
|
|
107
|
+
index: 1,
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
isOptional: true,
|
|
111
|
+
next: [
|
|
112
|
+
{
|
|
113
|
+
name: "decrypt",
|
|
114
|
+
regex: /^\s+(Decrypt)\s*$/,
|
|
115
|
+
groups: [
|
|
116
|
+
{
|
|
117
|
+
tokenType: TokenType.Decrypt,
|
|
118
|
+
index: 1,
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
isOptional: true,
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: "unquotedKey",
|
|
129
|
+
regex: /\s*([a-zA-Z_.\-][a-zA-Z0-9_.\-]*)\s*(:)/, // Matches name:
|
|
130
|
+
groups: [
|
|
131
|
+
{
|
|
132
|
+
tokenType: TokenType.Identifier,
|
|
133
|
+
index: 1,
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
tokenType: TokenType.Colon,
|
|
137
|
+
index: 2,
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
next: [
|
|
141
|
+
{
|
|
142
|
+
name: "value",
|
|
143
|
+
regex: /(['"])(.*?)(\1)/,
|
|
144
|
+
groups: [
|
|
145
|
+
{
|
|
146
|
+
tokenType: TokenType.Quote,
|
|
147
|
+
index: 1,
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
tokenType: TokenType.Scalar,
|
|
151
|
+
index: 2,
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
tokenType: TokenType.Quote,
|
|
155
|
+
index: 3,
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
isOptional: true,
|
|
159
|
+
next: [
|
|
160
|
+
{
|
|
161
|
+
name: "decrypt",
|
|
162
|
+
regex: /^\s+(Decrypt)\s*$/,
|
|
163
|
+
groups: [
|
|
164
|
+
{
|
|
165
|
+
tokenType: TokenType.Decrypt,
|
|
166
|
+
index: 1,
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
isOptional: true,
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
name: "multilineValue",
|
|
175
|
+
regex: /(`)([\s\S]*?)(`)/,
|
|
176
|
+
isOptional: true,
|
|
177
|
+
groups: [
|
|
178
|
+
{
|
|
179
|
+
tokenType: TokenType.Backtick,
|
|
180
|
+
index: 1,
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
tokenType: TokenType.Scalar,
|
|
184
|
+
index: 2,
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
tokenType: TokenType.Backtick,
|
|
188
|
+
index: 3,
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
start: /(`)([\s\S]*?)/,
|
|
192
|
+
end: /(`)([\s\S]*?)(`)/,
|
|
193
|
+
mergeLines: true,
|
|
194
|
+
next: [
|
|
195
|
+
{
|
|
196
|
+
name: "decrypt",
|
|
197
|
+
regex: /^\s+(Decrypt)\s*$/,
|
|
198
|
+
groups: [
|
|
199
|
+
{
|
|
200
|
+
tokenType: TokenType.Decrypt,
|
|
201
|
+
index: 1,
|
|
202
|
+
},
|
|
203
|
+
],
|
|
204
|
+
isOptional: true,
|
|
205
|
+
},
|
|
206
|
+
],
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
name: "unquotedValue",
|
|
210
|
+
regex: /\s*([a-zA-Z_\.\-][a-zA-Z0-9_\.\-]*)/,
|
|
211
|
+
groups: [
|
|
212
|
+
{
|
|
213
|
+
tokenType: TokenType.Identifier,
|
|
214
|
+
index: 1,
|
|
215
|
+
},
|
|
216
|
+
],
|
|
217
|
+
isOptional: true,
|
|
218
|
+
next: [
|
|
219
|
+
{
|
|
220
|
+
name: "decrypt",
|
|
221
|
+
regex: /^\s+(Decrypt)\s*$/,
|
|
222
|
+
groups: [
|
|
223
|
+
{
|
|
224
|
+
tokenType: TokenType.Decrypt,
|
|
225
|
+
index: 1,
|
|
226
|
+
},
|
|
227
|
+
],
|
|
228
|
+
isOptional: true,
|
|
229
|
+
},
|
|
230
|
+
],
|
|
231
|
+
},
|
|
232
|
+
],
|
|
233
|
+
isMultiline: false,
|
|
234
|
+
isOptional: true,
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
loopUntil: /^\s*(-)\s*['"a-zA-Z\-]*\s*:/,
|
|
238
|
+
isMultiline: false,
|
|
239
|
+
moveNextLine: true,
|
|
240
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TokenType } from "../../tokenType.js";
|
|
2
|
+
export const linkGrammer = {
|
|
3
|
+
name: "link",
|
|
4
|
+
regex: /^\s*(Link)\s+(.+?)\s*$/,
|
|
5
|
+
groups: [
|
|
6
|
+
{
|
|
7
|
+
tokenType: TokenType.Link,
|
|
8
|
+
index: 1,
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
tokenType: TokenType.LinkPath,
|
|
12
|
+
index: 2,
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
isOptional: true,
|
|
16
|
+
isMultiline: false,
|
|
17
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TokenType } from "../../tokenType.js";
|
|
2
|
+
import { keyValueGrammer } from "./keyvalue.grammer.js";
|
|
3
|
+
export const paramsGrammer = {
|
|
4
|
+
name: "Params",
|
|
5
|
+
regex: /^\s*(Params)/,
|
|
6
|
+
groups: [
|
|
7
|
+
{
|
|
8
|
+
tokenType: TokenType.Params,
|
|
9
|
+
index: 1,
|
|
10
|
+
},
|
|
11
|
+
],
|
|
12
|
+
next: [
|
|
13
|
+
{
|
|
14
|
+
...keyValueGrammer,
|
|
15
|
+
moveNextLine: true,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
isOptional: true,
|
|
19
|
+
isMultiline: false,
|
|
20
|
+
moveNextLine: true,
|
|
21
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { TokenType } from "../../tokenType.js";
|
|
2
|
+
export const stepGrammer = {
|
|
3
|
+
name: "step",
|
|
4
|
+
regex: /^\s*(Step)\s*(?:(Call))\s*(?:(Api))\s*(\w*|\W*)/,
|
|
5
|
+
groups: [
|
|
6
|
+
{
|
|
7
|
+
tokenType: TokenType.Step,
|
|
8
|
+
index: 1,
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
tokenType: TokenType.Call,
|
|
12
|
+
index: 2,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
tokenType: TokenType.Api,
|
|
16
|
+
index: 3,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
tokenType: TokenType.Identifier,
|
|
20
|
+
index: 4,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
isOptional: true,
|
|
24
|
+
isMultiline: false,
|
|
25
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TokenType } from "../../tokenType.js";
|
|
2
|
+
export const taskGrammer = {
|
|
3
|
+
name: "task",
|
|
4
|
+
regex: /^\s*(Task)\s*(?:(.*))?$/,
|
|
5
|
+
groups: [
|
|
6
|
+
{
|
|
7
|
+
tokenType: TokenType.Task,
|
|
8
|
+
index: 1,
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
tokenType: TokenType.Title,
|
|
12
|
+
index: 2,
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
isOptional: true,
|
|
16
|
+
isMultiline: false,
|
|
17
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { TokenType } from "../../tokenType.js";
|
|
2
|
+
import { keyValueGrammer } from "./keyvalue.grammer.js";
|
|
3
|
+
export const varLexerGrammer = [
|
|
4
|
+
{
|
|
5
|
+
name: "var",
|
|
6
|
+
regex: /^Var/,
|
|
7
|
+
groups: [
|
|
8
|
+
{
|
|
9
|
+
tokenType: TokenType.Var,
|
|
10
|
+
},
|
|
11
|
+
],
|
|
12
|
+
next: [
|
|
13
|
+
{
|
|
14
|
+
name: "pointer",
|
|
15
|
+
regex: /(@)(\S+)\s+(.*)/,
|
|
16
|
+
isOptional: true,
|
|
17
|
+
groups: [
|
|
18
|
+
{
|
|
19
|
+
tokenType: TokenType.Pointer,
|
|
20
|
+
index: 1,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
tokenType: TokenType.Pointed,
|
|
24
|
+
index: 2,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
tokenType: TokenType.Title,
|
|
28
|
+
index: 3,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "title",
|
|
34
|
+
regex: /\s+(.*)/,
|
|
35
|
+
groups: [
|
|
36
|
+
{
|
|
37
|
+
tokenType: TokenType.Title,
|
|
38
|
+
index: 0,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
isOptional: true,
|
|
42
|
+
},
|
|
43
|
+
{ ...keyValueGrammer, ...{ moveNextLine: true } },
|
|
44
|
+
],
|
|
45
|
+
isMultiline: false,
|
|
46
|
+
},
|
|
47
|
+
];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Token } from "../token.js";
|
|
2
|
+
export declare class LexerError extends Error {
|
|
3
|
+
readonly line: number;
|
|
4
|
+
readonly column: number;
|
|
5
|
+
constructor(message: string, line: number, column: number);
|
|
6
|
+
}
|
|
7
|
+
export declare class LexerEngine {
|
|
8
|
+
private input;
|
|
9
|
+
private tokens;
|
|
10
|
+
private lines;
|
|
11
|
+
private lineIndex;
|
|
12
|
+
private columnIndex;
|
|
13
|
+
private currentLine;
|
|
14
|
+
private at;
|
|
15
|
+
private next;
|
|
16
|
+
private prev;
|
|
17
|
+
constructor(input: string);
|
|
18
|
+
/**
|
|
19
|
+
* Processes a grammar rule against the given line and updates tokens.
|
|
20
|
+
* Optimized for readability and performance.
|
|
21
|
+
*/
|
|
22
|
+
private processGrammer;
|
|
23
|
+
/**
|
|
24
|
+
* Merges lines until the grammar's end pattern is matched or lines run out.
|
|
25
|
+
*/
|
|
26
|
+
private mergeLinesUntilEnd;
|
|
27
|
+
/**
|
|
28
|
+
* Processes the groups in the grammar and generates tokens.
|
|
29
|
+
*/
|
|
30
|
+
private processGroups;
|
|
31
|
+
/**
|
|
32
|
+
* Processes any next grammar rules chained to the current grammar.
|
|
33
|
+
*/
|
|
34
|
+
private processNextGrammars;
|
|
35
|
+
/**
|
|
36
|
+
* Handles looping a grammar until a condition is met.
|
|
37
|
+
*/
|
|
38
|
+
private processLoopUntil;
|
|
39
|
+
/**
|
|
40
|
+
* Tokenizes the input string into tokens using the defined grammar list.
|
|
41
|
+
*/
|
|
42
|
+
tokenize(): Token[];
|
|
43
|
+
}
|