grammar-composer 0.2.3 → 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/README.md +2 -2
- package/dist/exports/Exports.d.ts +2 -0
- package/dist/exports/Exports.d.ts.map +1 -0
- package/dist/exports/Exports.js +2 -0
- package/dist/exports/Exports.js.map +1 -0
- package/dist/{GrammarComposer.d.ts → parser-generator/Grammar.d.ts} +2 -1
- package/dist/parser-generator/Grammar.d.ts.map +1 -0
- package/dist/{GrammarComposer.js → parser-generator/Grammar.js} +84 -27
- package/dist/parser-generator/Grammar.js.map +1 -0
- package/dist/{TopDownParser.d.ts → parser-generator/TopDownParser.d.ts} +3 -2
- package/dist/parser-generator/TopDownParser.d.ts.map +1 -0
- package/dist/{TopDownParser.js → parser-generator/TopDownParser.js} +13 -8
- package/dist/parser-generator/TopDownParser.js.map +1 -0
- package/dist/tests/Test.d.ts +2 -0
- package/dist/tests/Test.d.ts.map +1 -0
- package/dist/{Test.js → tests/Test.js} +6 -6
- package/dist/tests/Test.js.map +1 -0
- package/dist/{test-data → tests/test-data}/TestData.d.ts +1 -0
- package/dist/tests/test-data/TestData.d.ts.map +1 -0
- package/dist/tests/test-data/TestData.js.map +1 -0
- package/dist/{test-grammars → tests/test-grammars}/JsonGrammar.d.ts +2 -1
- package/dist/tests/test-grammars/JsonGrammar.d.ts.map +1 -0
- package/dist/{test-grammars → tests/test-grammars}/JsonGrammar.js +1 -1
- package/dist/tests/test-grammars/JsonGrammar.js.map +1 -0
- package/dist/{test-grammars → tests/test-grammars}/RegExpGrammar.d.ts +2 -1
- package/dist/tests/test-grammars/RegExpGrammar.d.ts.map +1 -0
- package/dist/{test-grammars → tests/test-grammars}/RegExpGrammar.js +1 -1
- package/dist/tests/test-grammars/RegExpGrammar.js.map +1 -0
- package/dist/{test-grammars → tests/test-grammars}/XmlGrammar.d.ts +2 -1
- package/dist/tests/test-grammars/XmlGrammar.d.ts.map +1 -0
- package/dist/{test-grammars → tests/test-grammars}/XmlGrammar.js +1 -1
- package/dist/tests/test-grammars/XmlGrammar.js.map +1 -0
- package/dist/utilities/Timer.d.ts +1 -0
- package/dist/utilities/Timer.d.ts.map +1 -0
- package/dist/utilities/Timer.js +1 -1
- package/dist/utilities/{utilities.d.ts → Utilities.d.ts} +1 -0
- package/dist/utilities/Utilities.d.ts.map +1 -0
- package/package.json +5 -5
- package/src/exports/Exports.ts +1 -0
- package/src/{GrammarComposer.ts → parser-generator/Grammar.ts} +94 -30
- package/src/{TopDownParser.ts → parser-generator/TopDownParser.ts} +15 -12
- package/src/{Test.ts → tests/Test.ts} +6 -6
- package/src/{test-grammars → tests/test-grammars}/JsonGrammar.ts +1 -1
- package/src/{test-grammars → tests/test-grammars}/RegExpGrammar.ts +1 -1
- package/src/{test-grammars → tests/test-grammars}/XmlGrammar.ts +1 -1
- package/src/utilities/Timer.ts +1 -1
- package/tsconfig.json +53 -103
- package/dist/Exports.d.ts +0 -1
- package/dist/Exports.js +0 -2
- package/dist/Exports.js.map +0 -1
- package/dist/Grammar.d.ts +0 -62
- package/dist/Grammar.js +0 -376
- package/dist/Grammar.js.map +0 -1
- package/dist/GrammarComposer.js.map +0 -1
- package/dist/Grammars/JsonGrammar.d.ts +0 -16
- package/dist/Grammars/JsonGrammar.js +0 -74
- package/dist/Grammars/JsonGrammar.js.map +0 -1
- package/dist/Grammars/XmlGrammar.d.ts +0 -13
- package/dist/Grammars/XmlGrammar.js +0 -74
- package/dist/Grammars/XmlGrammar.js.map +0 -1
- package/dist/ParserTest.d.ts +0 -1
- package/dist/ParserTest.js +0 -37
- package/dist/ParserTest.js.map +0 -1
- package/dist/Test.d.ts +0 -1
- package/dist/Test.js.map +0 -1
- package/dist/TestData.d.ts +0 -5
- package/dist/TestData.js +0 -466
- package/dist/TestData.js.map +0 -1
- package/dist/TopDownParser.js.map +0 -1
- package/dist/data/TestData.d.ts +0 -5
- package/dist/data/TestData.js +0 -466
- package/dist/data/TestData.js.map +0 -1
- package/dist/test-data/TestData.js.map +0 -1
- package/dist/test-grammars/JsonGrammar.js.map +0 -1
- package/dist/test-grammars/RegExpGrammar.js.map +0 -1
- package/dist/test-grammars/XmlGrammar.js.map +0 -1
- /package/dist/{test-data → tests/test-data}/TestData.js +0 -0
- /package/dist/utilities/{utilities.js → Utilities.js} +0 -0
- /package/dist/utilities/{utilities.js.map → Utilities.js.map} +0 -0
- /package/src/{test-data → tests/test-data}/TestData.ts +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "grammar-composer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Defines and generates parsers from composable grammar definitions. Includes advanced features like lexer-free parsing, selective packrat memoization and static analysis.",
|
|
5
5
|
"author": "Rotem Dan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"bugs": {
|
|
20
20
|
"url": "https://github.com/rotemdan/grammar-composer/issues"
|
|
21
21
|
},
|
|
22
|
-
"main": "./dist/
|
|
22
|
+
"main": "./dist/exports/Exports.js",
|
|
23
23
|
"type": "module",
|
|
24
24
|
"files": [
|
|
25
25
|
"dist",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"README.md"
|
|
30
30
|
],
|
|
31
31
|
"scripts": {
|
|
32
|
-
"test": "node dist/Test.js"
|
|
32
|
+
"test": "node dist/tests/Test.js"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"regexp-composer": "
|
|
35
|
+
"regexp-composer": "~0.4.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@types/node": "
|
|
38
|
+
"@types/node": "~26.2.0"
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../parser-generator/Grammar.js'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Pattern, buildRegExp, inputStart, isPatternOptional } from 'regexp-composer'
|
|
2
|
-
import { isArray, isBoolean, isFunction, isString } from
|
|
2
|
+
import { isArray, isBoolean, isFunction, isString } from '../utilities/Utilities.js'
|
|
3
3
|
|
|
4
4
|
import { parse } from './TopDownParser.js'
|
|
5
5
|
|
|
@@ -24,7 +24,7 @@ export function buildGrammar<T extends { [key: string]: any }>(obj: T | (new ()
|
|
|
24
24
|
continue
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
const productionContent = objectProperty()
|
|
27
|
+
const productionContent = objectProperty.call(obj)
|
|
28
28
|
const normalizedProduction = productionToGrammarElement(productionContent)
|
|
29
29
|
|
|
30
30
|
const newNonterminal = nonterminal(key, normalizedProduction)
|
|
@@ -69,7 +69,7 @@ export function buildGrammar<T extends { [key: string]: any }>(obj: T | (new ()
|
|
|
69
69
|
nonterminals,
|
|
70
70
|
startProductionName,
|
|
71
71
|
uniqueIdCounter
|
|
72
|
-
|
|
72
|
+
)
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
function prepareGrammarElement(
|
|
@@ -128,6 +128,18 @@ function prepareGrammarElement(
|
|
|
128
128
|
throw new Error(`Couldn't resolve function reference in grammar element: ${JSON.stringify(element)}`)
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
if (element.cached !== undefined || element.uniqueId !== undefined) {
|
|
132
|
+
const clonedNonterminal = { ...nonterminal }
|
|
133
|
+
|
|
134
|
+
if (element.cached !== undefined) {
|
|
135
|
+
clonedNonterminal.cached = element.cached
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
clonedNonterminal.uniqueId = getUniqueId()
|
|
139
|
+
|
|
140
|
+
return clonedNonterminal
|
|
141
|
+
}
|
|
142
|
+
|
|
131
143
|
if (nonterminal.uniqueId === undefined) {
|
|
132
144
|
nonterminal.uniqueId = getUniqueId()
|
|
133
145
|
}
|
|
@@ -147,7 +159,7 @@ function detectAndAnnotateOptionalNodes(rootNode: GrammarElement) {
|
|
|
147
159
|
const visitedNodes = new Set<GrammarElement>()
|
|
148
160
|
|
|
149
161
|
const resolvedNodes = new Map<GrammarElement, boolean>()
|
|
150
|
-
const unresolvedNodes = new Map<GrammarElement, Set<GrammarElement
|
|
162
|
+
const unresolvedNodes = new Map<GrammarElement, { dependencies: Set<GrammarElement>, isChoice: boolean }>()
|
|
151
163
|
|
|
152
164
|
function processDepthFirst(node: GrammarElement): boolean | undefined {
|
|
153
165
|
if (visitedNodes.has(node)) {
|
|
@@ -177,24 +189,23 @@ function detectAndAnnotateOptionalNodes(rootNode: GrammarElement) {
|
|
|
177
189
|
|
|
178
190
|
return result
|
|
179
191
|
} else {
|
|
180
|
-
unresolvedNodes.set(node, new Set([node.content]))
|
|
192
|
+
unresolvedNodes.set(node, { dependencies: new Set([node.content]), isChoice: false })
|
|
181
193
|
|
|
182
194
|
return undefined
|
|
183
195
|
}
|
|
184
196
|
}
|
|
185
197
|
|
|
186
|
-
case 'Sequence':
|
|
187
|
-
case 'Choice': {
|
|
198
|
+
case 'Sequence': {
|
|
188
199
|
const dependencies = new Set<GrammarElement>()
|
|
189
200
|
|
|
190
|
-
let
|
|
201
|
+
let hasNonOptionalResolvedMember = false
|
|
191
202
|
|
|
192
203
|
for (const element of node.members) {
|
|
193
204
|
const result = processDepthFirst(element)
|
|
194
205
|
|
|
195
206
|
if (isBoolean(result)) {
|
|
196
|
-
if (result
|
|
197
|
-
|
|
207
|
+
if (result === false) {
|
|
208
|
+
hasNonOptionalResolvedMember = true
|
|
198
209
|
}
|
|
199
210
|
} else {
|
|
200
211
|
dependencies.add(element)
|
|
@@ -205,12 +216,51 @@ function detectAndAnnotateOptionalNodes(rootNode: GrammarElement) {
|
|
|
205
216
|
resolvedNodes.set(node, true)
|
|
206
217
|
|
|
207
218
|
return true
|
|
208
|
-
} else if (
|
|
209
|
-
resolvedNodes.set(node,
|
|
219
|
+
} else if (hasNonOptionalResolvedMember) {
|
|
220
|
+
resolvedNodes.set(node, false)
|
|
221
|
+
|
|
222
|
+
return false
|
|
223
|
+
} else if (dependencies.size == 0) {
|
|
224
|
+
resolvedNodes.set(node, true)
|
|
210
225
|
|
|
211
|
-
return
|
|
226
|
+
return true
|
|
212
227
|
} else {
|
|
213
|
-
unresolvedNodes.set(node, dependencies)
|
|
228
|
+
unresolvedNodes.set(node, { dependencies, isChoice: false })
|
|
229
|
+
|
|
230
|
+
return undefined
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
case 'Choice': {
|
|
235
|
+
const dependencies = new Set<GrammarElement>()
|
|
236
|
+
let hasOptionalResolvedMember = false
|
|
237
|
+
|
|
238
|
+
for (const element of node.members) {
|
|
239
|
+
const result = processDepthFirst(element)
|
|
240
|
+
|
|
241
|
+
if (isBoolean(result)) {
|
|
242
|
+
if (result === true) {
|
|
243
|
+
hasOptionalResolvedMember = true
|
|
244
|
+
}
|
|
245
|
+
} else {
|
|
246
|
+
dependencies.add(element)
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (node.optional == true) {
|
|
251
|
+
resolvedNodes.set(node, true)
|
|
252
|
+
|
|
253
|
+
return true
|
|
254
|
+
} else if (hasOptionalResolvedMember) {
|
|
255
|
+
resolvedNodes.set(node, true)
|
|
256
|
+
|
|
257
|
+
return true
|
|
258
|
+
} else if (dependencies.size == 0) {
|
|
259
|
+
resolvedNodes.set(node, false)
|
|
260
|
+
|
|
261
|
+
return false
|
|
262
|
+
} else {
|
|
263
|
+
unresolvedNodes.set(node, { dependencies, isChoice: true })
|
|
214
264
|
|
|
215
265
|
return undefined
|
|
216
266
|
}
|
|
@@ -231,13 +281,14 @@ function detectAndAnnotateOptionalNodes(rootNode: GrammarElement) {
|
|
|
231
281
|
// If it stays false, it means that no improvement was made during the iteration,
|
|
232
282
|
// and we should exit the loop.
|
|
233
283
|
let atLastOneDependencyResolvedInAnyNode = false
|
|
284
|
+
const nodesToDelete: GrammarElement[] = []
|
|
234
285
|
|
|
235
286
|
// Scan the unresolved nodes to locate any new resolved dependencies
|
|
236
|
-
for (const [node, dependencies] of unresolvedNodes) {
|
|
237
|
-
let
|
|
287
|
+
for (const [node, { dependencies, isChoice }] of unresolvedNodes) {
|
|
288
|
+
let nodeResolved = false
|
|
238
289
|
|
|
239
290
|
// Iterate over all unresolved dependencies for the node
|
|
240
|
-
for (const dependency of dependencies) {
|
|
291
|
+
for (const dependency of Array.from(dependencies)) {
|
|
241
292
|
// Check if the dependency has been resolved
|
|
242
293
|
const value = resolvedNodes.get(dependency)
|
|
243
294
|
|
|
@@ -245,28 +296,41 @@ function detectAndAnnotateOptionalNodes(rootNode: GrammarElement) {
|
|
|
245
296
|
// If it did, record that some dependencies were resolved
|
|
246
297
|
atLastOneDependencyResolvedInAnyNode = true
|
|
247
298
|
|
|
248
|
-
if (
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
299
|
+
if (isChoice) {
|
|
300
|
+
if (value === true) {
|
|
301
|
+
resolvedNodes.set(node, true)
|
|
302
|
+
nodeResolved = true
|
|
303
|
+
break
|
|
304
|
+
}
|
|
253
305
|
} else {
|
|
254
|
-
|
|
255
|
-
|
|
306
|
+
if (value === false) {
|
|
307
|
+
resolvedNodes.set(node, false)
|
|
308
|
+
nodeResolved = true
|
|
309
|
+
break
|
|
310
|
+
}
|
|
256
311
|
}
|
|
312
|
+
|
|
313
|
+
dependencies.delete(dependency)
|
|
257
314
|
}
|
|
258
315
|
}
|
|
259
316
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
if (
|
|
263
|
-
|
|
317
|
+
if (nodeResolved) {
|
|
318
|
+
nodesToDelete.push(node)
|
|
319
|
+
} else if (dependencies.size === 0) {
|
|
320
|
+
if (isChoice) {
|
|
321
|
+
resolvedNodes.set(node, false)
|
|
322
|
+
} else {
|
|
323
|
+
resolvedNodes.set(node, true)
|
|
324
|
+
}
|
|
264
325
|
|
|
265
|
-
|
|
266
|
-
unresolvedNodes.delete(node)
|
|
326
|
+
nodesToDelete.push(node)
|
|
267
327
|
}
|
|
268
328
|
}
|
|
269
329
|
|
|
330
|
+
for (const node of nodesToDelete) {
|
|
331
|
+
unresolvedNodes.delete(node)
|
|
332
|
+
}
|
|
333
|
+
|
|
270
334
|
// If not even one dependency was eliminated for any node,
|
|
271
335
|
// it means that only mutually cyclic nodes are left unresolved, so exit the loop.
|
|
272
336
|
if (!atLastOneDependencyResolvedInAnyNode) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Grammar, GrammarElement, Terminal } from
|
|
1
|
+
import { Grammar, GrammarElement, Terminal } from './Grammar.js'
|
|
2
2
|
|
|
3
3
|
export function parse(inputString: string, grammar: Grammar<any>) {
|
|
4
4
|
const inputLength = inputString.length
|
|
@@ -78,12 +78,6 @@ export function parse(inputString: string, grammar: Grammar<any>) {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
case 'PatternTerminal': {
|
|
81
|
-
if (startOffset >= inputLength) {
|
|
82
|
-
updateBestFailedMatchesIfNeeded(grammarElement, startOffset)
|
|
83
|
-
|
|
84
|
-
return null
|
|
85
|
-
}
|
|
86
|
-
|
|
87
81
|
const substringToMatch = inputString.substring(startOffset)
|
|
88
82
|
|
|
89
83
|
const matchResults = grammarElement.regExp.exec(substringToMatch)
|
|
@@ -209,6 +203,10 @@ export function parse(inputString: string, grammar: Grammar<any>) {
|
|
|
209
203
|
break
|
|
210
204
|
}
|
|
211
205
|
|
|
206
|
+
if (result.endOffset === readOffset) {
|
|
207
|
+
break
|
|
208
|
+
}
|
|
209
|
+
|
|
212
210
|
if (result.nodes !== undefined) {
|
|
213
211
|
nodes.push(...result.nodes)
|
|
214
212
|
}
|
|
@@ -221,6 +219,11 @@ export function parse(inputString: string, grammar: Grammar<any>) {
|
|
|
221
219
|
endOffset: readOffset,
|
|
222
220
|
nodes: nodes.length > 0 ? nodes : undefined
|
|
223
221
|
}
|
|
222
|
+
} else if (grammarElement.optional === true) {
|
|
223
|
+
return {
|
|
224
|
+
endOffset: startOffset,
|
|
225
|
+
nodes: undefined
|
|
226
|
+
}
|
|
224
227
|
} else {
|
|
225
228
|
return null
|
|
226
229
|
}
|
|
@@ -252,10 +255,8 @@ export function parse(inputString: string, grammar: Grammar<any>) {
|
|
|
252
255
|
|
|
253
256
|
const result = tryParse(grammar.rootElement, 0)
|
|
254
257
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
if (lastNode && lastNode.endOffset >= inputLength) {
|
|
258
|
-
return result.nodes
|
|
258
|
+
if (result && result.endOffset >= inputLength) {
|
|
259
|
+
return result.nodes ?? []
|
|
259
260
|
} else {
|
|
260
261
|
if (bestFailedMatches.length > 0) {
|
|
261
262
|
const possibleMatches = bestFailedMatches.map(match => {
|
|
@@ -280,7 +281,9 @@ export function parse(inputString: string, grammar: Grammar<any>) {
|
|
|
280
281
|
|
|
281
282
|
throw new Error(`Failed parsing the input text. Expected ${possibleMatchesString} at position ${bestFailedMatchesOffset}.`)
|
|
282
283
|
} else {
|
|
283
|
-
|
|
284
|
+
const lastNode = result?.nodes?.[result.nodes.length - 1]
|
|
285
|
+
|
|
286
|
+
throw new Error(`Failed parsing the input text. Parsed length was ${lastNode?.endOffset ?? result?.endOffset ?? 0}. Input length was ${inputLength}.`)
|
|
284
287
|
}
|
|
285
288
|
}
|
|
286
289
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Timer } from
|
|
2
|
-
import { jsonSample1, jsonSample2 } from
|
|
3
|
-
import { anyOf, buildGrammar } from
|
|
4
|
-
import { JsonGrammar } from
|
|
5
|
-
import { XmlGrammar } from
|
|
6
|
-
import { RegExpGrammar } from
|
|
1
|
+
import { Timer } from '../utilities/Timer.js'
|
|
2
|
+
import { jsonSample1, jsonSample2 } from './test-data/TestData.js'
|
|
3
|
+
import { anyOf, buildGrammar } from '../exports/Exports.js'
|
|
4
|
+
import { JsonGrammar } from './test-grammars/JsonGrammar.js'
|
|
5
|
+
import { XmlGrammar } from './test-grammars/XmlGrammar.js'
|
|
6
|
+
import { RegExpGrammar } from './test-grammars/RegExpGrammar.js'
|
|
7
7
|
|
|
8
8
|
const log = console.log
|
|
9
9
|
|
package/src/utilities/Timer.ts
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,105 +1,55 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
56
|
-
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
57
|
-
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
58
|
-
"outDir": "./dist", /* Specify an output folder for all emitted files. */
|
|
59
|
-
// "removeComments": true, /* Disable emitting comments. */
|
|
60
|
-
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
61
|
-
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
62
|
-
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
63
|
-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
64
|
-
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
65
|
-
"emitBOM": false, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
66
|
-
"newLine": "lf", /* Set the newline character for emitting files. */
|
|
67
|
-
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
68
|
-
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
69
|
-
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
70
|
-
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
71
|
-
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
72
|
-
/* Interop Constraints */
|
|
73
|
-
"isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
74
|
-
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
|
75
|
-
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
|
|
76
|
-
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
77
|
-
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
78
|
-
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
79
|
-
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
80
|
-
/* Type Checking */
|
|
81
|
-
"strict": true, /* Enable all strict type-checking options. */
|
|
82
|
-
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
83
|
-
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
84
|
-
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
85
|
-
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
86
|
-
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
87
|
-
// "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
|
|
88
|
-
"noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
89
|
-
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
90
|
-
"alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
91
|
-
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
92
|
-
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
93
|
-
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
94
|
-
"noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
95
|
-
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
96
|
-
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
97
|
-
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
98
|
-
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
99
|
-
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
100
|
-
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
101
|
-
/* Completeness */
|
|
102
|
-
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
103
|
-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
104
|
-
}
|
|
2
|
+
// Visit https://aka.ms/tsconfig to read more about this file
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
// File Layout
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
|
|
8
|
+
// Environment Settings
|
|
9
|
+
// See also https://aka.ms/tsconfig/module
|
|
10
|
+
"module": "nodenext",
|
|
11
|
+
"target": "esnext",
|
|
12
|
+
"types": ["node"],
|
|
13
|
+
// For nodejs:
|
|
14
|
+
// "lib": ["esnext"],
|
|
15
|
+
// "types": ["node"],
|
|
16
|
+
// and npm install -D @types/node
|
|
17
|
+
|
|
18
|
+
// Other Outputs
|
|
19
|
+
"sourceMap": true,
|
|
20
|
+
"declaration": true,
|
|
21
|
+
"declarationMap": true,
|
|
22
|
+
|
|
23
|
+
// Stricter Typechecking Options
|
|
24
|
+
// "noUncheckedIndexedAccess": true,
|
|
25
|
+
// "exactOptionalPropertyTypes": true,
|
|
26
|
+
|
|
27
|
+
// Style Options
|
|
28
|
+
"noImplicitReturns": true,
|
|
29
|
+
// "noImplicitOverride": true,
|
|
30
|
+
// "noUnusedLocals": true,
|
|
31
|
+
// "noUnusedParameters": true,
|
|
32
|
+
// "noFallthroughCasesInSwitch": true,
|
|
33
|
+
// "noPropertyAccessFromIndexSignature": true,
|
|
34
|
+
|
|
35
|
+
// Recommended Options
|
|
36
|
+
"strict": true,
|
|
37
|
+
"jsx": "react-jsx",
|
|
38
|
+
// "verbatimModuleSyntax": true,
|
|
39
|
+
"isolatedModules": true,
|
|
40
|
+
"noUncheckedSideEffectImports": true,
|
|
41
|
+
"moduleDetection": "force",
|
|
42
|
+
"skipLibCheck": true,
|
|
43
|
+
|
|
44
|
+
// Extended options not in generated tsconfig.json
|
|
45
|
+
"newLine": "lf",
|
|
46
|
+
"forceConsistentCasingInFileNames": true,
|
|
47
|
+
"alwaysStrict": true,
|
|
48
|
+
|
|
49
|
+
"noImplicitThis": true,
|
|
50
|
+
"strictBindCallApply": true,
|
|
51
|
+
"strictFunctionTypes": true,
|
|
52
|
+
|
|
53
|
+
"noErrorTruncation": true,
|
|
54
|
+
}
|
|
105
55
|
}
|
package/dist/Exports.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/Exports.js
DELETED
package/dist/Exports.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Exports.js","sourceRoot":"","sources":["../src/Exports.ts"],"names":[],"mappings":""}
|
package/dist/Grammar.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Pattern } from 'regexp-composer';
|
|
2
|
-
export declare function buildGrammar<T extends {
|
|
3
|
-
[key: string]: any;
|
|
4
|
-
}>(obj: T | (new () => T), startProductionName: keyof T): Grammar<T>;
|
|
5
|
-
export declare function detectAndErrorOnLeftRecursion(rootNode: GrammarElement): void;
|
|
6
|
-
export declare function oneOrMore(content: Production): Repetition;
|
|
7
|
-
export declare function zeroOrMore(content: Production): Repetition;
|
|
8
|
-
export declare function anyOf(...members: Production[]): Choice;
|
|
9
|
-
export declare function bestOf(...members: Production[]): Choice;
|
|
10
|
-
export declare function possibly<T extends Production>(content: Production): T;
|
|
11
|
-
export declare function cached<T extends Production>(content: Production): T;
|
|
12
|
-
export declare function uncached<T extends Production>(content: Production): T;
|
|
13
|
-
export declare function pattern(pattern: Pattern): PatternTerminal;
|
|
14
|
-
export interface Grammar<T> {
|
|
15
|
-
rootElement: Nonterminal;
|
|
16
|
-
productions: {
|
|
17
|
-
[key in keyof T]: any;
|
|
18
|
-
};
|
|
19
|
-
maxElementId: number;
|
|
20
|
-
}
|
|
21
|
-
export type Production = string | GrammarElement | (() => Production) | Production[];
|
|
22
|
-
export type GrammarElement = StringTerminal | PatternTerminal | Nonterminal | Sequence | Repetition | Choice | NonterminalReference;
|
|
23
|
-
interface GrammarElementBase {
|
|
24
|
-
type: string;
|
|
25
|
-
optional: boolean;
|
|
26
|
-
uniqueId?: number;
|
|
27
|
-
cached?: boolean;
|
|
28
|
-
}
|
|
29
|
-
export type Terminal = StringTerminal | PatternTerminal;
|
|
30
|
-
export interface StringTerminal extends GrammarElementBase {
|
|
31
|
-
type: 'StringTerminal';
|
|
32
|
-
content: string;
|
|
33
|
-
}
|
|
34
|
-
export interface PatternTerminal extends GrammarElementBase {
|
|
35
|
-
type: 'PatternTerminal';
|
|
36
|
-
name: string;
|
|
37
|
-
pattern: Pattern | Pattern[];
|
|
38
|
-
regExp: RegExp;
|
|
39
|
-
}
|
|
40
|
-
export interface Nonterminal extends GrammarElementBase {
|
|
41
|
-
type: 'Nonterminal';
|
|
42
|
-
name: string;
|
|
43
|
-
content: GrammarElement;
|
|
44
|
-
}
|
|
45
|
-
export interface Sequence extends GrammarElementBase {
|
|
46
|
-
type: 'Sequence';
|
|
47
|
-
members: GrammarElement[];
|
|
48
|
-
}
|
|
49
|
-
export interface Repetition extends GrammarElementBase {
|
|
50
|
-
type: 'Repetition';
|
|
51
|
-
content: GrammarElement;
|
|
52
|
-
}
|
|
53
|
-
export interface Choice extends GrammarElementBase {
|
|
54
|
-
type: 'Choice';
|
|
55
|
-
members: GrammarElement[];
|
|
56
|
-
exhaustive: boolean;
|
|
57
|
-
}
|
|
58
|
-
export interface NonterminalReference extends GrammarElementBase {
|
|
59
|
-
type: 'NonterminalReference';
|
|
60
|
-
reference: Function;
|
|
61
|
-
}
|
|
62
|
-
export {};
|