@traqula/core 0.0.1-alpha.10
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.txt +22 -0
- package/README.md +137 -0
- package/lib/CoreFactory.d.ts +39 -0
- package/lib/CoreFactory.js +135 -0
- package/lib/CoreFactory.js.map +1 -0
- package/lib/Transformer.d.ts +26 -0
- package/lib/Transformer.js +57 -0
- package/lib/Transformer.js.map +1 -0
- package/lib/generator-builder/builderTypes.d.ts +20 -0
- package/lib/generator-builder/builderTypes.js +2 -0
- package/lib/generator-builder/builderTypes.js.map +1 -0
- package/lib/generator-builder/dynamicGenerator.d.ts +22 -0
- package/lib/generator-builder/dynamicGenerator.js +115 -0
- package/lib/generator-builder/dynamicGenerator.js.map +1 -0
- package/lib/generator-builder/generatorBuilder.d.ts +60 -0
- package/lib/generator-builder/generatorBuilder.js +104 -0
- package/lib/generator-builder/generatorBuilder.js.map +1 -0
- package/lib/generator-builder/generatorTypes.d.ts +36 -0
- package/lib/generator-builder/generatorTypes.js +2 -0
- package/lib/generator-builder/generatorTypes.js.map +1 -0
- package/lib/index.cjs +10121 -0
- package/lib/index.d.ts +13 -0
- package/lib/index.js +19 -0
- package/lib/index.js.map +1 -0
- package/lib/indirection-builder/IndirBuilder.d.ts +43 -0
- package/lib/indirection-builder/IndirBuilder.js +60 -0
- package/lib/indirection-builder/IndirBuilder.js.map +1 -0
- package/lib/indirection-builder/dynamicIndirected.d.ts +9 -0
- package/lib/indirection-builder/dynamicIndirected.js +28 -0
- package/lib/indirection-builder/dynamicIndirected.js.map +1 -0
- package/lib/indirection-builder/helpers.d.ts +24 -0
- package/lib/indirection-builder/helpers.js +11 -0
- package/lib/indirection-builder/helpers.js.map +1 -0
- package/lib/lexer-builder/LexerBuilder.d.ts +23 -0
- package/lib/lexer-builder/LexerBuilder.js +96 -0
- package/lib/lexer-builder/LexerBuilder.js.map +1 -0
- package/lib/nodeTypings.d.ts +53 -0
- package/lib/nodeTypings.js +2 -0
- package/lib/nodeTypings.js.map +1 -0
- package/lib/parser-builder/builderTypes.d.ts +26 -0
- package/lib/parser-builder/builderTypes.js +2 -0
- package/lib/parser-builder/builderTypes.js.map +1 -0
- package/lib/parser-builder/dynamicParser.d.ts +9 -0
- package/lib/parser-builder/dynamicParser.js +113 -0
- package/lib/parser-builder/dynamicParser.js.map +1 -0
- package/lib/parser-builder/parserBuilder.d.ts +74 -0
- package/lib/parser-builder/parserBuilder.js +171 -0
- package/lib/parser-builder/parserBuilder.js.map +1 -0
- package/lib/parser-builder/ruleDefTypes.d.ts +347 -0
- package/lib/parser-builder/ruleDefTypes.js +2 -0
- package/lib/parser-builder/ruleDefTypes.js.map +1 -0
- package/lib/utils.d.ts +17 -0
- package/lib/utils.js +8 -0
- package/lib/utils.js.map +1 -0
- package/package.json +47 -0
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './generator-builder/builderTypes';
|
|
2
|
+
export * from './generator-builder/generatorBuilder';
|
|
3
|
+
export * from './generator-builder/generatorTypes';
|
|
4
|
+
export * from './indirection-builder/helpers';
|
|
5
|
+
export * from './indirection-builder/IndirBuilder';
|
|
6
|
+
export * from './lexer-builder/LexerBuilder';
|
|
7
|
+
export * from './parser-builder/builderTypes';
|
|
8
|
+
export * from './parser-builder/parserBuilder';
|
|
9
|
+
export * from './parser-builder/ruleDefTypes';
|
|
10
|
+
export * from './utils';
|
|
11
|
+
export * from './CoreFactory';
|
|
12
|
+
export * from './nodeTypings';
|
|
13
|
+
export * from './Transformer';
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Export generator builder
|
|
2
|
+
export * from './generator-builder/builderTypes';
|
|
3
|
+
export * from './generator-builder/generatorBuilder';
|
|
4
|
+
export * from './generator-builder/generatorTypes';
|
|
5
|
+
// Export Indirection Builder
|
|
6
|
+
export * from './indirection-builder/helpers';
|
|
7
|
+
export * from './indirection-builder/IndirBuilder';
|
|
8
|
+
// Export lexer builder
|
|
9
|
+
export * from './lexer-builder/LexerBuilder';
|
|
10
|
+
// Export parser builder
|
|
11
|
+
export * from './parser-builder/builderTypes';
|
|
12
|
+
export * from './parser-builder/parserBuilder';
|
|
13
|
+
export * from './parser-builder/ruleDefTypes';
|
|
14
|
+
// Export general types
|
|
15
|
+
export * from './utils';
|
|
16
|
+
export * from './CoreFactory';
|
|
17
|
+
export * from './nodeTypings';
|
|
18
|
+
export * from './Transformer';
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC;AACnD,6BAA6B;AAC7B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oCAAoC,CAAC;AACnD,uBAAuB;AACvB,cAAc,8BAA8B,CAAC;AAC7C,wBAAwB;AACxB,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,uBAAuB;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC","sourcesContent":["// Export generator builder\nexport * from './generator-builder/builderTypes';\nexport * from './generator-builder/generatorBuilder';\nexport * from './generator-builder/generatorTypes';\n// Export Indirection Builder\nexport * from './indirection-builder/helpers';\nexport * from './indirection-builder/IndirBuilder';\n// Export lexer builder\nexport * from './lexer-builder/LexerBuilder';\n// Export parser builder\nexport * from './parser-builder/builderTypes';\nexport * from './parser-builder/parserBuilder';\nexport * from './parser-builder/ruleDefTypes';\n// Export general types\nexport * from './utils';\nexport * from './CoreFactory';\nexport * from './nodeTypings';\nexport * from './Transformer';\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ParseNamesFromList } from '../parser-builder/builderTypes';
|
|
2
|
+
import type { CheckOverlap } from '../utils';
|
|
3
|
+
import type { IndirDef, IndirectionMap, IndirectObjFromIndirDefs, ParseIndirsToObject } from './helpers';
|
|
4
|
+
export declare class IndirBuilder<Context, Names extends string, RuleDefs extends IndirectionMap<Names>> {
|
|
5
|
+
static create<Context, Names extends string, RuleDefs extends IndirectionMap<Names>>(args: IndirBuilder<Context, Names, RuleDefs>): IndirBuilder<Context, Names, RuleDefs>;
|
|
6
|
+
static create<Rules extends readonly IndirDef[] = readonly IndirDef[], Context = Rules[0] extends IndirDef<infer context> ? context : never, Names extends string = ParseNamesFromList<Rules>, RuleDefs extends IndirectionMap<Names> = ParseIndirsToObject<Rules>>(rules: Rules): IndirBuilder<Context, Names, RuleDefs>;
|
|
7
|
+
private rules;
|
|
8
|
+
private constructor();
|
|
9
|
+
widenContext<NewContext extends Context>(): IndirBuilder<NewContext, Names, RuleDefs>;
|
|
10
|
+
typePatch<Patch extends {
|
|
11
|
+
[Key in Names]?: any;
|
|
12
|
+
}>(): IndirBuilder<Context, Names, {
|
|
13
|
+
[Key in Names]: Key extends keyof Patch ? (IndirDef<Context, Key, Patch[Key][0], Patch[Key][1]>) : (RuleDefs[Key] extends IndirDef<Context, Key> ? RuleDefs[Key] : never);
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Change the implementation of an existing indirection.
|
|
17
|
+
*/
|
|
18
|
+
patchRule<U extends Names, RET, ARGS extends any[]>(patch: IndirDef<Context, U, RET, ARGS>): IndirBuilder<Context, Names, {
|
|
19
|
+
[Key in Names]: Key extends U ? IndirDef<Context, Key, RET, ARGS> : (RuleDefs[Key] extends IndirDef<Context, Key> ? RuleDefs[Key] : never);
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* Add an indirection function. If the rule already exists, but the implementation differs, an error will be thrown.
|
|
23
|
+
*/
|
|
24
|
+
addRuleRedundant<U extends string, RET, ARGS extends any[]>(rule: IndirDef<Context, U, RET, ARGS>): IndirBuilder<Context, Names | U, {
|
|
25
|
+
[K in Names | U]: K extends U ? IndirDef<Context, K, RET, ARGS> : (K extends Names ? (RuleDefs[K] extends IndirDef<Context, K> ? RuleDefs[K] : never) : never);
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Add a rule to the grammar. Will raise a typescript error if the rule already exists in the grammar.
|
|
29
|
+
*/
|
|
30
|
+
addRule<U extends string, RET, ARGS extends any[]>(rule: CheckOverlap<U, Names, IndirDef<Context, U, RET, ARGS>>): IndirBuilder<Context, Names | U, {
|
|
31
|
+
[K in Names | U]: K extends U ? IndirDef<Context, K, RET, ARGS> : (K extends Names ? (RuleDefs[K] extends IndirDef<Context, K> ? RuleDefs[K] : never) : never);
|
|
32
|
+
}>;
|
|
33
|
+
addMany<U extends readonly IndirDef<Context>[]>(...rules: CheckOverlap<ParseNamesFromList<U>, Names, U>): IndirBuilder<Context, Names | ParseNamesFromList<U>, {
|
|
34
|
+
[K in Names | ParseNamesFromList<U>]: K extends keyof ParseIndirsToObject<typeof rules> ? (ParseIndirsToObject<typeof rules>[K] extends IndirDef<Context, K> ? ParseIndirsToObject<typeof rules>[K] : never) : (K extends Names ? (RuleDefs[K] extends IndirDef<Context, K> ? RuleDefs[K] : never) : never);
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* Delete a grammar rule by its name.
|
|
38
|
+
*/
|
|
39
|
+
deleteRule<U extends Names>(ruleName: U): IndirBuilder<Context, Exclude<Names, U>, {
|
|
40
|
+
[K in Exclude<Names, U>]: RuleDefs[K] extends IndirDef<Context, K> ? RuleDefs[K] : never;
|
|
41
|
+
}>;
|
|
42
|
+
build(): IndirectObjFromIndirDefs<Context, Names, RuleDefs>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { DynamicIndirect } from './dynamicIndirected';
|
|
2
|
+
import { listToIndirectionMap } from './helpers';
|
|
3
|
+
export class IndirBuilder {
|
|
4
|
+
static create(start) {
|
|
5
|
+
if (start instanceof IndirBuilder) {
|
|
6
|
+
return new IndirBuilder({ ...start.rules });
|
|
7
|
+
}
|
|
8
|
+
return new IndirBuilder(listToIndirectionMap(start));
|
|
9
|
+
}
|
|
10
|
+
constructor(startRules) {
|
|
11
|
+
this.rules = startRules;
|
|
12
|
+
}
|
|
13
|
+
widenContext() {
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
typePatch() {
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Change the implementation of an existing indirection.
|
|
21
|
+
*/
|
|
22
|
+
patchRule(patch) {
|
|
23
|
+
const self = this;
|
|
24
|
+
self.rules[patch.name] = patch;
|
|
25
|
+
return self;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Add an indirection function. If the rule already exists, but the implementation differs, an error will be thrown.
|
|
29
|
+
*/
|
|
30
|
+
addRuleRedundant(rule) {
|
|
31
|
+
const self = this;
|
|
32
|
+
const rules = self.rules;
|
|
33
|
+
if (rules[rule.name] !== undefined && rules[rule.name] !== rule) {
|
|
34
|
+
throw new Error(`Function ${rule.name} already exists in the builder`);
|
|
35
|
+
}
|
|
36
|
+
rules[rule.name] = rule;
|
|
37
|
+
return self;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Add a rule to the grammar. Will raise a typescript error if the rule already exists in the grammar.
|
|
41
|
+
*/
|
|
42
|
+
addRule(rule) {
|
|
43
|
+
return this.addRuleRedundant(rule);
|
|
44
|
+
}
|
|
45
|
+
addMany(...rules) {
|
|
46
|
+
this.rules = { ...this.rules, ...listToIndirectionMap(rules) };
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Delete a grammar rule by its name.
|
|
51
|
+
*/
|
|
52
|
+
deleteRule(ruleName) {
|
|
53
|
+
delete this.rules[ruleName];
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
build() {
|
|
57
|
+
return new DynamicIndirect(this.rules);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=IndirBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IndirBuilder.js","sourceRoot":"","sources":["IndirBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEjD,MAAM,OAAO,YAAY;IAUhB,MAAM,CAAC,MAAM,CAMlB,KAAqD;QAErD,IAAI,KAAK,YAAY,YAAY,EAAE,CAAC;YAClC,OAAO,IAAI,YAAY,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QAC9C,CAAC;QACD,OAA0D,IAAI,YAAY,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;IAC1G,CAAC;IAID,YAAoB,UAAoB;QACtC,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC;IAC1B,CAAC;IAEM,YAAY;QACjB,OAA6D,IAAI,CAAC;IACpE,CAAC;IAEM,SAAS;QAId,OAEyF,IAAI,CAAC;IAChG,CAAC;IAED;;OAEG;IACI,SAAS,CAA2C,KAAsC;QAK/F,MAAM,IAAI,GAEE,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAS,KAAK,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACI,gBAAgB,CAA4C,IAAqC;QAKtG,MAAM,IAAI,GAGE,IAAI,CAAC;QACjB,MAAM,KAAK,GAAuC,IAAI,CAAC,KAAK,CAAC;QAC7D,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YAChE,MAAM,IAAI,KAAK,CAAC,YAAY,IAAI,CAAC,IAAI,gCAAgC,CAAC,CAAC;QACzE,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACI,OAAO,CACZ,IAA6D;QAI7D,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAEM,OAAO,CACZ,GAAG,KAAoD;QAYvD,IAAI,CAAC,KAAK,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,GAAG,oBAAoB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/D,OAAuB,IAAI,CAAC;IAC9B,CAAC;IAED;;OAEG;IACI,UAAU,CAAkB,QAAW;QAG5C,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC5B,OAEY,IAAI,CAAC;IACnB,CAAC;IAEM,KAAK;QACV,OAA4D,IAAI,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9F,CAAC;CACF","sourcesContent":["import type { ParseNamesFromList } from '../parser-builder/builderTypes';\nimport type { CheckOverlap } from '../utils';\nimport { DynamicIndirect } from './dynamicIndirected';\nimport type { IndirDef, IndirectionMap, IndirectObjFromIndirDefs, ParseIndirsToObject } from './helpers';\nimport { listToIndirectionMap } from './helpers';\n\nexport class IndirBuilder<Context, Names extends string, RuleDefs extends IndirectionMap<Names>> {\n public static create<Context, Names extends string, RuleDefs extends IndirectionMap<Names>>(\n args: IndirBuilder<Context, Names, RuleDefs>\n ): IndirBuilder<Context, Names, RuleDefs>;\n public static create<\n Rules extends readonly IndirDef[] = readonly IndirDef[],\n Context = Rules[0] extends IndirDef<infer context> ? context : never,\n Names extends string = ParseNamesFromList<Rules>,\n RuleDefs extends IndirectionMap<Names> = ParseIndirsToObject<Rules>,\n >(rules: Rules): IndirBuilder<Context, Names, RuleDefs>;\n public static create<\n Rules extends readonly IndirDef[] = readonly IndirDef[],\n Context = Rules[0] extends IndirDef<infer context> ? context : never,\n Names extends string = ParseNamesFromList<Rules>,\n RuleDefs extends IndirectionMap<Names> = ParseIndirsToObject<Rules>,\n >(\n start: Rules | IndirBuilder<Context, Names, RuleDefs>,\n ): IndirBuilder<Context, Names, RuleDefs> {\n if (start instanceof IndirBuilder) {\n return new IndirBuilder({ ...start.rules });\n }\n return <IndirBuilder<Context, Names, RuleDefs>> <unknown> new IndirBuilder(listToIndirectionMap(start));\n }\n\n private rules: RuleDefs;\n\n private constructor(startRules: RuleDefs) {\n this.rules = startRules;\n }\n\n public widenContext<NewContext extends Context>(): IndirBuilder<NewContext, Names, RuleDefs> {\n return <IndirBuilder<NewContext, Names, RuleDefs>> <unknown> this;\n }\n\n public typePatch<Patch extends {[Key in Names]?: any }>():\n IndirBuilder<Context, Names, {[Key in Names]: Key extends keyof Patch ? (\n IndirDef<Context, Key, Patch[Key][0], Patch[Key][1]>\n ) : (RuleDefs[Key] extends IndirDef<Context, Key> ? RuleDefs[Key] : never) }> {\n return <IndirBuilder<Context, Names, {[Key in Names]: Key extends keyof Patch ? (\n RuleDefs[Key] extends IndirDef<Context, Key, any, infer Par> ? IndirDef<Context, Key, Patch[Key], Par> : never\n ) : (RuleDefs[Key] extends IndirDef<Context, Key> ? RuleDefs[Key] : never) }>> <unknown> this;\n }\n\n /**\n * Change the implementation of an existing indirection.\n */\n public patchRule<U extends Names, RET, ARGS extends any[]>(patch: IndirDef<Context, U, RET, ARGS>):\n IndirBuilder<Context, Names, {[Key in Names]: Key extends U ?\n IndirDef<Context, Key, RET, ARGS> :\n (RuleDefs[Key] extends IndirDef<Context, Key> ? RuleDefs[Key] : never)\n } > {\n const self = <IndirBuilder<Context, Names, {[Key in Names]: Key extends U ?\n IndirDef<Context, Key, RET, ARGS> : (RuleDefs[Key] extends IndirDef<Context, Key> ? RuleDefs[Key] : never) }>>\n <unknown> this;\n self.rules[patch.name] = <any> patch;\n return self;\n }\n\n /**\n * Add an indirection function. If the rule already exists, but the implementation differs, an error will be thrown.\n */\n public addRuleRedundant<U extends string, RET, ARGS extends any[]>(rule: IndirDef<Context, U, RET, ARGS>):\n IndirBuilder<Context, Names | U, {[K in Names | U]: K extends U ?\n IndirDef<Context, K, RET, ARGS> :\n (K extends Names ? (RuleDefs[K] extends IndirDef<Context, K> ? RuleDefs[K] : never) : never)\n }> {\n const self = <IndirBuilder<Context, Names | U, {[K in Names | U]: K extends U ?\n IndirDef<Context, K, RET, ARGS> :\n (K extends Names ? (RuleDefs[K] extends IndirDef<Context, K> ? RuleDefs[K] : never) : never) }>>\n <unknown> this;\n const rules = <Record<string, IndirDef<Context>>> self.rules;\n if (rules[rule.name] !== undefined && rules[rule.name] !== rule) {\n throw new Error(`Function ${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 any[]>(\n rule: CheckOverlap<U, Names, IndirDef<Context, U, RET, ARGS>>,\n ): IndirBuilder<Context, Names | U, {[K in Names | U]: K extends U ?\n IndirDef<Context, K, RET, ARGS> :\n (K extends Names ? (RuleDefs[K] extends IndirDef<Context, K> ? RuleDefs[K] : never) : never) }> {\n return this.addRuleRedundant(rule);\n }\n\n public addMany<U extends readonly IndirDef<Context>[]>(\n ...rules: CheckOverlap<ParseNamesFromList<U>, Names, U>\n ): IndirBuilder<\n Context,\n Names | ParseNamesFromList<U>,\n {[K in Names | ParseNamesFromList<U>]:\n K extends keyof ParseIndirsToObject<typeof rules> ? (\n ParseIndirsToObject<typeof rules>[K] extends IndirDef<Context, K> ? ParseIndirsToObject<typeof rules>[K] : never\n ) : (\n K extends Names ? (RuleDefs[K] extends IndirDef<Context, K> ? RuleDefs[K] : never) : never\n )\n }\n > {\n this.rules = { ...this.rules, ...listToIndirectionMap(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 IndirBuilder<Context, Exclude<Names, U>, {[K in Exclude<Names, U>]:\n RuleDefs[K] extends IndirDef<Context, K> ? RuleDefs[K] : never }> {\n delete this.rules[ruleName];\n return <IndirBuilder<Context, Exclude<Names, U>, {[K in Exclude<Names, U>]:\n RuleDefs[K] extends IndirDef<Context, K> ? RuleDefs[K] : never }>>\n <unknown> this;\n }\n\n public build(): IndirectObjFromIndirDefs<Context, Names, RuleDefs> {\n return <IndirectObjFromIndirDefs<Context, Names, RuleDefs>> new DynamicIndirect(this.rules);\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IndirDefArg, IndirectionMap } from './helpers';
|
|
2
|
+
export declare class DynamicIndirect<Context, Names extends string, RuleDefs extends IndirectionMap<Names>> {
|
|
3
|
+
protected rules: RuleDefs;
|
|
4
|
+
protected __context: Context | undefined;
|
|
5
|
+
constructor(rules: RuleDefs);
|
|
6
|
+
setContext(context: Context): void;
|
|
7
|
+
protected getSafeContext(): Context;
|
|
8
|
+
protected readonly subrule: IndirDefArg['SUBRULE'];
|
|
9
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export class DynamicIndirect {
|
|
2
|
+
constructor(rules) {
|
|
3
|
+
this.rules = rules;
|
|
4
|
+
this.__context = undefined;
|
|
5
|
+
this.subrule = (cstDef, ...args) => {
|
|
6
|
+
const def = this.rules[cstDef.name];
|
|
7
|
+
if (!def) {
|
|
8
|
+
throw new Error(`Rule ${cstDef.name} not found`);
|
|
9
|
+
}
|
|
10
|
+
return def.fun({
|
|
11
|
+
SUBRULE: this.subrule,
|
|
12
|
+
})(this.getSafeContext(), ...args);
|
|
13
|
+
};
|
|
14
|
+
for (const rule of Object.values(rules)) {
|
|
15
|
+
this[rule.name] = ((context, ...args) => {
|
|
16
|
+
this.setContext(context);
|
|
17
|
+
return this.subrule(rule, ...args);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
setContext(context) {
|
|
22
|
+
this.__context = context;
|
|
23
|
+
}
|
|
24
|
+
getSafeContext() {
|
|
25
|
+
return this.__context;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=dynamicIndirected.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamicIndirected.js","sourceRoot":"","sources":["dynamicIndirected.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,eAAe;IAG1B,YAA6B,KAAe;QAAf,UAAK,GAAL,KAAK,CAAU;QAFlC,cAAS,GAAwB,SAAS,CAAC;QAmBlC,YAAO,GAA2B,CAAC,MAAM,EAAE,GAAG,IAAI,EAAE,EAAE;YACvE,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAmB,MAAM,CAAC,IAAI,CAAC,CAAC;YACtD,IAAI,CAAC,GAAG,EAAE,CAAC;gBACT,MAAM,IAAI,KAAK,CAAC,QAAQ,MAAM,CAAC,IAAI,YAAY,CAAC,CAAC;YACnD,CAAC;YAED,OAAa,GAAG,CAAC,GAAG,CAAC;gBACnB,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB,CAAC,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;QACrC,CAAC,CAAC;QAzBA,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,MAAM,CAAoC,KAAK,CAAC,EAAE,CAAC;YAC3E,IAAI,CAAsB,IAAI,CAAC,IAAI,CAAC,GAAS,CAAC,CAAC,OAAgB,EAAE,GAAG,IAAS,EAAO,EAAE;gBACpF,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;gBACzB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;YACrC,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAEM,UAAU,CAAC,OAAgB;QAChC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC;IAC3B,CAAC;IAES,cAAc;QACtB,OAAiB,IAAI,CAAC,SAAS,CAAC;IAClC,CAAC;CAYF","sourcesContent":["import type { IndirDef, IndirDefArg, IndirectionMap } from './helpers';\n\nexport class DynamicIndirect<Context, Names extends string, RuleDefs extends IndirectionMap<Names>> {\n protected __context: Context | undefined = undefined;\n\n public constructor(protected rules: RuleDefs) {\n for (const rule of Object.values(<Record<string, IndirDef<Context>>>rules)) {\n this[<keyof (typeof this)>rule.name] = <any> ((context: Context, ...args: any): any => {\n this.setContext(context);\n return this.subrule(rule, ...args);\n });\n }\n }\n\n public setContext(context: Context): void {\n this.__context = context;\n }\n\n protected getSafeContext(): Context {\n return <Context> this.__context;\n }\n\n protected readonly subrule: IndirDefArg['SUBRULE'] = (cstDef, ...args) => {\n const def = this.rules[<Names> <unknown> cstDef.name];\n if (!def) {\n throw new Error(`Rule ${cstDef.name} not found`);\n }\n\n return <any> def.fun({\n SUBRULE: this.subrule,\n })(this.getSafeContext(), ...args);\n };\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ParseNamesFromList } from '../parser-builder/builderTypes';
|
|
2
|
+
export type IndirDef<Context = any, NameType extends string = string, ReturnType = unknown, ParamType extends any[] = any[]> = {
|
|
3
|
+
name: NameType;
|
|
4
|
+
fun: (def: IndirDefArg) => (c: Context, ...params: ParamType) => ReturnType;
|
|
5
|
+
};
|
|
6
|
+
export type IndirDefArg = {
|
|
7
|
+
SUBRULE: <T, U extends any[]>(cstDef: IndirDef<any, any, T, U>, ...arg: U) => T;
|
|
8
|
+
};
|
|
9
|
+
export type IndirectionMap<RuleNames extends string> = {
|
|
10
|
+
[Key in RuleNames]: IndirDef<any, Key>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Converts a list of ruledefs to a record mapping a name to the corresponding ruledef.
|
|
14
|
+
*/
|
|
15
|
+
export declare function listToIndirectionMap<T extends readonly IndirDef[]>(rules: T): ParseIndirsToObject<T>;
|
|
16
|
+
/**
|
|
17
|
+
* Convert a list of IndirDefs to a Record with the name of the IndirDef as the key, matching the IndirectionMap type.
|
|
18
|
+
*/
|
|
19
|
+
export type ParseIndirsToObject<T extends readonly IndirDef[], Names extends string = ParseNamesFromList<T>, Agg extends Record<string, IndirDef> = Record<never, never>> = T extends readonly [infer First, ...infer Rest] ? (First extends IndirDef ? (Rest extends readonly IndirDef[] ? (ParseIndirsToObject<Rest, Names, {
|
|
20
|
+
[K in keyof Agg | First['name']]: K extends First['name'] ? First : Agg[K];
|
|
21
|
+
}>) : never) : never) : IndirectionMap<Names> & Agg;
|
|
22
|
+
export type IndirectObjFromIndirDefs<Context, Names extends string, RuleDefs extends IndirectionMap<Names>> = {
|
|
23
|
+
[K in Names]: RuleDefs[K] extends IndirDef<Context, K, infer RET, infer ARGS> ? (context: Context, ...args: ARGS) => RET : never;
|
|
24
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a list of ruledefs to a record mapping a name to the corresponding ruledef.
|
|
3
|
+
*/
|
|
4
|
+
export function listToIndirectionMap(rules) {
|
|
5
|
+
const newRules = {};
|
|
6
|
+
for (const rule of rules) {
|
|
7
|
+
newRules[rule.name] = rule;
|
|
8
|
+
}
|
|
9
|
+
return newRules;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["helpers.ts"],"names":[],"mappings":"AAkBA;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAgC,KAAQ;IAC1E,MAAM,QAAQ,GAA6B,EAAE,CAAC;IAC9C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC7B,CAAC;IACD,OAA+B,QAAQ,CAAC;AAC1C,CAAC","sourcesContent":["import type { ParseNamesFromList } from '../parser-builder/builderTypes';\n\nexport type IndirDef<\n Context = any,\n NameType extends string = string,\n ReturnType = unknown,\n ParamType extends any[] = any[],\n> = {\n name: NameType;\n fun: (def: IndirDefArg) => (c: Context, ...params: ParamType) => ReturnType;\n};\n\nexport type IndirDefArg = {\n SUBRULE: <T, U extends any[]>(cstDef: IndirDef<any, any, T, U>, ...arg: U) => T;\n};\n\nexport type IndirectionMap<RuleNames extends string> = {[Key in RuleNames]: IndirDef<any, Key> };\n\n/**\n * Converts a list of ruledefs to a record mapping a name to the corresponding ruledef.\n */\nexport function listToIndirectionMap<T extends readonly IndirDef[]>(rules: T): ParseIndirsToObject<T> {\n const newRules: Record<string, IndirDef> = {};\n for (const rule of rules) {\n newRules[rule.name] = rule;\n }\n return <ParseIndirsToObject<T>>newRules;\n}\n\n/**\n * Convert a list of IndirDefs to a Record with the name of the IndirDef as the key, matching the IndirectionMap type.\n */\nexport type ParseIndirsToObject<\n T extends readonly IndirDef[],\n Names extends string = ParseNamesFromList<T>,\n Agg extends Record<string, IndirDef> = Record<never, never>,\n> = T extends readonly [infer First, ...infer Rest] ? (\n First extends IndirDef ? (\n Rest extends readonly IndirDef[] ? (\n ParseIndirsToObject<Rest, Names, {[K in keyof Agg | First['name']]: K extends First['name'] ? First : Agg[K] }>\n ) : never\n ) : never\n) : IndirectionMap<Names> & Agg;\n\nexport type IndirectObjFromIndirDefs<Context, Names extends string, RuleDefs extends IndirectionMap<Names>> = {\n [K in Names]: RuleDefs[K] extends IndirDef<Context, K, infer RET, infer ARGS> ?\n (context: Context, ...args: ARGS) => RET : never\n};\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ILexerConfig } from '@chevrotain/types';
|
|
2
|
+
import type { TokenType } from 'chevrotain';
|
|
3
|
+
import { Lexer } from 'chevrotain';
|
|
4
|
+
import type { CheckOverlap, NamedToken } from '../utils';
|
|
5
|
+
export declare class LexerBuilder<NAMES extends string = string> {
|
|
6
|
+
private readonly tokens;
|
|
7
|
+
static create<U extends LexerBuilder<T>, T extends string = never>(starter?: U): U;
|
|
8
|
+
private constructor();
|
|
9
|
+
merge<OtherNames extends string, OW extends string>(merge: LexerBuilder<OtherNames>, overwrite?: NamedToken<OW>[]): LexerBuilder<NAMES | OtherNames>;
|
|
10
|
+
add<Name extends string>(...token: CheckOverlap<Name, NAMES, NamedToken<Name>[]>): LexerBuilder<Name | NAMES>;
|
|
11
|
+
addBefore<Name extends string>(before: NamedToken<NAMES>, ...token: CheckOverlap<Name, NAMES, NamedToken<Name>[]>): LexerBuilder<NAMES | Name>;
|
|
12
|
+
private moveBeforeOrAfter;
|
|
13
|
+
/**
|
|
14
|
+
* @param before token to move rest before
|
|
15
|
+
* @param tokens tokens to move before the first token
|
|
16
|
+
*/
|
|
17
|
+
moveBefore<Name extends string>(before: NamedToken<NAMES>, ...tokens: CheckOverlap<Name, NAMES, never, NamedToken<Name>[]>): LexerBuilder<NAMES>;
|
|
18
|
+
moveAfter<Name extends string>(after: NamedToken<NAMES>, ...tokens: CheckOverlap<Name, NAMES, never, NamedToken<Name>[]>): LexerBuilder<NAMES>;
|
|
19
|
+
addAfter<Name extends string>(after: NamedToken<NAMES>, ...token: CheckOverlap<Name, NAMES, never, NamedToken<Name>[]>): LexerBuilder<NAMES | Name>;
|
|
20
|
+
delete<Name extends NAMES>(...token: NamedToken<Name>[]): LexerBuilder<Exclude<NAMES, Name>>;
|
|
21
|
+
build(lexerConfig?: ILexerConfig): Lexer;
|
|
22
|
+
get tokenVocabulary(): readonly TokenType[];
|
|
23
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Lexer } from 'chevrotain';
|
|
2
|
+
export class LexerBuilder {
|
|
3
|
+
static create(starter) {
|
|
4
|
+
return new LexerBuilder(starter);
|
|
5
|
+
}
|
|
6
|
+
constructor(starter) {
|
|
7
|
+
this.tokens = starter?.tokens ? [...starter.tokens] : [];
|
|
8
|
+
}
|
|
9
|
+
merge(merge, overwrite = []) {
|
|
10
|
+
const extraTokens = merge.tokens.filter((token) => {
|
|
11
|
+
const overwriteToken = overwrite.find(t => t.name === token.name);
|
|
12
|
+
if (overwriteToken) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
const match = this.tokens.find(t => t.name === token.name);
|
|
16
|
+
if (match) {
|
|
17
|
+
if (match !== token) {
|
|
18
|
+
throw new Error(`Token with name ${token.name} already exists. Implementation is different and no overwrite was provided.`);
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
});
|
|
24
|
+
this.tokens.push(...extraTokens);
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
add(...token) {
|
|
28
|
+
this.tokens.push(...token);
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
addBefore(before, ...token) {
|
|
32
|
+
const index = this.tokens.indexOf(before);
|
|
33
|
+
if (index === -1) {
|
|
34
|
+
throw new Error('Token not found');
|
|
35
|
+
}
|
|
36
|
+
this.tokens.splice(index, 0, ...token);
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
moveBeforeOrAfter(beforeOrAfter, before, ...tokens) {
|
|
40
|
+
const beforeIndex = this.tokens.indexOf(before) + (beforeOrAfter === 'before' ? 0 : 1);
|
|
41
|
+
if (beforeIndex === -1) {
|
|
42
|
+
throw new Error('BeforeToken not found');
|
|
43
|
+
}
|
|
44
|
+
for (const token of tokens) {
|
|
45
|
+
const tokenIndex = this.tokens.indexOf(token);
|
|
46
|
+
if (tokenIndex === -1) {
|
|
47
|
+
throw new Error('Token not found');
|
|
48
|
+
}
|
|
49
|
+
this.tokens.splice(tokenIndex, 1);
|
|
50
|
+
this.tokens.splice(beforeIndex, 0, token);
|
|
51
|
+
}
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* @param before token to move rest before
|
|
56
|
+
* @param tokens tokens to move before the first token
|
|
57
|
+
*/
|
|
58
|
+
moveBefore(before, ...tokens) {
|
|
59
|
+
return this.moveBeforeOrAfter('before', before, ...tokens);
|
|
60
|
+
}
|
|
61
|
+
moveAfter(after, ...tokens) {
|
|
62
|
+
return this.moveBeforeOrAfter('after', after, ...tokens);
|
|
63
|
+
}
|
|
64
|
+
addAfter(after, ...token) {
|
|
65
|
+
const index = this.tokens.indexOf(after);
|
|
66
|
+
if (index === -1) {
|
|
67
|
+
throw new Error('Token not found');
|
|
68
|
+
}
|
|
69
|
+
this.tokens.splice(index + 1, 0, ...token);
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
delete(...token) {
|
|
73
|
+
for (const t of token) {
|
|
74
|
+
const index = this.tokens.indexOf(t);
|
|
75
|
+
if (index === -1) {
|
|
76
|
+
throw new Error('Token not found');
|
|
77
|
+
}
|
|
78
|
+
this.tokens.splice(index, 1);
|
|
79
|
+
}
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
build(lexerConfig) {
|
|
83
|
+
return new Lexer(this.tokens, {
|
|
84
|
+
positionTracking: 'onlyStart',
|
|
85
|
+
recoveryEnabled: false,
|
|
86
|
+
ensureOptimizations: true,
|
|
87
|
+
// SafeMode: true,
|
|
88
|
+
// SkipValidations: true,
|
|
89
|
+
...lexerConfig,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
get tokenVocabulary() {
|
|
93
|
+
return this.tokens;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=LexerBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LexerBuilder.js","sourceRoot":"","sources":["LexerBuilder.ts"],"names":[],"mappings":"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","sourcesContent":["import type { ILexerConfig } from '@chevrotain/types';\nimport type { TokenType } from 'chevrotain';\nimport { Lexer } from 'chevrotain';\nimport type { CheckOverlap, NamedToken } from '../utils';\n\nexport class LexerBuilder<NAMES extends string = string> {\n private readonly tokens: TokenType[];\n\n public static create<U extends LexerBuilder<T>, T extends string = never>(starter?: U): U {\n return <U> new LexerBuilder(starter);\n }\n\n private constructor(starter?: LexerBuilder<NAMES>) {\n this.tokens = starter?.tokens ? [ ...starter.tokens ] : [];\n }\n\n public merge<OtherNames extends string, OW extends string>(\n merge: LexerBuilder<OtherNames>,\n overwrite: NamedToken<OW>[] = [],\n ):\n LexerBuilder<NAMES | OtherNames> {\n const extraTokens = merge.tokens.filter((token) => {\n const overwriteToken = overwrite.find(t => t.name === token.name);\n if (overwriteToken) {\n return false;\n }\n const match = this.tokens.find(t => t.name === token.name);\n if (match) {\n if (match !== token) {\n throw new Error(`Token with name ${token.name} already exists. Implementation is different and no overwrite was provided.`);\n }\n return false;\n }\n return true;\n });\n this.tokens.push(...extraTokens);\n return this;\n }\n\n public add<Name extends string>(...token: CheckOverlap<Name, NAMES, NamedToken<Name>[]>):\n LexerBuilder<Name | NAMES> {\n this.tokens.push(...token);\n return this;\n }\n\n public addBefore<Name extends string>(\n before: NamedToken<NAMES>,\n ...token: CheckOverlap<Name, NAMES, NamedToken<Name>[]>\n ): LexerBuilder<NAMES | Name> {\n const index = this.tokens.indexOf(before);\n if (index === -1) {\n throw new Error('Token not found');\n }\n this.tokens.splice(index, 0, ...token);\n return this;\n }\n\n private moveBeforeOrAfter<Name extends string>(\n beforeOrAfter: 'before' | 'after',\n before: NamedToken<NAMES>,\n ...tokens: CheckOverlap<Name, NAMES, never, NamedToken<Name>[]>\n ): LexerBuilder<NAMES> {\n const beforeIndex = this.tokens.indexOf(before) + (beforeOrAfter === 'before' ? 0 : 1);\n if (beforeIndex === -1) {\n throw new Error('BeforeToken not found');\n }\n for (const token of tokens) {\n const tokenIndex = this.tokens.indexOf(token);\n if (tokenIndex === -1) {\n throw new Error('Token not found');\n }\n this.tokens.splice(tokenIndex, 1);\n this.tokens.splice(beforeIndex, 0, token);\n }\n return this;\n }\n\n /**\n * @param before token to move rest before\n * @param tokens tokens to move before the first token\n */\n public moveBefore<Name extends string>(\n before: NamedToken<NAMES>,\n ...tokens: CheckOverlap<Name, NAMES, never, NamedToken<Name>[]>\n ): LexerBuilder<NAMES> {\n return this.moveBeforeOrAfter('before', before, ...tokens);\n }\n\n public moveAfter<Name extends string>(\n after: NamedToken<NAMES>,\n ...tokens: CheckOverlap<Name, NAMES, never, NamedToken<Name>[]>\n ): LexerBuilder<NAMES> {\n return this.moveBeforeOrAfter('after', after, ...tokens);\n }\n\n public addAfter<Name extends string>(\n after: NamedToken<NAMES>,\n ...token: CheckOverlap<Name, NAMES, never, NamedToken<Name>[]>\n ): LexerBuilder<NAMES | Name> {\n const index = this.tokens.indexOf(after);\n if (index === -1) {\n throw new Error('Token not found');\n }\n this.tokens.splice(index + 1, 0, ...token);\n return this;\n }\n\n public delete<Name extends NAMES>(...token: NamedToken<Name>[]): LexerBuilder<Exclude<NAMES, Name>> {\n for (const t of token) {\n const index = this.tokens.indexOf(t);\n if (index === -1) {\n throw new Error('Token not found');\n }\n this.tokens.splice(index, 1);\n }\n return this;\n }\n\n public build(lexerConfig?: ILexerConfig): Lexer {\n return new Lexer(this.tokens, {\n positionTracking: 'onlyStart',\n recoveryEnabled: false,\n ensureOptimizations: true,\n // SafeMode: true,\n // SkipValidations: true,\n ...lexerConfig,\n });\n }\n\n public get tokenVocabulary(): readonly TokenType[] {\n return this.tokens;\n }\n}\n"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export interface Localized {
|
|
2
|
+
/**
|
|
3
|
+
* Location undefined means the node does have a string representation, but it was not clarified.
|
|
4
|
+
* This happens when an AST node is patched by a client of the lib.
|
|
5
|
+
*/
|
|
6
|
+
loc: SourceLocation;
|
|
7
|
+
}
|
|
8
|
+
export interface Wrap<T> extends Localized {
|
|
9
|
+
val: T;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A AST node. Nodes are indexable by their types.
|
|
13
|
+
* When generating, the SUBRULES called should be located within the current location range.
|
|
14
|
+
*/
|
|
15
|
+
export interface Node extends Localized {
|
|
16
|
+
type: string;
|
|
17
|
+
subType?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface SourceLocationBase {
|
|
20
|
+
sourceLocationType: string;
|
|
21
|
+
}
|
|
22
|
+
export interface SourceLocationSource extends SourceLocationBase {
|
|
23
|
+
sourceLocationType: 'source';
|
|
24
|
+
start: number;
|
|
25
|
+
end: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* NoStringManifestation means the node does not have a string representation.
|
|
29
|
+
* For example the literal '5' has an integer type (which is an AST node),
|
|
30
|
+
* but the type does not have an associated string representation.
|
|
31
|
+
* When set to true, the node will not be printed, start and end are meaningless in this case.
|
|
32
|
+
*/
|
|
33
|
+
export interface SourceLocationNoMaterialize extends SourceLocationBase {
|
|
34
|
+
sourceLocationType: 'noMaterialize';
|
|
35
|
+
}
|
|
36
|
+
export interface SourceLocationStringReplace extends SourceLocationBase {
|
|
37
|
+
sourceLocationType: 'stringReplace';
|
|
38
|
+
newSource: string;
|
|
39
|
+
start: number;
|
|
40
|
+
end: number;
|
|
41
|
+
}
|
|
42
|
+
export interface SourceLocationNodeReplace extends SourceLocationBase {
|
|
43
|
+
sourceLocationType: 'nodeReplace';
|
|
44
|
+
start: number;
|
|
45
|
+
end: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Must have an ancestor of type {@link SourceLocationNodeReplace}
|
|
49
|
+
*/
|
|
50
|
+
export interface SourceLocationNodeAutoGenerate extends SourceLocationBase {
|
|
51
|
+
sourceLocationType: 'autoGenerate';
|
|
52
|
+
}
|
|
53
|
+
export type SourceLocation = SourceLocationSource | SourceLocationNoMaterialize | SourceLocationStringReplace | SourceLocationNodeReplace | SourceLocationNodeAutoGenerate;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeTypings.js","sourceRoot":"","sources":["nodeTypings.ts"],"names":[],"mappings":"","sourcesContent":["export interface Localized {\n /**\n * Location undefined means the node does have a string representation, but it was not clarified.\n * This happens when an AST node is patched by a client of the lib.\n */\n loc: SourceLocation;\n}\n\nexport interface Wrap<T> extends Localized {\n val: T;\n}\n\n/**\n * A AST node. Nodes are indexable by their types.\n * When generating, the SUBRULES called should be located within the current location range.\n */\nexport interface Node extends Localized {\n type: string;\n subType?: string;\n}\n\nexport interface SourceLocationBase {\n sourceLocationType: string;\n}\n\nexport interface SourceLocationSource extends SourceLocationBase {\n sourceLocationType: 'source';\n start: number;\n end: number;\n}\n\n/**\n * NoStringManifestation means the node does not have a string representation.\n * For example the literal '5' has an integer type (which is an AST node),\n * but the type does not have an associated string representation.\n * When set to true, the node will not be printed, start and end are meaningless in this case.\n */\nexport interface SourceLocationNoMaterialize extends SourceLocationBase {\n sourceLocationType: 'noMaterialize';\n}\n\nexport interface SourceLocationStringReplace extends SourceLocationBase {\n sourceLocationType: 'stringReplace';\n newSource: string;\n start: number;\n end: number;\n}\n\nexport interface SourceLocationNodeReplace extends SourceLocationBase {\n sourceLocationType: 'nodeReplace';\n start: number;\n end: number;\n}\n/**\n * Must have an ancestor of type {@link SourceLocationNodeReplace}\n */\nexport interface SourceLocationNodeAutoGenerate extends SourceLocationBase {\n sourceLocationType: 'autoGenerate';\n}\n\nexport type SourceLocation =\n | SourceLocationSource\n | SourceLocationNoMaterialize\n | SourceLocationStringReplace\n | SourceLocationNodeReplace\n | SourceLocationNodeAutoGenerate;\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ParserMethod } from 'chevrotain';
|
|
2
|
+
import type { ParserRule } from './ruleDefTypes';
|
|
3
|
+
/**
|
|
4
|
+
* Get union-type of names used in list of ruledefs.
|
|
5
|
+
*/
|
|
6
|
+
export type ParseNamesFromList<T extends readonly {
|
|
7
|
+
name: string;
|
|
8
|
+
}[]> = T[number]['name'];
|
|
9
|
+
/**
|
|
10
|
+
* Convert a list of ruledefs to a record that maps each rule name to its definition.
|
|
11
|
+
*/
|
|
12
|
+
export type ParseRuleMap<RuleNames extends string> = {
|
|
13
|
+
[Key in RuleNames]: ParserRule<any, Key>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Convert a list of RuleDefs to a Record with the name of the RuleDef as the key, matching the RuleDefMap type.
|
|
17
|
+
*/
|
|
18
|
+
export type ParseRulesToObject<T extends readonly ParserRule[], Names extends string = ParseNamesFromList<T>, Agg extends Record<string, ParserRule> = Record<never, never>> = T extends readonly [infer First, ...infer Rest] ? (First extends ParserRule ? (Rest extends readonly ParserRule[] ? (ParseRulesToObject<Rest, Names, {
|
|
19
|
+
[K in keyof Agg | First['name']]: K extends First['name'] ? First : Agg[K];
|
|
20
|
+
}>) : never) : never) : ParseRuleMap<Names> & Agg;
|
|
21
|
+
export type ParserFromRules<Context, Names extends string, RuleDefs extends ParseRuleMap<Names>> = {
|
|
22
|
+
[K in Names]: RuleDefs[K] extends ParserRule<Context, K, infer RET, infer ARGS> ? (input: string, context: Context, args: ARGS) => RET : never;
|
|
23
|
+
};
|
|
24
|
+
export type ParseMethodsFromRules<Context, Names extends string, RuleDefs extends ParseRuleMap<Names>> = {
|
|
25
|
+
[K in Names]: RuleDefs[K] extends ParserRule<Context, K, infer RET, infer ARGS> ? ParserMethod<[Context, ARGS], RET> : never;
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builderTypes.js","sourceRoot":"","sources":["builderTypes.ts"],"names":[],"mappings":"","sourcesContent":["import type { ParserMethod } from 'chevrotain';\nimport type { ParserRule } from './ruleDefTypes';\n\n/**\n * Get union-type of names used in list of ruledefs.\n */\nexport type ParseNamesFromList<T extends readonly { name: string }[]> = 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 ParseRuleMap<RuleNames extends string> = {[Key in RuleNames]: ParserRule<any, Key> };\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 ParseRulesToObject<\n T extends readonly ParserRule[],\n Names extends string = ParseNamesFromList<T>,\n Agg extends Record<string, ParserRule> = Record<never, never>,\n> = T extends readonly [infer First, ...infer Rest] ? (\n First extends ParserRule ? (\n Rest extends readonly ParserRule[] ? (\n ParseRulesToObject<Rest, Names, {[K in keyof Agg | First['name']]: K extends First['name'] ? First : Agg[K] }>\n ) : never\n ) : never\n) : ParseRuleMap<Names> & Agg;\n\nexport type ParserFromRules<Context, Names extends string, RuleDefs extends ParseRuleMap<Names>> = {\n [K in Names]: RuleDefs[K] extends ParserRule<Context, K, infer RET, infer ARGS> ?\n (input: string, context: Context, args: ARGS) => RET : never\n};\n\nexport type ParseMethodsFromRules<Context, Names extends string, RuleDefs extends ParseRuleMap<Names>> = {\n [K in Names]: RuleDefs[K] extends ParserRule<Context, K, infer RET, infer ARGS> ?\n ParserMethod<[Context, ARGS], RET> : never\n};\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IParserConfig } from '@chevrotain/types';
|
|
2
|
+
import { EmbeddedActionsParser, type TokenVocabulary } from 'chevrotain';
|
|
3
|
+
import type { ParseRuleMap } from './builderTypes';
|
|
4
|
+
export declare class DynamicParser<Context, Names extends string, RuleDefs extends ParseRuleMap<Names>> extends EmbeddedActionsParser {
|
|
5
|
+
private context;
|
|
6
|
+
setContext(context: Context): void;
|
|
7
|
+
constructor(rules: RuleDefs, tokenVocabulary: TokenVocabulary, config?: IParserConfig);
|
|
8
|
+
private constructSelfRef;
|
|
9
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { EmbeddedActionsParser } from 'chevrotain';
|
|
2
|
+
export class DynamicParser extends EmbeddedActionsParser {
|
|
3
|
+
setContext(context) {
|
|
4
|
+
this.context = context;
|
|
5
|
+
}
|
|
6
|
+
constructor(rules, tokenVocabulary, config = {}) {
|
|
7
|
+
super(tokenVocabulary, {
|
|
8
|
+
// RecoveryEnabled: true,
|
|
9
|
+
maxLookahead: 2,
|
|
10
|
+
// SkipValidations: true,
|
|
11
|
+
...config,
|
|
12
|
+
});
|
|
13
|
+
this.context = undefined;
|
|
14
|
+
const selfRef = this.constructSelfRef();
|
|
15
|
+
const implArgs = {
|
|
16
|
+
...selfRef,
|
|
17
|
+
cache: new WeakMap(),
|
|
18
|
+
};
|
|
19
|
+
for (const rule of Object.values(rules)) {
|
|
20
|
+
// Function implementation itself - this function is called AFTER lexing
|
|
21
|
+
this[rule.name] = this.RULE(rule.name, rule.impl(implArgs));
|
|
22
|
+
}
|
|
23
|
+
this.performSelfAnalysis();
|
|
24
|
+
}
|
|
25
|
+
constructSelfRef() {
|
|
26
|
+
const subRuleImpl = (chevrotainSubrule) => ((cstDef, arg) => chevrotainSubrule(this[cstDef.name], { ARGS: [this.context, arg] }));
|
|
27
|
+
return {
|
|
28
|
+
CONSUME: (tokenType, option) => this.CONSUME(tokenType, option),
|
|
29
|
+
CONSUME1: (tokenType, option) => this.CONSUME1(tokenType, option),
|
|
30
|
+
CONSUME2: (tokenType, option) => this.CONSUME2(tokenType, option),
|
|
31
|
+
CONSUME3: (tokenType, option) => this.CONSUME3(tokenType, option),
|
|
32
|
+
CONSUME4: (tokenType, option) => this.CONSUME4(tokenType, option),
|
|
33
|
+
CONSUME5: (tokenType, option) => this.CONSUME5(tokenType, option),
|
|
34
|
+
CONSUME6: (tokenType, option) => this.CONSUME6(tokenType, option),
|
|
35
|
+
CONSUME7: (tokenType, option) => this.CONSUME7(tokenType, option),
|
|
36
|
+
CONSUME8: (tokenType, option) => this.CONSUME8(tokenType, option),
|
|
37
|
+
CONSUME9: (tokenType, option) => this.CONSUME9(tokenType, option),
|
|
38
|
+
OPTION: actionORMethodDef => this.OPTION(actionORMethodDef),
|
|
39
|
+
OPTION1: actionORMethodDef => this.OPTION1(actionORMethodDef),
|
|
40
|
+
OPTION2: actionORMethodDef => this.OPTION2(actionORMethodDef),
|
|
41
|
+
OPTION3: actionORMethodDef => this.OPTION3(actionORMethodDef),
|
|
42
|
+
OPTION4: actionORMethodDef => this.OPTION4(actionORMethodDef),
|
|
43
|
+
OPTION5: actionORMethodDef => this.OPTION5(actionORMethodDef),
|
|
44
|
+
OPTION6: actionORMethodDef => this.OPTION6(actionORMethodDef),
|
|
45
|
+
OPTION7: actionORMethodDef => this.OPTION7(actionORMethodDef),
|
|
46
|
+
OPTION8: actionORMethodDef => this.OPTION8(actionORMethodDef),
|
|
47
|
+
OPTION9: actionORMethodDef => this.OPTION9(actionORMethodDef),
|
|
48
|
+
OR: altsOrOpts => this.OR(altsOrOpts),
|
|
49
|
+
OR1: altsOrOpts => this.OR1(altsOrOpts),
|
|
50
|
+
OR2: altsOrOpts => this.OR2(altsOrOpts),
|
|
51
|
+
OR3: altsOrOpts => this.OR3(altsOrOpts),
|
|
52
|
+
OR4: altsOrOpts => this.OR4(altsOrOpts),
|
|
53
|
+
OR5: altsOrOpts => this.OR5(altsOrOpts),
|
|
54
|
+
OR6: altsOrOpts => this.OR6(altsOrOpts),
|
|
55
|
+
OR7: altsOrOpts => this.OR7(altsOrOpts),
|
|
56
|
+
OR8: altsOrOpts => this.OR8(altsOrOpts),
|
|
57
|
+
OR9: altsOrOpts => this.OR9(altsOrOpts),
|
|
58
|
+
MANY: actionORMethodDef => this.MANY(actionORMethodDef),
|
|
59
|
+
MANY1: actionORMethodDef => this.MANY1(actionORMethodDef),
|
|
60
|
+
MANY2: actionORMethodDef => this.MANY2(actionORMethodDef),
|
|
61
|
+
MANY3: actionORMethodDef => this.MANY3(actionORMethodDef),
|
|
62
|
+
MANY4: actionORMethodDef => this.MANY4(actionORMethodDef),
|
|
63
|
+
MANY5: actionORMethodDef => this.MANY5(actionORMethodDef),
|
|
64
|
+
MANY6: actionORMethodDef => this.MANY6(actionORMethodDef),
|
|
65
|
+
MANY7: actionORMethodDef => this.MANY7(actionORMethodDef),
|
|
66
|
+
MANY8: actionORMethodDef => this.MANY8(actionORMethodDef),
|
|
67
|
+
MANY9: actionORMethodDef => this.MANY9(actionORMethodDef),
|
|
68
|
+
MANY_SEP: options => this.MANY_SEP(options),
|
|
69
|
+
MANY_SEP1: options => this.MANY_SEP1(options),
|
|
70
|
+
MANY_SEP2: options => this.MANY_SEP2(options),
|
|
71
|
+
MANY_SEP3: options => this.MANY_SEP3(options),
|
|
72
|
+
MANY_SEP4: options => this.MANY_SEP4(options),
|
|
73
|
+
MANY_SEP5: options => this.MANY_SEP5(options),
|
|
74
|
+
MANY_SEP6: options => this.MANY_SEP6(options),
|
|
75
|
+
MANY_SEP7: options => this.MANY_SEP7(options),
|
|
76
|
+
MANY_SEP8: options => this.MANY_SEP8(options),
|
|
77
|
+
MANY_SEP9: options => this.MANY_SEP9(options),
|
|
78
|
+
AT_LEAST_ONE: actionORMethodDef => this.AT_LEAST_ONE(actionORMethodDef),
|
|
79
|
+
AT_LEAST_ONE1: actionORMethodDef => this.AT_LEAST_ONE1(actionORMethodDef),
|
|
80
|
+
AT_LEAST_ONE2: actionORMethodDef => this.AT_LEAST_ONE2(actionORMethodDef),
|
|
81
|
+
AT_LEAST_ONE3: actionORMethodDef => this.AT_LEAST_ONE3(actionORMethodDef),
|
|
82
|
+
AT_LEAST_ONE4: actionORMethodDef => this.AT_LEAST_ONE4(actionORMethodDef),
|
|
83
|
+
AT_LEAST_ONE5: actionORMethodDef => this.AT_LEAST_ONE5(actionORMethodDef),
|
|
84
|
+
AT_LEAST_ONE6: actionORMethodDef => this.AT_LEAST_ONE6(actionORMethodDef),
|
|
85
|
+
AT_LEAST_ONE7: actionORMethodDef => this.AT_LEAST_ONE7(actionORMethodDef),
|
|
86
|
+
AT_LEAST_ONE8: actionORMethodDef => this.AT_LEAST_ONE8(actionORMethodDef),
|
|
87
|
+
AT_LEAST_ONE9: actionORMethodDef => this.AT_LEAST_ONE9(actionORMethodDef),
|
|
88
|
+
AT_LEAST_ONE_SEP: options => this.AT_LEAST_ONE_SEP(options),
|
|
89
|
+
AT_LEAST_ONE_SEP1: options => this.AT_LEAST_ONE_SEP1(options),
|
|
90
|
+
AT_LEAST_ONE_SEP2: options => this.AT_LEAST_ONE_SEP2(options),
|
|
91
|
+
AT_LEAST_ONE_SEP3: options => this.AT_LEAST_ONE_SEP3(options),
|
|
92
|
+
AT_LEAST_ONE_SEP4: options => this.AT_LEAST_ONE_SEP4(options),
|
|
93
|
+
AT_LEAST_ONE_SEP5: options => this.AT_LEAST_ONE_SEP5(options),
|
|
94
|
+
AT_LEAST_ONE_SEP6: options => this.AT_LEAST_ONE_SEP6(options),
|
|
95
|
+
AT_LEAST_ONE_SEP7: options => this.AT_LEAST_ONE_SEP7(options),
|
|
96
|
+
AT_LEAST_ONE_SEP8: options => this.AT_LEAST_ONE_SEP8(options),
|
|
97
|
+
AT_LEAST_ONE_SEP9: options => this.AT_LEAST_ONE_SEP9(options),
|
|
98
|
+
ACTION: func => this.ACTION(func),
|
|
99
|
+
BACKTRACK: (cstDef, ...args) => this.BACKTRACK(this[cstDef.name], { ARGS: args }),
|
|
100
|
+
SUBRULE: subRuleImpl((rule, args) => this.SUBRULE(rule, args)),
|
|
101
|
+
SUBRULE1: subRuleImpl((rule, args) => this.SUBRULE1(rule, args)),
|
|
102
|
+
SUBRULE2: subRuleImpl((rule, args) => this.SUBRULE2(rule, args)),
|
|
103
|
+
SUBRULE3: subRuleImpl((rule, args) => this.SUBRULE3(rule, args)),
|
|
104
|
+
SUBRULE4: subRuleImpl((rule, args) => this.SUBRULE4(rule, args)),
|
|
105
|
+
SUBRULE5: subRuleImpl((rule, args) => this.SUBRULE5(rule, args)),
|
|
106
|
+
SUBRULE6: subRuleImpl((rule, args) => this.SUBRULE6(rule, args)),
|
|
107
|
+
SUBRULE7: subRuleImpl((rule, args) => this.SUBRULE7(rule, args)),
|
|
108
|
+
SUBRULE8: subRuleImpl((rule, args) => this.SUBRULE8(rule, args)),
|
|
109
|
+
SUBRULE9: subRuleImpl((rule, args) => this.SUBRULE9(rule, args)),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=dynamicParser.js.map
|