@traqula/core 0.0.1-alpha.143 → 0.0.1-alpha.148
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/lib/grammar-builder/builderTypes.d.ts +14 -5
- package/lib/grammar-builder/builderTypes.js.map +1 -1
- package/lib/grammar-builder/parserBuilder.d.ts +38 -20
- package/lib/grammar-builder/parserBuilder.js +56 -114
- package/lib/grammar-builder/parserBuilder.js.map +1 -1
- package/lib/grammar-builder/ruleDefTypes.d.ts +44 -28
- package/lib/grammar-builder/ruleDefTypes.js.map +1 -1
- package/lib/index.cjs +45 -414
- package/package.json +4 -6
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import type { ParserMethod } from 'chevrotain';
|
|
2
2
|
import type { RuleDef } from './ruleDefTypes';
|
|
3
|
+
/**
|
|
4
|
+
* Get union-type of names used in list of ruledefs.
|
|
5
|
+
*/
|
|
3
6
|
export type RuleNamesFromList<T extends readonly RuleDef[]> = T[number]['name'];
|
|
7
|
+
/**
|
|
8
|
+
* Convert a list of ruledefs to a record that maps each rule name to its definition.
|
|
9
|
+
*/
|
|
4
10
|
export type RuleDefMap<RuleNames extends string> = {
|
|
5
|
-
[Key in RuleNames]: RuleDef<Key>;
|
|
11
|
+
[Key in RuleNames]: RuleDef<any, Key>;
|
|
6
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Check whether the first two types overlap, if yes, return the 3th argument, else the 4th.
|
|
15
|
+
*/
|
|
7
16
|
export type CheckOverlap<T, U, V, W = never> = T & U extends never ? V : W;
|
|
8
17
|
/**
|
|
9
18
|
* Convert a list of RuleDefs to a Record with the name of the RuleDef as the key, matching the RuleDefMap type.
|
|
@@ -11,9 +20,9 @@ export type CheckOverlap<T, U, V, W = never> = T & U extends never ? V : W;
|
|
|
11
20
|
export type RuleListToObject<T extends readonly RuleDef[], Names extends string = RuleNamesFromList<T>, Agg extends Record<string, RuleDef> = Record<never, never>> = T extends readonly [infer First, ...infer Rest] ? (First extends RuleDef ? (Rest extends readonly RuleDef[] ? (RuleListToObject<Rest, Names, {
|
|
12
21
|
[K in keyof Agg | First['name']]: K extends First['name'] ? First : Agg[K];
|
|
13
22
|
}>) : never) : never) : RuleDefMap<Names> & Agg;
|
|
14
|
-
export type ParserFromRules<Names extends string, RuleDefs extends RuleDefMap<Names>> = {
|
|
15
|
-
[K in Names]: RuleDefs[K] extends RuleDef<K, infer RET, infer ARGS> ? (
|
|
23
|
+
export type ParserFromRules<Context, Names extends string, RuleDefs extends RuleDefMap<Names>> = {
|
|
24
|
+
[K in Names]: RuleDefs[K] extends RuleDef<Context, K, infer RET, infer ARGS> ? (input: string, context: Context, args: ARGS) => RET : never;
|
|
16
25
|
};
|
|
17
|
-
export type ParseMethodsFromRules<Names extends string, RuleDefs extends RuleDefMap<Names>> = {
|
|
18
|
-
[K in Names]: RuleDefs[K] extends RuleDef<K, infer RET, infer ARGS> ? ParserMethod<ARGS, RET> : never;
|
|
26
|
+
export type ParseMethodsFromRules<Context, Names extends string, RuleDefs extends RuleDefMap<Names>> = {
|
|
27
|
+
[K in Names]: RuleDefs[K] extends RuleDef<Context, K, infer RET, infer ARGS> ? ParserMethod<[Context, ARGS], RET> : never;
|
|
19
28
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builderTypes.js","sourceRoot":"","sources":["builderTypes.ts"],"names":[],"mappings":"","sourcesContent":["import type { ParserMethod } from 'chevrotain';\nimport type {
|
|
1
|
+
{"version":3,"file":"builderTypes.js","sourceRoot":"","sources":["builderTypes.ts"],"names":[],"mappings":"","sourcesContent":["import type { ParserMethod } from 'chevrotain';\nimport type {RuleDef} from './ruleDefTypes';\n\n/**\n * Get union-type of names used in list of ruledefs.\n */\nexport type RuleNamesFromList<T extends readonly RuleDef[]> = T[number]['name'];\n\n/**\n * Convert a list of ruledefs to a record that maps each rule name to its definition.\n */\nexport type RuleDefMap<RuleNames extends string> = {[Key in RuleNames]: RuleDef<any, Key> };\n\n/**\n * Check whether the first two types overlap, if yes, return the 3th argument, else the 4th.\n */\nexport type CheckOverlap<T, U, V, W = never> = T & U extends never ? V : W;\n\n/**\n * Convert a list of RuleDefs to a Record with the name of the RuleDef as the key, matching the RuleDefMap type.\n */\nexport type RuleListToObject<\n T extends readonly RuleDef[],\n Names extends string = RuleNamesFromList<T>,\n Agg extends Record<string, RuleDef> = Record<never, never>,\n> = T extends readonly [infer First, ...infer Rest] ? (\n First extends RuleDef ? (\n Rest extends readonly RuleDef[] ? (\n RuleListToObject<Rest, Names, {[K in keyof Agg | First['name']]: K extends First['name'] ? First : Agg[K] }>\n ) : never\n ) : never\n) : RuleDefMap<Names> & Agg;\n\nexport type ParserFromRules<Context, Names extends string, RuleDefs extends RuleDefMap<Names>> = {\n [K in Names]: RuleDefs[K] extends RuleDef<Context, K, infer RET, infer ARGS> ? (input: string, context: Context, args: ARGS) => RET : never\n};\n\nexport type ParseMethodsFromRules<Context, Names extends string, RuleDefs extends RuleDefMap<Names>> = {\n [K in Names]: RuleDefs[K] extends RuleDef<Context, K, infer RET, infer ARGS> ? ParserMethod<[Context, ARGS], RET> : never\n};\n"]}
|
|
@@ -1,50 +1,68 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ILexerConfig, IParserConfig } from '@chevrotain/types';
|
|
2
2
|
import type { TokenType, TokenVocabulary } from 'chevrotain';
|
|
3
3
|
import { EmbeddedActionsParser } from 'chevrotain';
|
|
4
|
-
import type { CheckOverlap,
|
|
5
|
-
import type {
|
|
6
|
-
|
|
4
|
+
import type { CheckOverlap, ParseMethodsFromRules, ParserFromRules, RuleDefMap, RuleListToObject, RuleNamesFromList } from './builderTypes';
|
|
5
|
+
import type { RuleDef } from './ruleDefTypes';
|
|
6
|
+
/**
|
|
7
|
+
* The grammar builder. This is the core of traqula (besides using the amazing chevrotain framework).
|
|
8
|
+
* Using the builder you can create a grammar + AST creator.
|
|
9
|
+
* At any point in time, a parser can be constructed from the added rules.
|
|
10
|
+
* Constructing a parser will cause a validation which will validate the correctness of the grammar.
|
|
11
|
+
*/
|
|
12
|
+
export declare class Builder<Context, Names extends string, RuleDefs extends RuleDefMap<Names>> {
|
|
7
13
|
/**
|
|
8
|
-
* Create a builder
|
|
14
|
+
* Create a builder from some initial grammar rules or an existing builder.
|
|
9
15
|
* If a builder is provided, a new copy will be created.
|
|
10
16
|
*/
|
|
11
|
-
static createBuilder<Rules extends readonly RuleDef[] = RuleDef[], Names extends string = RuleNamesFromList<Rules>, RuleDefs extends RuleDefMap<Names> = RuleListToObject<Rules>>(start: Rules | Builder<Names, RuleDefs>): Builder<Names, RuleDefs>;
|
|
17
|
+
static createBuilder<Rules extends readonly RuleDef[] = readonly RuleDef[], Context = Rules[0] extends RuleDef<infer context> ? context : never, Names extends string = RuleNamesFromList<Rules>, RuleDefs extends RuleDefMap<Names> = RuleListToObject<Rules>>(start: Rules | Builder<Context, Names, RuleDefs>): Builder<Context, Names, RuleDefs>;
|
|
12
18
|
private rules;
|
|
13
19
|
private constructor();
|
|
14
20
|
/**
|
|
15
21
|
* Change the implementation of an existing grammar rule.
|
|
16
22
|
*/
|
|
17
|
-
patchRule<U extends Names, RET, ARGS
|
|
18
|
-
[Key in Names]: Key extends U ? RuleDef<Key, RET, ARGS> : (RuleDefs[Key] extends RuleDef<Key> ? RuleDefs[Key] : never);
|
|
23
|
+
patchRule<U extends Names, RET, ARGS>(patch: RuleDef<Context, U, RET, ARGS>): Builder<Context, Names, {
|
|
24
|
+
[Key in Names]: Key extends U ? RuleDef<Context, Key, RET, ARGS> : (RuleDefs[Key] extends RuleDef<Context, Key> ? RuleDefs[Key] : never);
|
|
19
25
|
}>;
|
|
20
26
|
/**
|
|
21
27
|
* Add a rule to the grammar. If the rule already exists, but the implementation differs, an error will be thrown.
|
|
22
28
|
*/
|
|
23
|
-
addRuleRedundant<U extends string, RET, ARGS
|
|
24
|
-
[K in Names | U]: K extends U ? RuleDef<K, RET, ARGS> : (K extends Names ? (RuleDefs[K] extends RuleDef<K> ? RuleDefs[K] : never) : never);
|
|
29
|
+
addRuleRedundant<U extends string, RET, ARGS>(rule: RuleDef<Context, U, RET, ARGS>): Builder<Context, Names | U, {
|
|
30
|
+
[K in Names | U]: K extends U ? RuleDef<Context, K, RET, ARGS> : (K extends Names ? (RuleDefs[K] extends RuleDef<Context, K> ? RuleDefs[K] : never) : never);
|
|
25
31
|
}>;
|
|
26
32
|
/**
|
|
27
33
|
* Add a rule to the grammar. Will raise a typescript error if the rule already exists in the grammar.
|
|
28
34
|
*/
|
|
29
|
-
addRule<U extends string, RET, ARGS
|
|
30
|
-
[K in Names | U]: K extends U ? RuleDef<K, RET, ARGS> : (K extends Names ? (RuleDefs[K] extends RuleDef<K> ? RuleDefs[K] : never) : never);
|
|
35
|
+
addRule<U extends string, RET, ARGS>(rule: CheckOverlap<U, Names, RuleDef<Context, U, RET, ARGS>>): Builder<Context, Names | U, {
|
|
36
|
+
[K in Names | U]: K extends U ? RuleDef<Context, K, RET, ARGS> : (K extends Names ? (RuleDefs[K] extends RuleDef<Context, K> ? RuleDefs[K] : never) : never);
|
|
31
37
|
}>;
|
|
32
|
-
addMany<U extends RuleDef[]>(...rules: CheckOverlap<RuleNamesFromList<U>, Names, U>): Builder<Names | RuleNamesFromList<U>, {
|
|
33
|
-
[K in Names | RuleNamesFromList<U>]: K extends keyof RuleListToObject<typeof rules> ? (RuleListToObject<typeof rules>[K] extends RuleDef<K> ? RuleListToObject<typeof rules>[K] : never) : (K extends Names ? (RuleDefs[K] extends RuleDef<K> ? RuleDefs[K] : never) : never);
|
|
38
|
+
addMany<U extends readonly RuleDef<Context>[]>(...rules: CheckOverlap<RuleNamesFromList<U>, Names, U>): Builder<Context, Names | RuleNamesFromList<U>, {
|
|
39
|
+
[K in Names | RuleNamesFromList<U>]: K extends keyof RuleListToObject<typeof rules> ? (RuleListToObject<typeof rules>[K] extends RuleDef<Context, K> ? RuleListToObject<typeof rules>[K] : never) : (K extends Names ? (RuleDefs[K] extends RuleDef<Context, K> ? RuleDefs[K] : never) : never);
|
|
34
40
|
}>;
|
|
35
|
-
|
|
36
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Delete a grammar rule by its name.
|
|
43
|
+
*/
|
|
44
|
+
deleteRule<U extends Names>(ruleName: U): Builder<Context, Exclude<Names, U>, {
|
|
45
|
+
[K in Exclude<Names, U>]: RuleDefs[K] extends RuleDef<Context, K> ? RuleDefs[K] : never;
|
|
37
46
|
}>;
|
|
38
|
-
|
|
39
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Merge this grammar builder with another.
|
|
49
|
+
* It is best to merge the bigger grammar with the smaller one.
|
|
50
|
+
* If the two builders both have a grammar rule with the same name, no error will be thrown case they map to the same ruledef object.
|
|
51
|
+
* If they map to a different object, an error will be thrown.
|
|
52
|
+
* To fix this problem, the overridingRules array should contain a rule with the same conflicting name, this rule implementation will be used.
|
|
53
|
+
*/
|
|
54
|
+
merge<OtherNames extends string, OtherRules extends RuleDefMap<OtherNames>, OW extends readonly RuleDef<Context>[]>(builder: Builder<Context, OtherNames, OtherRules>, overridingRules: OW): Builder<Context, Names | OtherNames | RuleNamesFromList<OW>, {
|
|
55
|
+
[K in Names | OtherNames | RuleNamesFromList<OW>]: K extends keyof RuleListToObject<OW> ? (RuleListToObject<OW>[K] extends RuleDef<Context, K> ? RuleListToObject<OW>[K] : never) : (K extends Names ? (RuleDefs[K] extends RuleDef<Context, K> ? RuleDefs[K] : never) : K extends OtherNames ? (OtherRules[K] extends RuleDef<Context, K> ? OtherRules[K] : never) : never);
|
|
40
56
|
}>;
|
|
41
57
|
consumeToParser({ tokenVocabulary, parserConfig, lexerConfig }: {
|
|
42
58
|
tokenVocabulary: TokenType[];
|
|
43
59
|
parserConfig?: IParserConfig;
|
|
44
60
|
lexerConfig?: ILexerConfig;
|
|
45
|
-
}
|
|
61
|
+
}): ParserFromRules<Context, Names, RuleDefs>;
|
|
46
62
|
consume({ tokenVocabulary, config }: {
|
|
47
63
|
tokenVocabulary: TokenVocabulary;
|
|
48
64
|
config?: IParserConfig;
|
|
49
|
-
}
|
|
65
|
+
}): EmbeddedActionsParser & ParseMethodsFromRules<Context, Names, RuleDefs> & {
|
|
66
|
+
setContext: (context: Context) => void;
|
|
67
|
+
};
|
|
50
68
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { EmbeddedActionsParser, Lexer } from 'chevrotain';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Converts a list of ruledefs to a record mapping a name to the corresponding ruledef.
|
|
4
|
+
*/
|
|
3
5
|
function listToRuleDefMap(rules) {
|
|
4
6
|
const newRules = {};
|
|
5
7
|
for (const rule of rules) {
|
|
@@ -7,9 +9,16 @@ function listToRuleDefMap(rules) {
|
|
|
7
9
|
}
|
|
8
10
|
return newRules;
|
|
9
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* The grammar builder. This is the core of traqula (besides using the amazing chevrotain framework).
|
|
14
|
+
* Using the builder you can create a grammar + AST creator.
|
|
15
|
+
* At any point in time, a parser can be constructed from the added rules.
|
|
16
|
+
* Constructing a parser will cause a validation which will validate the correctness of the grammar.
|
|
17
|
+
*/
|
|
18
|
+
// This code is wild so other code can be simple.
|
|
10
19
|
export class Builder {
|
|
11
20
|
/**
|
|
12
|
-
* Create a builder
|
|
21
|
+
* Create a builder from some initial grammar rules or an existing builder.
|
|
13
22
|
* If a builder is provided, a new copy will be created.
|
|
14
23
|
*/
|
|
15
24
|
static createBuilder(start) {
|
|
@@ -51,10 +60,20 @@ export class Builder {
|
|
|
51
60
|
this.rules = { ...this.rules, ...listToRuleDefMap(rules) };
|
|
52
61
|
return this;
|
|
53
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Delete a grammar rule by its name.
|
|
65
|
+
*/
|
|
54
66
|
deleteRule(ruleName) {
|
|
55
67
|
delete this.rules[ruleName];
|
|
56
68
|
return this;
|
|
57
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Merge this grammar builder with another.
|
|
72
|
+
* It is best to merge the bigger grammar with the smaller one.
|
|
73
|
+
* If the two builders both have a grammar rule with the same name, no error will be thrown case they map to the same ruledef object.
|
|
74
|
+
* If they map to a different object, an error will be thrown.
|
|
75
|
+
* To fix this problem, the overridingRules array should contain a rule with the same conflicting name, this rule implementation will be used.
|
|
76
|
+
*/
|
|
58
77
|
merge(builder, overridingRules) {
|
|
59
78
|
// Assume the other grammar is bigger than yours. So start from that one and add this one
|
|
60
79
|
const otherRules = { ...builder.rules };
|
|
@@ -81,7 +100,7 @@ export class Builder {
|
|
|
81
100
|
this.rules = otherRules;
|
|
82
101
|
return this;
|
|
83
102
|
}
|
|
84
|
-
consumeToParser({ tokenVocabulary, parserConfig = {}, lexerConfig = {} }
|
|
103
|
+
consumeToParser({ tokenVocabulary, parserConfig = {}, lexerConfig = {} }) {
|
|
85
104
|
const lexer = new Lexer(tokenVocabulary, {
|
|
86
105
|
positionTracking: 'onlyStart',
|
|
87
106
|
recoveryEnabled: false,
|
|
@@ -90,11 +109,13 @@ export class Builder {
|
|
|
90
109
|
ensureOptimizations: true,
|
|
91
110
|
...lexerConfig,
|
|
92
111
|
});
|
|
93
|
-
|
|
112
|
+
// get the chevrotain parser
|
|
113
|
+
const parser = this.consume({ tokenVocabulary, config: parserConfig });
|
|
114
|
+
// Start building a parser that does not pass input using a state, but instead gets it as a function argument.
|
|
94
115
|
const selfSufficientParser = {};
|
|
95
|
-
//
|
|
116
|
+
// To do that, we need to create a wrapper for each parser rule.
|
|
96
117
|
for (const rule of Object.values(this.rules)) {
|
|
97
|
-
selfSufficientParser[rule.name] = ((input,
|
|
118
|
+
selfSufficientParser[rule.name] = ((input, context, arg) => {
|
|
98
119
|
// Transform input in accordance to 19.2
|
|
99
120
|
input = input.replaceAll(/\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{8})/gu, (_, unicode4, unicode8) => {
|
|
100
121
|
if (unicode4) {
|
|
@@ -113,10 +134,10 @@ export class Builder {
|
|
|
113
134
|
throw new Error(`Invalid unicode codepoint of surrogate pair without corresponding codepoint`);
|
|
114
135
|
}
|
|
115
136
|
const lexResult = lexer.tokenize(input);
|
|
116
|
-
//
|
|
117
|
-
parser.reset();
|
|
137
|
+
// This also resets the parser
|
|
118
138
|
parser.input = lexResult.tokens;
|
|
119
|
-
|
|
139
|
+
parser.setContext(context);
|
|
140
|
+
const result = parser[rule.name](context, arg);
|
|
120
141
|
if (parser.errors.length > 0) {
|
|
121
142
|
// Console.log(lexResult.tokens);
|
|
122
143
|
throw new Error(`Parse error on line ${parser.errors.map(x => x.token.startLine).join(', ')}
|
|
@@ -127,9 +148,18 @@ ${parser.errors.map(x => `${x.token.startLine}: ${x.message}`).join('\n')}`);
|
|
|
127
148
|
}
|
|
128
149
|
return selfSufficientParser;
|
|
129
150
|
}
|
|
130
|
-
consume({ tokenVocabulary, config = {} }
|
|
151
|
+
consume({ tokenVocabulary, config = {} }) {
|
|
131
152
|
const rules = this.rules;
|
|
132
153
|
class MyParser extends EmbeddedActionsParser {
|
|
154
|
+
getSafeContext() {
|
|
155
|
+
if (this.context === undefined) {
|
|
156
|
+
throw new Error('context was not correctly set');
|
|
157
|
+
}
|
|
158
|
+
return this.context;
|
|
159
|
+
}
|
|
160
|
+
setContext(context) {
|
|
161
|
+
this.context = context;
|
|
162
|
+
}
|
|
133
163
|
constructor() {
|
|
134
164
|
super(tokenVocabulary, {
|
|
135
165
|
// RecoveryEnabled: true,
|
|
@@ -137,41 +167,23 @@ ${parser.errors.map(x => `${x.token.startLine}: ${x.message}`).join('\n')}`);
|
|
|
137
167
|
// SkipValidations: true,
|
|
138
168
|
...config,
|
|
139
169
|
});
|
|
170
|
+
this.context = undefined;
|
|
140
171
|
const selfRef = this.getSelfRef();
|
|
141
|
-
// !!! Remember to change the RESET function accordingly !!!
|
|
142
|
-
this.initialParseContext = {
|
|
143
|
-
dataFactory: new DataFactory({ blankNodePrefix: 'g_' }),
|
|
144
|
-
baseIRI: undefined,
|
|
145
|
-
parseMode: new Set(),
|
|
146
|
-
skipValidation: false,
|
|
147
|
-
...context,
|
|
148
|
-
prefixes: context.prefixes ? { ...context.prefixes } : {},
|
|
149
|
-
};
|
|
150
|
-
this.runningContext = {
|
|
151
|
-
...this.initialParseContext,
|
|
152
|
-
prefixes: { ...this.initialParseContext.prefixes },
|
|
153
|
-
parseMode: new Set(this.initialParseContext.parseMode),
|
|
154
|
-
};
|
|
155
172
|
const implArgs = {
|
|
156
173
|
...selfRef,
|
|
157
174
|
cache: new WeakMap(),
|
|
158
|
-
context: this.runningContext,
|
|
159
175
|
};
|
|
160
176
|
for (const rule of Object.values(rules)) {
|
|
161
177
|
this[rule.name] = this.RULE(rule.name, rule.impl(implArgs));
|
|
162
178
|
}
|
|
163
179
|
this.performSelfAnalysis();
|
|
164
180
|
}
|
|
165
|
-
reset() {
|
|
166
|
-
super.reset();
|
|
167
|
-
// We need to keep the original object reference.
|
|
168
|
-
Object.assign(this.runningContext, {
|
|
169
|
-
...this.initialParseContext,
|
|
170
|
-
});
|
|
171
|
-
this.runningContext.prefixes = { ...this.initialParseContext.prefixes };
|
|
172
|
-
this.runningContext.parseMode = new Set(this.initialParseContext.parseMode);
|
|
173
|
-
}
|
|
174
181
|
getSelfRef() {
|
|
182
|
+
const subRuleImpl = (chevrotainSubrule) => {
|
|
183
|
+
return ((cstDef, arg) => {
|
|
184
|
+
return chevrotainSubrule(this[cstDef.name], { ARGS: [this.context, arg] });
|
|
185
|
+
});
|
|
186
|
+
};
|
|
175
187
|
return {
|
|
176
188
|
CONSUME: (tokenType, option) => this.CONSUME(tokenType, option),
|
|
177
189
|
CONSUME1: (tokenType, option) => this.CONSUME1(tokenType, option),
|
|
@@ -252,86 +264,16 @@ ${parser.errors.map(x => `${x.token.startLine}: ${x.message}`).join('\n')}`);
|
|
|
252
264
|
throw error;
|
|
253
265
|
}
|
|
254
266
|
},
|
|
255
|
-
SUBRULE: (
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
return this.SUBRULE1(this[cstDef.name], { ARGS: args });
|
|
266
|
-
}
|
|
267
|
-
catch (error) {
|
|
268
|
-
throw error;
|
|
269
|
-
}
|
|
270
|
-
},
|
|
271
|
-
SUBRULE2: (cstDef, ...args) => {
|
|
272
|
-
try {
|
|
273
|
-
return this.SUBRULE2(this[cstDef.name], { ARGS: args });
|
|
274
|
-
}
|
|
275
|
-
catch (error) {
|
|
276
|
-
throw error;
|
|
277
|
-
}
|
|
278
|
-
},
|
|
279
|
-
SUBRULE3: (cstDef, ...args) => {
|
|
280
|
-
try {
|
|
281
|
-
return this.SUBRULE3(this[cstDef.name], { ARGS: args });
|
|
282
|
-
}
|
|
283
|
-
catch (error) {
|
|
284
|
-
throw error;
|
|
285
|
-
}
|
|
286
|
-
},
|
|
287
|
-
SUBRULE4: (cstDef, ...args) => {
|
|
288
|
-
try {
|
|
289
|
-
return this.SUBRULE4(this[cstDef.name], { ARGS: args });
|
|
290
|
-
}
|
|
291
|
-
catch (error) {
|
|
292
|
-
throw error;
|
|
293
|
-
}
|
|
294
|
-
},
|
|
295
|
-
SUBRULE5: (cstDef, ...args) => {
|
|
296
|
-
try {
|
|
297
|
-
return this.SUBRULE5(this[cstDef.name], { ARGS: args });
|
|
298
|
-
}
|
|
299
|
-
catch (error) {
|
|
300
|
-
throw error;
|
|
301
|
-
}
|
|
302
|
-
},
|
|
303
|
-
SUBRULE6: (cstDef, ...args) => {
|
|
304
|
-
try {
|
|
305
|
-
return this.SUBRULE6(this[cstDef.name], { ARGS: args });
|
|
306
|
-
}
|
|
307
|
-
catch (error) {
|
|
308
|
-
throw error;
|
|
309
|
-
}
|
|
310
|
-
},
|
|
311
|
-
SUBRULE7: (cstDef, ...args) => {
|
|
312
|
-
try {
|
|
313
|
-
return this.SUBRULE7(this[cstDef.name], { ARGS: args });
|
|
314
|
-
}
|
|
315
|
-
catch (error) {
|
|
316
|
-
throw error;
|
|
317
|
-
}
|
|
318
|
-
},
|
|
319
|
-
SUBRULE8: (cstDef, ...args) => {
|
|
320
|
-
try {
|
|
321
|
-
return this.SUBRULE8(this[cstDef.name], { ARGS: args });
|
|
322
|
-
}
|
|
323
|
-
catch (error) {
|
|
324
|
-
throw error;
|
|
325
|
-
}
|
|
326
|
-
},
|
|
327
|
-
SUBRULE9: (cstDef, ...args) => {
|
|
328
|
-
try {
|
|
329
|
-
return this.SUBRULE9(this[cstDef.name], { ARGS: args });
|
|
330
|
-
}
|
|
331
|
-
catch (error) {
|
|
332
|
-
throw error;
|
|
333
|
-
}
|
|
334
|
-
},
|
|
267
|
+
SUBRULE: subRuleImpl((rule, args) => this.SUBRULE(rule, args)),
|
|
268
|
+
SUBRULE1: subRuleImpl((rule, args) => this.SUBRULE1(rule, args)),
|
|
269
|
+
SUBRULE2: subRuleImpl((rule, args) => this.SUBRULE2(rule, args)),
|
|
270
|
+
SUBRULE3: subRuleImpl((rule, args) => this.SUBRULE3(rule, args)),
|
|
271
|
+
SUBRULE4: subRuleImpl((rule, args) => this.SUBRULE4(rule, args)),
|
|
272
|
+
SUBRULE5: subRuleImpl((rule, args) => this.SUBRULE5(rule, args)),
|
|
273
|
+
SUBRULE6: subRuleImpl((rule, args) => this.SUBRULE6(rule, args)),
|
|
274
|
+
SUBRULE7: subRuleImpl((rule, args) => this.SUBRULE7(rule, args)),
|
|
275
|
+
SUBRULE8: subRuleImpl((rule, args) => this.SUBRULE8(rule, args)),
|
|
276
|
+
SUBRULE9: subRuleImpl((rule, args) => this.SUBRULE9(rule, args)),
|
|
335
277
|
};
|
|
336
278
|
}
|
|
337
279
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parserBuilder.js","sourceRoot":"","sources":["parserBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAW/C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E;wBAC5B,IAAI,CAAC;4BACH,OAAO,IAAI,CAAC,QAAQ,CAAO,IAAI,CAAuB,MAAM,CAAC,IAAI,CAAC,EAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;wBAC5F,CAAC;wBAAC,OAAO,KAAc,EAAE,CAAC;4BACxB,MAAM,KAAK,CAAC;wBACd,CAAC;oBACH,CAAC;iBACF,CAAC;YACJ,CAAC;SACF;QACD,OAAiF,IAAI,QAAQ,EAAE,CAAC;IAClG,CAAC;CACF","sourcesContent":["import type { ILexerConfig, IParserConfig } from '@chevrotain/types';\nimport type {IToken, TokenType, TokenVocabulary} from 'chevrotain';\nimport { EmbeddedActionsParser, Lexer } from 'chevrotain';\nimport { DataFactory } from 'rdf-data-factory';\nimport type {\n CheckOverlap,\n RuleDefMap,\n ParserFromRules,\n RuleListToObject,\n RuleNamesFromList,\n ParseMethodsFromRules,\n} from './builderTypes';\nimport type { CstDef, ImplArgs, RuleDef } from './ruleDefTypes';\n\nfunction listToRuleDefMap<T extends readonly RuleDef[]>(rules: T): RuleListToObject<T> {\n const newRules: Record<string, RuleDef> = {};\n for (const rule of rules) {\n newRules[rule.name] = rule;\n }\n return <RuleListToObject<T>>newRules;\n}\n\nexport class Builder<Names extends string, RuleDefs extends RuleDefMap<Names>> {\n /**\n * Create a builder with from some initial grammar rules or an existing builder.\n * If a builder is provided, a new copy will be created.\n */\n public static createBuilder<\n Rules extends readonly RuleDef[] = RuleDef[],\n Names extends string = RuleNamesFromList<Rules>,\n RuleDefs extends RuleDefMap<Names> = RuleListToObject<Rules>,\n>(start: Rules | Builder<Names, RuleDefs>): Builder<Names, RuleDefs> {\n if (start instanceof Builder) {\n return new Builder({ ...start.rules });\n }\n return <Builder<Names, RuleDefs>> <unknown> new Builder(listToRuleDefMap(start));\n }\n\n private rules: RuleDefs;\n\n private constructor(startRules: RuleDefs) {\n this.rules = startRules;\n }\n\n /**\n * Change the implementation of an existing grammar rule.\n */\n public patchRule<U extends Names, RET, ARGS extends unknown[]>(patch: RuleDef<U, RET, ARGS>):\n Builder<Names, {[Key in Names]: Key extends U ? RuleDef<Key, RET, ARGS> : (RuleDefs[Key] extends RuleDef<Key> ? RuleDefs[Key] : never) }> {\n const self = <Builder<Names, {[Key in Names]: Key extends U ? RuleDef<Key, RET, ARGS> : (RuleDefs[Key] extends RuleDef<Key> ? RuleDefs[Key] : never) }>>\n <unknown> this;\n self.rules[patch.name] = <any> patch;\n return self;\n }\n\n /**\n * Add a rule to the grammar. If the rule already exists, but the implementation differs, an error will be thrown.\n */\n public addRuleRedundant<U extends string, RET, ARGS extends undefined[]>(rule: RuleDef<U, RET, ARGS>):\n Builder<Names | U, {[K in Names | U]: K extends U ? RuleDef<K, RET, ARGS> : ( K extends Names ? (RuleDefs[K] extends RuleDef<K> ? RuleDefs[K] : never ) : never) }> {\n const self = <Builder<Names | U, {[K in Names | U]: K extends U ? RuleDef<K, RET, ARGS> : ( K extends Names ? (RuleDefs[K] extends RuleDef<K> ? RuleDefs[K] : never ) : never) }>>\n <unknown> this;\n const rules = <Record<string, RuleDef>> self.rules;\n if (rules[rule.name] !== undefined && rules[rule.name] !== rule) {\n throw new Error(`Rule ${rule.name} already exists in the builder`);\n }\n rules[rule.name] = rule;\n return self;\n }\n\n /**\n * Add a rule to the grammar. Will raise a typescript error if the rule already exists in the grammar.\n */\n public addRule<U extends string, RET, ARGS extends unknown[]>(\n rule: CheckOverlap<U, Names, RuleDef<U, RET, ARGS>>,\n ): Builder<Names | U, {[K in Names | U]: K extends U ? RuleDef<K, RET, ARGS> : ( K extends Names ? (RuleDefs[K] extends RuleDef<K> ? RuleDefs[K] : never ) : never) }> {\n return this.addRuleRedundant(rule);\n }\n\n public addMany<U extends RuleDef[]>(\n ...rules: CheckOverlap<RuleNamesFromList<U>, Names, U>\n ): Builder<\n Names | RuleNamesFromList<U>,\n {[K in Names | RuleNamesFromList<U>]:\n K extends keyof RuleListToObject<typeof rules> ? (\n RuleListToObject<typeof rules>[K] extends RuleDef<K> ? RuleListToObject<typeof rules>[K] : never\n ) : (\n K extends Names ? (RuleDefs[K] extends RuleDef<K> ? RuleDefs[K] : never) : never\n )\n }> {\n this.rules = { ...this.rules, ...listToRuleDefMap(rules) };\n return <any> <unknown> this;\n }\n\n public deleteRule<U extends Names>(ruleName: U):\n Builder<Exclude<Names, U>, { [K in Exclude<Names, U>]: RuleDefs[K] extends RuleDef<K> ? RuleDefs[K] : never }> {\n delete this.rules[ruleName];\n return <Builder<Exclude<Names, U>, { [K in Exclude<Names, U>]: RuleDefs[K] extends RuleDef<K> ? RuleDefs[K] : never }>>\n <unknown> this;\n }\n\n public merge<OtherNames extends string, OtherRules extends RuleDefMap<OtherNames>, OW extends readonly RuleDef[]>(\n builder: Builder<OtherNames, OtherRules>,\n overridingRules: OW,\n ):\n Builder<\n Names | OtherNames | RuleNamesFromList<OW>,\n {[K in Names | OtherNames | RuleNamesFromList<OW>]:\n K extends keyof RuleListToObject<OW> ? (\n RuleListToObject<OW>[K] extends RuleDef<K> ? RuleListToObject<OW>[K] : never\n )\n : (\n K extends Names ? (RuleDefs[K] extends RuleDef<K> ? RuleDefs[K] : never)\n : K extends OtherNames ? (OtherRules[K] extends RuleDef<K> ? OtherRules[K] : never) : never\n )}> {\n // Assume the other grammar is bigger than yours. So start from that one and add this one\n const otherRules: Record<string, RuleDef> = { ...builder.rules };\n const myRules: Record<string, RuleDef> = this.rules;\n\n for (const rule of Object.values(myRules)) {\n if (otherRules[rule.name] === undefined) {\n otherRules[rule.name] = rule;\n } else {\n const existingRule = otherRules[rule.name];\n // If same rule, no issue, move on. Else\n if (existingRule !== rule) {\n const override = overridingRules.find(x => x.name === rule.name);\n // If override specified, take override, else, inform user that there is a conflict\n if (override) {\n otherRules[rule.name] = override;\n } else {\n throw new Error(`Rule with name \"${rule.name}\" already exists in the builder, specify an override to resolve conflict`);\n }\n }\n }\n }\n\n this.rules = <any> <unknown> otherRules;\n return <any> <unknown> this;\n }\n\n public consumeToParser({ tokenVocabulary, parserConfig = {}, lexerConfig = {}}: {\n tokenVocabulary: TokenType[];\n parserConfig?: IParserConfig;\n lexerConfig?: ILexerConfig;\n }, context: Partial<ImplArgs['context']> = {}): ParserFromRules<Names, RuleDefs> {\n const lexer: Lexer = new Lexer(tokenVocabulary, {\n positionTracking: 'onlyStart',\n recoveryEnabled: false,\n // SafeMode: true,\n // SkipValidations: true,\n ensureOptimizations: true,\n ...lexerConfig,\n });\n const parser = this.consume({ tokenVocabulary, config: parserConfig }, context);\n const selfSufficientParser: Partial<ParserFromRules<Names, RuleDefs>> = {};\n // eslint-disable-next-line ts/no-unnecessary-type-assertion\n for (const rule of <RuleDef<Names>[]> Object.values(this.rules)) {\n selfSufficientParser[rule.name] = <any> ((input: string, ...args: unknown[]) => {\n // Transform input in accordance to 19.2\n input = input.replaceAll(\n /\\\\u([0-9a-fA-F]{4})|\\\\U([0-9a-fA-F]{8})/gu,\n (_, unicode4: string, unicode8: string) => {\n if (unicode4) {\n const charCode = Number.parseInt(unicode4, 16);\n return String.fromCodePoint(charCode);\n }\n const charCode = Number.parseInt(unicode8, 16);\n if (charCode < 0xFFFF) {\n return String.fromCodePoint(charCode);\n }\n const substractedCharCode = charCode - 0x10000;\n return String.fromCodePoint(0xD800 + (substractedCharCode >> 10), 0xDC00 + (substractedCharCode & 0x3FF));\n },\n );\n // Test for invalid unicode surrogate pairs\n if (/[\\uD800-\\uDBFF]([^\\uDC00-\\uDFFF]|$)/u.test(input)) {\n throw new Error(`Invalid unicode codepoint of surrogate pair without corresponding codepoint`);\n }\n\n const lexResult = lexer.tokenize(input);\n // Console.log(lexResult.tokens);\n\n parser.reset();\n parser.input = lexResult.tokens;\n const result = parser[rule.name](...args);\n if (parser.errors.length > 0) {\n // Console.log(lexResult.tokens);\n throw new Error(`Parse error on line ${parser.errors.map(x => x.token.startLine).join(', ')}\n${parser.errors.map(x => `${x.token.startLine}: ${x.message}`).join('\\n')}`);\n }\n return result;\n });\n }\n return <ParserFromRules<Names, RuleDefs>> selfSufficientParser;\n }\n\n public consume({ tokenVocabulary, config = {}}: {\n tokenVocabulary: TokenVocabulary;\n config?: IParserConfig;\n }, context: Partial<ImplArgs['context']> = {}): EmbeddedActionsParser & ParseMethodsFromRules<Names, RuleDefs> {\n const rules = this.rules;\n class MyParser extends EmbeddedActionsParser {\n private readonly initialParseContext: ImplArgs['context'];\n private readonly runningContext: ImplArgs['context'];\n\n public constructor() {\n super(tokenVocabulary, {\n // RecoveryEnabled: true,\n maxLookahead: 2,\n // SkipValidations: true,\n ...config,\n });\n\n const selfRef = this.getSelfRef();\n // !!! Remember to change the RESET function accordingly !!!\n this.initialParseContext = {\n dataFactory: new DataFactory({ blankNodePrefix: 'g_' }),\n baseIRI: undefined,\n parseMode: new Set(),\n skipValidation: false,\n ...context,\n prefixes: context.prefixes ? { ...context.prefixes } : {},\n };\n this.runningContext = {\n ...this.initialParseContext,\n prefixes: { ...this.initialParseContext.prefixes },\n parseMode: new Set(this.initialParseContext.parseMode),\n };\n\n const implArgs: ImplArgs = {\n ...selfRef,\n cache: new WeakMap(),\n context: this.runningContext,\n };\n\n for (const rule of Object.values(<Record<string, RuleDef>>rules)) {\n this[<keyof (typeof this)> rule.name] = <any> this.RULE(rule.name, rule.impl(implArgs));\n }\n this.performSelfAnalysis();\n }\n\n public override reset(): void {\n super.reset();\n // We need to keep the original object reference.\n Object.assign(this.runningContext, {\n ...this.initialParseContext,\n });\n this.runningContext.prefixes = { ...this.initialParseContext.prefixes };\n this.runningContext.parseMode = new Set(this.initialParseContext.parseMode);\n }\n\n private getSelfRef(): CstDef {\n return {\n CONSUME: (tokenType, option) => this.CONSUME(tokenType, option),\n CONSUME1: (tokenType, option) => this.CONSUME1(tokenType, option),\n CONSUME2: (tokenType, option) => this.CONSUME2(tokenType, option),\n CONSUME3: (tokenType, option) => this.CONSUME3(tokenType, option),\n CONSUME4: (tokenType, option) => this.CONSUME4(tokenType, option),\n CONSUME5: (tokenType, option) => this.CONSUME5(tokenType, option),\n CONSUME6: (tokenType, option) => this.CONSUME6(tokenType, option),\n CONSUME7: (tokenType, option) => this.CONSUME7(tokenType, option),\n CONSUME8: (tokenType, option) => this.CONSUME8(tokenType, option),\n CONSUME9: (tokenType, option) => this.CONSUME9(tokenType, option),\n OPTION: actionORMethodDef => this.OPTION(actionORMethodDef),\n OPTION1: actionORMethodDef => this.OPTION1(actionORMethodDef),\n OPTION2: actionORMethodDef => this.OPTION2(actionORMethodDef),\n OPTION3: actionORMethodDef => this.OPTION3(actionORMethodDef),\n OPTION4: actionORMethodDef => this.OPTION4(actionORMethodDef),\n OPTION5: actionORMethodDef => this.OPTION5(actionORMethodDef),\n OPTION6: actionORMethodDef => this.OPTION6(actionORMethodDef),\n OPTION7: actionORMethodDef => this.OPTION7(actionORMethodDef),\n OPTION8: actionORMethodDef => this.OPTION8(actionORMethodDef),\n OPTION9: actionORMethodDef => this.OPTION9(actionORMethodDef),\n OR: altsOrOpts => this.OR(altsOrOpts),\n OR1: altsOrOpts => this.OR1(altsOrOpts),\n OR2: altsOrOpts => this.OR2(altsOrOpts),\n OR3: altsOrOpts => this.OR3(altsOrOpts),\n OR4: altsOrOpts => this.OR4(altsOrOpts),\n OR5: altsOrOpts => this.OR5(altsOrOpts),\n OR6: altsOrOpts => this.OR6(altsOrOpts),\n OR7: altsOrOpts => this.OR7(altsOrOpts),\n OR8: altsOrOpts => this.OR8(altsOrOpts),\n OR9: altsOrOpts => this.OR9(altsOrOpts),\n MANY: actionORMethodDef => this.MANY(actionORMethodDef),\n MANY1: actionORMethodDef => this.MANY1(actionORMethodDef),\n MANY2: actionORMethodDef => this.MANY2(actionORMethodDef),\n MANY3: actionORMethodDef => this.MANY3(actionORMethodDef),\n MANY4: actionORMethodDef => this.MANY4(actionORMethodDef),\n MANY5: actionORMethodDef => this.MANY5(actionORMethodDef),\n MANY6: actionORMethodDef => this.MANY6(actionORMethodDef),\n MANY7: actionORMethodDef => this.MANY7(actionORMethodDef),\n MANY8: actionORMethodDef => this.MANY8(actionORMethodDef),\n MANY9: actionORMethodDef => this.MANY9(actionORMethodDef),\n MANY_SEP: options => this.MANY_SEP(options),\n MANY_SEP1: options => this.MANY_SEP1(options),\n MANY_SEP2: options => this.MANY_SEP2(options),\n MANY_SEP3: options => this.MANY_SEP3(options),\n MANY_SEP4: options => this.MANY_SEP4(options),\n MANY_SEP5: options => this.MANY_SEP5(options),\n MANY_SEP6: options => this.MANY_SEP6(options),\n MANY_SEP7: options => this.MANY_SEP7(options),\n MANY_SEP8: options => this.MANY_SEP8(options),\n MANY_SEP9: options => this.MANY_SEP9(options),\n AT_LEAST_ONE: actionORMethodDef => this.AT_LEAST_ONE(actionORMethodDef),\n AT_LEAST_ONE1: actionORMethodDef => this.AT_LEAST_ONE1(actionORMethodDef),\n AT_LEAST_ONE2: actionORMethodDef => this.AT_LEAST_ONE2(actionORMethodDef),\n AT_LEAST_ONE3: actionORMethodDef => this.AT_LEAST_ONE3(actionORMethodDef),\n AT_LEAST_ONE4: actionORMethodDef => this.AT_LEAST_ONE4(actionORMethodDef),\n AT_LEAST_ONE5: actionORMethodDef => this.AT_LEAST_ONE5(actionORMethodDef),\n AT_LEAST_ONE6: actionORMethodDef => this.AT_LEAST_ONE6(actionORMethodDef),\n AT_LEAST_ONE7: actionORMethodDef => this.AT_LEAST_ONE7(actionORMethodDef),\n AT_LEAST_ONE8: actionORMethodDef => this.AT_LEAST_ONE8(actionORMethodDef),\n AT_LEAST_ONE9: actionORMethodDef => this.AT_LEAST_ONE9(actionORMethodDef),\n AT_LEAST_ONE_SEP: options => this.AT_LEAST_ONE_SEP(options),\n AT_LEAST_ONE_SEP1: options => this.AT_LEAST_ONE_SEP1(options),\n AT_LEAST_ONE_SEP2: options => this.AT_LEAST_ONE_SEP2(options),\n AT_LEAST_ONE_SEP3: options => this.AT_LEAST_ONE_SEP3(options),\n AT_LEAST_ONE_SEP4: options => this.AT_LEAST_ONE_SEP4(options),\n AT_LEAST_ONE_SEP5: options => this.AT_LEAST_ONE_SEP5(options),\n AT_LEAST_ONE_SEP6: options => this.AT_LEAST_ONE_SEP6(options),\n AT_LEAST_ONE_SEP7: options => this.AT_LEAST_ONE_SEP7(options),\n AT_LEAST_ONE_SEP8: options => this.AT_LEAST_ONE_SEP8(options),\n AT_LEAST_ONE_SEP9: options => this.AT_LEAST_ONE_SEP9(options),\n ACTION: func => this.ACTION(func),\n BACKTRACK: (cstDef, ...args) => {\n try {\n return this.BACKTRACK(<any> this[<keyof (typeof this)> cstDef.name], <any> { ARGS: args });\n } catch (error: unknown) {\n throw error;\n }\n },\n SUBRULE: (cstDef, ...args) => {\n try {\n return this.SUBRULE(<any> this[<keyof (typeof this)> cstDef.name], <any> { ARGS: args });\n } catch (error: unknown) {\n throw error;\n }\n },\n SUBRULE1: (cstDef, ...args) => {\n try {\n return this.SUBRULE1(<any> this[<keyof (typeof this)> cstDef.name], <any> { ARGS: args });\n } catch (error: unknown) {\n throw error;\n }\n },\n SUBRULE2: (cstDef, ...args) => {\n try {\n return this.SUBRULE2(<any> this[<keyof (typeof this)> cstDef.name], <any> { ARGS: args });\n } catch (error: unknown) {\n throw error;\n }\n },\n SUBRULE3: (cstDef, ...args) => {\n try {\n return this.SUBRULE3(<any> this[<keyof (typeof this)> cstDef.name], <any> { ARGS: args });\n } catch (error: unknown) {\n throw error;\n }\n },\n SUBRULE4: (cstDef, ...args) => {\n try {\n return this.SUBRULE4(<any> this[<keyof (typeof this)> cstDef.name], <any> { ARGS: args });\n } catch (error: unknown) {\n throw error;\n }\n },\n SUBRULE5: (cstDef, ...args) => {\n try {\n return this.SUBRULE5(<any> this[<keyof (typeof this)> cstDef.name], <any> { ARGS: args });\n } catch (error: unknown) {\n throw error;\n }\n },\n SUBRULE6: (cstDef, ...args) => {\n try {\n return this.SUBRULE6(<any> this[<keyof (typeof this)> cstDef.name], <any> { ARGS: args });\n } catch (error: unknown) {\n throw error;\n }\n },\n SUBRULE7: (cstDef, ...args) => {\n try {\n return this.SUBRULE7(<any> this[<keyof (typeof this)> cstDef.name], <any> { ARGS: args });\n } catch (error: unknown) {\n throw error;\n }\n },\n SUBRULE8: (cstDef, ...args) => {\n try {\n return this.SUBRULE8(<any> this[<keyof (typeof this)> cstDef.name], <any> { ARGS: args });\n } catch (error: unknown) {\n throw error;\n }\n },\n SUBRULE9: (cstDef, ...args) => {\n try {\n return this.SUBRULE9(<any> this[<keyof (typeof this)> cstDef.name], <any> { ARGS: args });\n } catch (error: unknown) {\n throw error;\n }\n },\n };\n }\n }\n return <EmbeddedActionsParser & ParseMethodsFromRules<Names, RuleDefs>><unknown> new MyParser();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"parserBuilder.js","sourceRoot":"","sources":["parserBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,qBAAqB,EAAE,KAAK,EAAC,MAAM,YAAY,CAAC;AAWxD;;GAEG;AACH,SAAS,gBAAgB,CAA+B,KAAQ;IAC9D,MAAM,QAAQ,GAA4B,EAAE,CAAC;IAC7C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC7B,CAAC;IACD,OAA4B,QAAQ,CAAC;AACvC,CAAC;AAED;;;;;GAKG;AACH,iDAAiD;AACjD,MAAM,OAAO,OAAO;IAClB;;;OAGG;IACI,MAAM,CAAC,aAAa,CAK3B,KAAgD;QAC9C,IAAI,KAAK,YAAY,OAAO,EAAE,CAAC;YAC7B,OAAO,IAAI,OAAO,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QACzC,CAAC;QACD,OAAqD,IAAI,OAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5F,CAAC;IAID,YAAoB,UAAoB;QACtC,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC;IAC1B,CAAC;IAED;;OAEG;IACI,SAAS,CAA6B,KAAqC;QAEhF,MAAM,IAAI,GACE,IAAI,C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QAAQ,EAAE,CAAC;IACxJ,CAAC;CACF","sourcesContent":["import {ILexerConfig, IParserConfig} from '@chevrotain/types';\nimport type {TokenType, TokenVocabulary} from 'chevrotain';\nimport {EmbeddedActionsParser, Lexer} from 'chevrotain';\nimport type {\n CheckOverlap,\n ParseMethodsFromRules,\n ParserFromRules,\n RuleDefMap,\n RuleListToObject,\n RuleNamesFromList,\n} from './builderTypes';\nimport type {CstDef, ImplArgs, RuleDef} from './ruleDefTypes';\n\n/**\n * Converts a list of ruledefs to a record mapping a name to the corresponding ruledef.\n */\nfunction listToRuleDefMap<T extends readonly RuleDef[]>(rules: T): RuleListToObject<T> {\n const newRules: Record<string, RuleDef> = {};\n for (const rule of rules) {\n newRules[rule.name] = rule;\n }\n return <RuleListToObject<T>>newRules;\n}\n\n/**\n * The grammar builder. This is the core of traqula (besides using the amazing chevrotain framework).\n * Using the builder you can create a grammar + AST creator.\n * At any point in time, a parser can be constructed from the added rules.\n * Constructing a parser will cause a validation which will validate the correctness of the grammar.\n */\n// This code is wild so other code can be simple.\nexport class Builder<Context, Names extends string, RuleDefs extends RuleDefMap<Names>> {\n /**\n * Create a builder from some initial grammar rules or an existing builder.\n * If a builder is provided, a new copy will be created.\n */\n public static createBuilder<\n Rules extends readonly RuleDef[] = readonly RuleDef[],\n Context = Rules[0] extends RuleDef<infer context> ? context : never,\n Names extends string = RuleNamesFromList<Rules>,\n RuleDefs extends RuleDefMap<Names> = RuleListToObject<Rules>,\n>(start: Rules | Builder<Context, Names, RuleDefs>): Builder<Context, Names, RuleDefs> {\n if (start instanceof Builder) {\n return new Builder({ ...start.rules });\n }\n return <Builder<Context, Names, RuleDefs>> <unknown> new Builder(listToRuleDefMap(start));\n }\n\n private rules: RuleDefs;\n\n private constructor(startRules: RuleDefs) {\n this.rules = startRules;\n }\n\n /**\n * Change the implementation of an existing grammar rule.\n */\n public patchRule<U extends Names, RET, ARGS>(patch: RuleDef<Context, U, RET, ARGS>):\n Builder<Context, Names, {[Key in Names]: Key extends U ? RuleDef<Context, Key, RET, ARGS> : (RuleDefs[Key] extends RuleDef<Context, Key> ? RuleDefs[Key] : never) }> {\n const self = <Builder<Context, Names, {[Key in Names]: Key extends U ? RuleDef<Context, Key, RET, ARGS> : (RuleDefs[Key] extends RuleDef<Context, Key> ? RuleDefs[Key] : never) }>>\n <unknown> this;\n self.rules[patch.name] = <any> patch;\n return self;\n }\n\n /**\n * Add a rule to the grammar. If the rule already exists, but the implementation differs, an error will be thrown.\n */\n public addRuleRedundant<U extends string, RET, ARGS>(rule: RuleDef<Context, U, RET, ARGS>):\n Builder<Context, Names | U, {[K in Names | U]: K extends U ? RuleDef<Context, K, RET, ARGS> : ( K extends Names ? (RuleDefs[K] extends RuleDef<Context, K> ? RuleDefs[K] : never ) : never) }> {\n const self = <Builder<Context, Names | U, {[K in Names | U]: K extends U ? RuleDef<Context, K, RET, ARGS> : ( K extends Names ? (RuleDefs[K] extends RuleDef<Context, K> ? RuleDefs[K] : never ) : never) }>>\n <unknown> this;\n const rules = <Record<string, RuleDef<Context>>> self.rules;\n if (rules[rule.name] !== undefined && rules[rule.name] !== rule) {\n throw new Error(`Rule ${rule.name} already exists in the builder`);\n }\n rules[rule.name] = rule;\n return self;\n }\n\n /**\n * Add a rule to the grammar. Will raise a typescript error if the rule already exists in the grammar.\n */\n public addRule<U extends string, RET, ARGS>(\n rule: CheckOverlap<U, Names, RuleDef<Context, U, RET, ARGS>>,\n ): Builder<Context, Names | U, {[K in Names | U]: K extends U ? RuleDef<Context, K, RET, ARGS> : ( K extends Names ? (RuleDefs[K] extends RuleDef<Context, K> ? RuleDefs[K] : never ) : never) }> {\n return this.addRuleRedundant(rule);\n }\n\n public addMany<U extends readonly RuleDef<Context>[]>(\n ...rules: CheckOverlap<RuleNamesFromList<U>, Names, U>\n ): Builder<\n Context,\n Names | RuleNamesFromList<U>,\n {[K in Names | RuleNamesFromList<U>]:\n K extends keyof RuleListToObject<typeof rules> ? (\n RuleListToObject<typeof rules>[K] extends RuleDef<Context, K> ? RuleListToObject<typeof rules>[K] : never\n ) : (\n K extends Names ? (RuleDefs[K] extends RuleDef<Context, K> ? RuleDefs[K] : never) : never\n )\n }> {\n this.rules = { ...this.rules, ...listToRuleDefMap(rules) };\n return <any> <unknown> this;\n }\n\n /**\n * Delete a grammar rule by its name.\n */\n public deleteRule<U extends Names>(ruleName: U):\n Builder<Context, Exclude<Names, U>, { [K in Exclude<Names, U>]: RuleDefs[K] extends RuleDef<Context, K> ? RuleDefs[K] : never }> {\n delete this.rules[ruleName];\n return <Builder<Context, Exclude<Names, U>, { [K in Exclude<Names, U>]: RuleDefs[K] extends RuleDef<Context, K> ? RuleDefs[K] : never }>>\n <unknown> this;\n }\n\n /**\n * Merge this grammar builder with another.\n * It is best to merge the bigger grammar with the smaller one.\n * If the two builders both have a grammar rule with the same name, no error will be thrown case they map to the same ruledef object.\n * If they map to a different object, an error will be thrown.\n * To fix this problem, the overridingRules array should contain a rule with the same conflicting name, this rule implementation will be used.\n */\n public merge<OtherNames extends string, OtherRules extends RuleDefMap<OtherNames>, OW extends readonly RuleDef<Context>[]>(\n builder: Builder<Context, OtherNames, OtherRules>,\n overridingRules: OW,\n ):\n Builder<\n Context,\n Names | OtherNames | RuleNamesFromList<OW>,\n {[K in Names | OtherNames | RuleNamesFromList<OW>]:\n K extends keyof RuleListToObject<OW> ? (\n RuleListToObject<OW>[K] extends RuleDef<Context, K> ? RuleListToObject<OW>[K] : never\n )\n : (\n K extends Names ? (RuleDefs[K] extends RuleDef<Context, K> ? RuleDefs[K] : never)\n : K extends OtherNames ? (OtherRules[K] extends RuleDef<Context, K> ? OtherRules[K] : never) : never\n )}> {\n // Assume the other grammar is bigger than yours. So start from that one and add this one\n const otherRules: Record<string, RuleDef<Context>> = { ...builder.rules };\n const myRules: Record<string, RuleDef<Context>> = this.rules;\n\n for (const rule of Object.values(myRules)) {\n if (otherRules[rule.name] === undefined) {\n otherRules[rule.name] = rule;\n } else {\n const existingRule = otherRules[rule.name];\n // If same rule, no issue, move on. Else\n if (existingRule !== rule) {\n const override = overridingRules.find(x => x.name === rule.name);\n // If override specified, take override, else, inform user that there is a conflict\n if (override) {\n otherRules[rule.name] = override;\n } else {\n throw new Error(`Rule with name \"${rule.name}\" already exists in the builder, specify an override to resolve conflict`);\n }\n }\n }\n }\n\n this.rules = <any> <unknown> otherRules;\n return <any> <unknown> this;\n }\n\n public consumeToParser({ tokenVocabulary, parserConfig = {}, lexerConfig = {}}: {\n tokenVocabulary: TokenType[];\n parserConfig?: IParserConfig;\n lexerConfig?: ILexerConfig;\n }): ParserFromRules<Context, Names, RuleDefs> {\n const lexer: Lexer = new Lexer(tokenVocabulary, {\n positionTracking: 'onlyStart',\n recoveryEnabled: false,\n // SafeMode: true,\n // SkipValidations: true,\n ensureOptimizations: true,\n ...lexerConfig,\n });\n // get the chevrotain parser\n const parser = this.consume({ tokenVocabulary, config: parserConfig });\n // Start building a parser that does not pass input using a state, but instead gets it as a function argument.\n const selfSufficientParser: Partial<ParserFromRules<Context, Names, RuleDefs>> = {};\n // To do that, we need to create a wrapper for each parser rule.\n for (const rule of <RuleDef<Context, Names>[]> Object.values(this.rules)) {\n selfSufficientParser[rule.name] = <any> ((input: string, context: Context, arg: unknown) => {\n // Transform input in accordance to 19.2\n input = input.replaceAll(\n /\\\\u([0-9a-fA-F]{4})|\\\\U([0-9a-fA-F]{8})/gu,\n (_, unicode4: string, unicode8: string) => {\n if (unicode4) {\n const charCode = Number.parseInt(unicode4, 16);\n return String.fromCodePoint(charCode);\n }\n const charCode = Number.parseInt(unicode8, 16);\n if (charCode < 0xFFFF) {\n return String.fromCodePoint(charCode);\n }\n const substractedCharCode = charCode - 0x10000;\n return String.fromCodePoint(0xD800 + (substractedCharCode >> 10), 0xDC00 + (substractedCharCode & 0x3FF));\n },\n );\n // Test for invalid unicode surrogate pairs\n if (/[\\uD800-\\uDBFF]([^\\uDC00-\\uDFFF]|$)/u.test(input)) {\n throw new Error(`Invalid unicode codepoint of surrogate pair without corresponding codepoint`);\n }\n\n const lexResult = lexer.tokenize(input);\n\n // This also resets the parser\n parser.input = lexResult.tokens;\n parser.setContext(context);\n const result = parser[rule.name](context, arg);\n if (parser.errors.length > 0) {\n // Console.log(lexResult.tokens);\n throw new Error(`Parse error on line ${parser.errors.map(x => x.token.startLine).join(', ')}\n${parser.errors.map(x => `${x.token.startLine}: ${x.message}`).join('\\n')}`);\n }\n return result;\n });\n }\n return <ParserFromRules<Context, Names, RuleDefs>> selfSufficientParser;\n }\n\n public consume({ tokenVocabulary, config = {}}: {\n tokenVocabulary: TokenVocabulary;\n config?: IParserConfig;\n }): EmbeddedActionsParser & ParseMethodsFromRules<Context, Names, RuleDefs> & { setContext: (context: Context) => void } {\n const rules = this.rules;\n class MyParser extends EmbeddedActionsParser {\n private context: Context | undefined;\n\n private getSafeContext(): Context {\n if (this.context === undefined) {\n throw new Error('context was not correctly set');\n }\n return this.context;\n }\n\n public setContext(context: Context): void {\n this.context = context;\n }\n\n public constructor() {\n super(tokenVocabulary, {\n // RecoveryEnabled: true,\n maxLookahead: 2,\n // SkipValidations: true,\n ...config,\n });\n this.context = undefined;\n const selfRef = this.getSelfRef();\n const implArgs: ImplArgs = {\n ...selfRef,\n cache: new WeakMap(),\n };\n\n for (const rule of Object.values(<Record<string, RuleDef<Context>>>rules)) {\n this[<keyof (typeof this)> rule.name] = <any> this.RULE(rule.name, rule.impl(implArgs));\n }\n this.performSelfAnalysis();\n }\n\n private getSelfRef(): CstDef {\n const subRuleImpl = (chevrotainSubrule: typeof this.SUBRULE): CstDef['SUBRULE'] => {\n return ((cstDef, arg) => {\n return chevrotainSubrule(<any> this[<keyof (typeof this)> cstDef.name], <any> { ARGS: [this.context, arg] });\n }) satisfies CstDef['SUBRULE'];\n }\n return {\n CONSUME: (tokenType, option) => this.CONSUME(tokenType, option),\n CONSUME1: (tokenType, option) => this.CONSUME1(tokenType, option),\n CONSUME2: (tokenType, option) => this.CONSUME2(tokenType, option),\n CONSUME3: (tokenType, option) => this.CONSUME3(tokenType, option),\n CONSUME4: (tokenType, option) => this.CONSUME4(tokenType, option),\n CONSUME5: (tokenType, option) => this.CONSUME5(tokenType, option),\n CONSUME6: (tokenType, option) => this.CONSUME6(tokenType, option),\n CONSUME7: (tokenType, option) => this.CONSUME7(tokenType, option),\n CONSUME8: (tokenType, option) => this.CONSUME8(tokenType, option),\n CONSUME9: (tokenType, option) => this.CONSUME9(tokenType, option),\n OPTION: actionORMethodDef => this.OPTION(actionORMethodDef),\n OPTION1: actionORMethodDef => this.OPTION1(actionORMethodDef),\n OPTION2: actionORMethodDef => this.OPTION2(actionORMethodDef),\n OPTION3: actionORMethodDef => this.OPTION3(actionORMethodDef),\n OPTION4: actionORMethodDef => this.OPTION4(actionORMethodDef),\n OPTION5: actionORMethodDef => this.OPTION5(actionORMethodDef),\n OPTION6: actionORMethodDef => this.OPTION6(actionORMethodDef),\n OPTION7: actionORMethodDef => this.OPTION7(actionORMethodDef),\n OPTION8: actionORMethodDef => this.OPTION8(actionORMethodDef),\n OPTION9: actionORMethodDef => this.OPTION9(actionORMethodDef),\n OR: altsOrOpts => this.OR(altsOrOpts),\n OR1: altsOrOpts => this.OR1(altsOrOpts),\n OR2: altsOrOpts => this.OR2(altsOrOpts),\n OR3: altsOrOpts => this.OR3(altsOrOpts),\n OR4: altsOrOpts => this.OR4(altsOrOpts),\n OR5: altsOrOpts => this.OR5(altsOrOpts),\n OR6: altsOrOpts => this.OR6(altsOrOpts),\n OR7: altsOrOpts => this.OR7(altsOrOpts),\n OR8: altsOrOpts => this.OR8(altsOrOpts),\n OR9: altsOrOpts => this.OR9(altsOrOpts),\n MANY: actionORMethodDef => this.MANY(actionORMethodDef),\n MANY1: actionORMethodDef => this.MANY1(actionORMethodDef),\n MANY2: actionORMethodDef => this.MANY2(actionORMethodDef),\n MANY3: actionORMethodDef => this.MANY3(actionORMethodDef),\n MANY4: actionORMethodDef => this.MANY4(actionORMethodDef),\n MANY5: actionORMethodDef => this.MANY5(actionORMethodDef),\n MANY6: actionORMethodDef => this.MANY6(actionORMethodDef),\n MANY7: actionORMethodDef => this.MANY7(actionORMethodDef),\n MANY8: actionORMethodDef => this.MANY8(actionORMethodDef),\n MANY9: actionORMethodDef => this.MANY9(actionORMethodDef),\n MANY_SEP: options => this.MANY_SEP(options),\n MANY_SEP1: options => this.MANY_SEP1(options),\n MANY_SEP2: options => this.MANY_SEP2(options),\n MANY_SEP3: options => this.MANY_SEP3(options),\n MANY_SEP4: options => this.MANY_SEP4(options),\n MANY_SEP5: options => this.MANY_SEP5(options),\n MANY_SEP6: options => this.MANY_SEP6(options),\n MANY_SEP7: options => this.MANY_SEP7(options),\n MANY_SEP8: options => this.MANY_SEP8(options),\n MANY_SEP9: options => this.MANY_SEP9(options),\n AT_LEAST_ONE: actionORMethodDef => this.AT_LEAST_ONE(actionORMethodDef),\n AT_LEAST_ONE1: actionORMethodDef => this.AT_LEAST_ONE1(actionORMethodDef),\n AT_LEAST_ONE2: actionORMethodDef => this.AT_LEAST_ONE2(actionORMethodDef),\n AT_LEAST_ONE3: actionORMethodDef => this.AT_LEAST_ONE3(actionORMethodDef),\n AT_LEAST_ONE4: actionORMethodDef => this.AT_LEAST_ONE4(actionORMethodDef),\n AT_LEAST_ONE5: actionORMethodDef => this.AT_LEAST_ONE5(actionORMethodDef),\n AT_LEAST_ONE6: actionORMethodDef => this.AT_LEAST_ONE6(actionORMethodDef),\n AT_LEAST_ONE7: actionORMethodDef => this.AT_LEAST_ONE7(actionORMethodDef),\n AT_LEAST_ONE8: actionORMethodDef => this.AT_LEAST_ONE8(actionORMethodDef),\n AT_LEAST_ONE9: actionORMethodDef => this.AT_LEAST_ONE9(actionORMethodDef),\n AT_LEAST_ONE_SEP: options => this.AT_LEAST_ONE_SEP(options),\n AT_LEAST_ONE_SEP1: options => this.AT_LEAST_ONE_SEP1(options),\n AT_LEAST_ONE_SEP2: options => this.AT_LEAST_ONE_SEP2(options),\n AT_LEAST_ONE_SEP3: options => this.AT_LEAST_ONE_SEP3(options),\n AT_LEAST_ONE_SEP4: options => this.AT_LEAST_ONE_SEP4(options),\n AT_LEAST_ONE_SEP5: options => this.AT_LEAST_ONE_SEP5(options),\n AT_LEAST_ONE_SEP6: options => this.AT_LEAST_ONE_SEP6(options),\n AT_LEAST_ONE_SEP7: options => this.AT_LEAST_ONE_SEP7(options),\n AT_LEAST_ONE_SEP8: options => this.AT_LEAST_ONE_SEP8(options),\n AT_LEAST_ONE_SEP9: options => this.AT_LEAST_ONE_SEP9(options),\n ACTION: func => this.ACTION(func),\n BACKTRACK: (cstDef, ...args) => {\n try {\n return this.BACKTRACK(<any> this[<keyof (typeof this)> cstDef.name], <any> { ARGS: args });\n } catch (error: unknown) {\n throw error;\n }\n },\n SUBRULE: subRuleImpl((rule, args) => this.SUBRULE(rule, args)),\n SUBRULE1: subRuleImpl((rule, args) => this.SUBRULE1(rule, args)),\n SUBRULE2: subRuleImpl((rule, args) => this.SUBRULE2(rule, args)),\n SUBRULE3: subRuleImpl((rule, args) => this.SUBRULE3(rule, args)),\n SUBRULE4: subRuleImpl((rule, args) => this.SUBRULE4(rule, args)),\n SUBRULE5: subRuleImpl((rule, args) => this.SUBRULE5(rule, args)),\n SUBRULE6: subRuleImpl((rule, args) => this.SUBRULE6(rule, args)),\n SUBRULE7: subRuleImpl((rule, args) => this.SUBRULE7(rule, args)),\n SUBRULE8: subRuleImpl((rule, args) => this.SUBRULE8(rule, args)),\n SUBRULE9: subRuleImpl((rule, args) => this.SUBRULE9(rule, args)),\n };\n }\n }\n return <EmbeddedActionsParser & ParseMethodsFromRules<Context, Names, RuleDefs> & { setContext: (context: Context) => void }><unknown> new MyParser();\n }\n}\n"]}
|
|
@@ -1,37 +1,53 @@
|
|
|
1
1
|
import type { AtLeastOneSepMethodOpts, DSLMethodOpts, DSLMethodOptsWithErr, GrammarAction, IOrAlt, ManySepMethodOpts, OrMethodOpts } from '@chevrotain/types';
|
|
2
|
-
import type * as RDF from '@rdfjs/types';
|
|
3
2
|
import type { ConsumeMethodOpts, IToken, TokenType } from 'chevrotain';
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Get the return-type of a RuleDef
|
|
5
|
+
*/
|
|
6
|
+
export type RuleDefReturn<T extends RuleDef> = T extends RuleDef<any, string, infer Ret> ? Ret : never;
|
|
7
|
+
/**
|
|
8
|
+
* Type used to declare grammar rules.
|
|
9
|
+
*/
|
|
10
|
+
export type RuleDef<
|
|
11
|
+
/**
|
|
12
|
+
* Context object available in rule implementation.
|
|
13
|
+
*/
|
|
14
|
+
Context = any,
|
|
15
|
+
/**
|
|
16
|
+
* Name of grammar rule, should be a strict subtype of string like 'myGrammarRule'.
|
|
17
|
+
*/
|
|
18
|
+
NameType extends string = string,
|
|
19
|
+
/**
|
|
20
|
+
* Type that will be returned after a correct parse of this rule.
|
|
21
|
+
* This type will be the return type of calling SUBRULE with this grammar rule.
|
|
22
|
+
*/
|
|
23
|
+
ReturnType = unknown,
|
|
24
|
+
/**
|
|
25
|
+
* Function arguments that can be given to convey the state of the current parse operation.
|
|
26
|
+
*/
|
|
27
|
+
ParamType = any> = {
|
|
6
28
|
name: NameType;
|
|
7
|
-
impl: (def: ImplArgs) => (
|
|
29
|
+
impl: (def: ImplArgs) => (context: Context, params: ParamType) => ReturnType;
|
|
8
30
|
};
|
|
9
|
-
|
|
10
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Type expected by grammar rules in the main `impl` function.
|
|
33
|
+
*/
|
|
11
34
|
export interface ImplArgs extends CstDef {
|
|
12
35
|
cache: WeakMap<RuleDef, unknown>;
|
|
13
|
-
context: {
|
|
14
|
-
dataFactory: DataFactory<RDF.BaseQuad>;
|
|
15
|
-
/**
|
|
16
|
-
* Current scoped prefixes. Used for resolving prefixed names.
|
|
17
|
-
*/
|
|
18
|
-
prefixes: Record<string, string>;
|
|
19
|
-
/**
|
|
20
|
-
* The base IRI for the query. Used for resolving relative IRIs.
|
|
21
|
-
*/
|
|
22
|
-
baseIRI: string | undefined;
|
|
23
|
-
/**
|
|
24
|
-
* Can be used to disable the validation that used variables in a select clause are in scope.
|
|
25
|
-
*/
|
|
26
|
-
skipValidation: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Set of queryModes. Primarily used for note 8, 14.
|
|
29
|
-
*/
|
|
30
|
-
parseMode: Set<symbol>;
|
|
31
|
-
};
|
|
32
36
|
}
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Type definition used by {@link CstDef.SUBRULE} and family.
|
|
39
|
+
*/
|
|
40
|
+
type SubRuleFunc = <T extends string, U = unknown, ARGS = any>(cstDef: RuleDef<any, T, U, ARGS>, argument: ARGS) => U;
|
|
41
|
+
/**
|
|
42
|
+
* Type definition used by {@link CstDef.BACKTRACK}.
|
|
43
|
+
*/
|
|
44
|
+
type BacktrackFunc = <T extends string, U = unknown, ARGS = any>(cstDef: RuleDef<any, T, U, ARGS>, argument: ARGS) => () => boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Mainly a repetition of the functions exposed by the {@link EmbeddedActionsParser},
|
|
47
|
+
* with some small adjustments that allow for the API changes made by traqula.
|
|
48
|
+
* Specifically changes are made to the {@link CstDef.SUBRULE} (and family) interface,
|
|
49
|
+
* and to the {@link CstDef.BACKTRACK} interface.
|
|
50
|
+
*/
|
|
35
51
|
export interface CstDef {
|
|
36
52
|
/**
|
|
37
53
|
*
|
|
@@ -303,7 +319,7 @@ export interface CstDef {
|
|
|
303
319
|
*
|
|
304
320
|
* @param options - An object defining the grammar of each iteration and the separator between iterations
|
|
305
321
|
*
|
|
306
|
-
* @return
|
|
322
|
+
* @return ISeparatedIterationResult<OUT>
|
|
307
323
|
*/
|
|
308
324
|
AT_LEAST_ONE_SEP: (options: AtLeastOneSepMethodOpts<any>) => void;
|
|
309
325
|
AT_LEAST_ONE_SEP1: (options: AtLeastOneSepMethodOpts<any>) => void;
|