parseman 0.1.7 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +192 -155
- package/dist/combinators/choice.d.ts.map +1 -1
- package/dist/combinators/completions.d.ts +17 -0
- package/dist/combinators/completions.d.ts.map +1 -0
- package/dist/combinators/grammar.d.ts +20 -4
- package/dist/combinators/grammar.d.ts.map +1 -1
- package/dist/combinators/guard.d.ts +2 -2
- package/dist/combinators/guard.d.ts.map +1 -1
- package/dist/combinators/keywords.d.ts +22 -0
- package/dist/combinators/keywords.d.ts.map +1 -0
- package/dist/combinators/literal.d.ts.map +1 -1
- package/dist/combinators/node.d.ts +24 -0
- package/dist/combinators/node.d.ts.map +1 -0
- package/dist/combinators/parser.d.ts +7 -7
- package/dist/combinators/parser.d.ts.map +1 -1
- package/dist/combinators/probe.d.ts +13 -0
- package/dist/combinators/probe.d.ts.map +1 -0
- package/dist/combinators/recover.d.ts.map +1 -1
- package/dist/combinators/regex.d.ts.map +1 -1
- package/dist/combinators/repeat.d.ts.map +1 -1
- package/dist/combinators/scanTo.d.ts.map +1 -1
- package/dist/combinators/sequence.d.ts.map +1 -1
- package/dist/combinators/trivia-skip.d.ts +33 -0
- package/dist/combinators/trivia-skip.d.ts.map +1 -0
- package/dist/combinators/withCtx.d.ts +1 -1
- package/dist/compiler/codegen.d.ts +13 -4
- package/dist/compiler/codegen.d.ts.map +1 -1
- package/dist/cst/grammar.d.ts +33 -2
- package/dist/cst/grammar.d.ts.map +1 -1
- package/dist/cst/incremental.d.ts +4 -2
- package/dist/cst/incremental.d.ts.map +1 -1
- package/dist/cst/trivia-index.d.ts +50 -0
- package/dist/cst/trivia-index.d.ts.map +1 -0
- package/dist/cst/types.d.ts +7 -7
- package/dist/cst/types.d.ts.map +1 -1
- package/dist/functional/doc.d.ts +53 -0
- package/dist/functional/doc.d.ts.map +1 -0
- package/dist/index.cjs +953 -221
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +12 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6519 -226
- package/dist/index.js.map +4 -4
- package/dist/plugin/evaluator.d.ts +26 -6
- package/dist/plugin/evaluator.d.ts.map +1 -1
- package/dist/plugin/index.cjs +1164 -215
- package/dist/plugin/index.cjs.map +4 -4
- package/dist/plugin/index.d.ts +5 -2
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +1164 -215
- package/dist/plugin/index.js.map +4 -4
- package/dist/types.d.ts +51 -6
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -3
|
@@ -2,14 +2,34 @@
|
|
|
2
2
|
* Statically evaluates parseman combinator call expressions from an oxc AST
|
|
3
3
|
* into actual Combinator<unknown> objects by calling the real library functions.
|
|
4
4
|
*
|
|
5
|
-
* Returns null for anything unresolvable (
|
|
6
|
-
*
|
|
5
|
+
* Returns null for anything unresolvable (external variables, template literals,
|
|
6
|
+
* computed keys, etc.) — callers leave those as-is.
|
|
7
7
|
*/
|
|
8
8
|
import type { Expression, Node } from '@oxc-project/types';
|
|
9
9
|
import type { Combinator } from '../types.ts';
|
|
10
|
-
export type
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
export type ScopeEntry = {
|
|
11
|
+
combi: Combinator<unknown>;
|
|
12
|
+
mfSrcs: string[];
|
|
13
|
+
};
|
|
14
|
+
export type Scope = Map<string, ScopeEntry>;
|
|
15
|
+
/** Evaluate a single combinator expression. Returns null if unresolvable. */
|
|
16
|
+
export declare function evaluateExpr(node: Expression, scope: Scope, code?: string, mapFnSources?: string[]): Combinator<unknown> | null;
|
|
17
|
+
/**
|
|
18
|
+
* Evaluate a `parser(g => { ... return { ruleName: combinator, ... } })` call.
|
|
19
|
+
* Returns a map of rule names → defined Combinators, or null if the factory
|
|
20
|
+
* can't be statically evaluated.
|
|
21
|
+
*
|
|
22
|
+
* mapFnSources is populated with the sources for mapFns that codegen will push
|
|
23
|
+
* when compiling each returned rule — each rule's entry in the map will produce
|
|
24
|
+
* a sub-slice of mapFnSources aligned to its specific ctx.mapFns.
|
|
25
|
+
*
|
|
26
|
+
* Important: this function uses a SEPARATE accumulator for body statement
|
|
27
|
+
* evaluation so that only the return-expression phase adds entries to the
|
|
28
|
+
* caller-provided mapFnSources (which is what compile() will receive).
|
|
29
|
+
* The body-phase entries are stored as `mfSrcs` on localScope entries and
|
|
30
|
+
* replayed when those entries are referenced during return evaluation.
|
|
31
|
+
*/
|
|
32
|
+
export declare function evaluateParserFactory(factoryNode: Expression, scope: Scope, code: string, mapFnSources: string[]): Map<string, Combinator<unknown>> | null;
|
|
33
|
+
/** Check if an AST node references any name from the given scope or names set. */
|
|
14
34
|
export declare function referencesAny(node: Node, names: Set<string>, scope: Scope): boolean;
|
|
15
35
|
//# sourceMappingURL=evaluator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../src/plugin/evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../src/plugin/evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,UAAU,EAAE,IAAI,EAMjB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAa7C,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,CAAA;IAC1B,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB,CAAA;AACD,MAAM,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;AAoQ3C,6EAA6E;AAC7E,wBAAgB,YAAY,CAC1B,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,KAAK,EACZ,IAAI,CAAC,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,MAAM,EAAE,GACtB,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,CAE5B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,UAAU,EACvB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,EAAE,GACrB,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,CAuGzC;AAED,kFAAkF;AAClF,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAcnF"}
|