parseman 0.12.0 → 0.13.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/dist/compiler/codegen.d.ts.map +1 -1
- package/dist/compiler/scannable-run.d.ts +80 -2
- package/dist/compiler/scannable-run.d.ts.map +1 -1
- package/dist/cst/types.d.ts +1 -1
- package/dist/functional/doc.d.ts +6 -6
- package/dist/functional/doc.d.ts.map +1 -1
- package/dist/index.cjs +727 -52
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +727 -52
- package/dist/index.js.map +3 -3
- package/dist/plugin/evaluator.d.ts +28 -2
- package/dist/plugin/evaluator.d.ts.map +1 -1
- package/dist/plugin/index.cjs +974 -101
- package/dist/plugin/index.cjs.map +3 -3
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +974 -101
- package/dist/plugin/index.js.map +3 -3
- package/package.json +5 -4
- package/dist/combinators/lazy.d.ts +0 -14
- package/dist/combinators/lazy.d.ts.map +0 -1
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Returns null for anything unresolvable (external variables, template literals,
|
|
6
6
|
* computed keys, etc.) — callers leave those as-is.
|
|
7
7
|
*/
|
|
8
|
-
import type { Expression, Node } from '@oxc-project/types';
|
|
8
|
+
import type { Expression, Node, ArrowFunctionExpression, Function as OxcFunction } from '@oxc-project/types';
|
|
9
9
|
import type { Combinator } from '../types.ts';
|
|
10
10
|
export type ScopeEntry = {
|
|
11
11
|
combi: Combinator<unknown>;
|
|
@@ -28,6 +28,31 @@ export declare function evaluateExpr(node: Expression, scope: Scope, code?: stri
|
|
|
28
28
|
* literal of statically-resolvable combinators.
|
|
29
29
|
*/
|
|
30
30
|
export declare function evaluateCombinatorArray(node: Expression, scope: Scope, code?: string): Combinator<unknown>[] | null;
|
|
31
|
+
/** A rules() fragment factory AST: an arrow / function returning an object literal. */
|
|
32
|
+
export type FactoryAst = ArrowFunctionExpression | OxcFunction;
|
|
33
|
+
/**
|
|
34
|
+
* A resolved fragment factory + the source text its AST offsets index into. For a
|
|
35
|
+
* same-file factory that's the consumer's own `code`; for an imported one it's the
|
|
36
|
+
* exporting module's source (read by the plugin). The source MUST travel with the
|
|
37
|
+
* AST so callback capture (`node`/`transform` slice `code[start..end]`) reads the
|
|
38
|
+
* right bytes — a fragment's node offsets are meaningless against the consumer file.
|
|
39
|
+
*/
|
|
40
|
+
export type ResolvedFactory = {
|
|
41
|
+
fn: FactoryAst;
|
|
42
|
+
code: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Resolve a fragment factory by name — a local same-file `const frag = …` OR an
|
|
46
|
+
* imported one whose source the plugin reads (tier 2). Returns null when the name
|
|
47
|
+
* isn't a resolvable fragment (→ the spread bails to the interpreter fallback).
|
|
48
|
+
*/
|
|
49
|
+
export type FactoryResolver = (name: string) => ResolvedFactory | null;
|
|
50
|
+
/**
|
|
51
|
+
* If `expr` is a fragment factory — an arrow/function whose body returns an object
|
|
52
|
+
* literal, e.g. `(g, deps) => ({ rule: combinator, … })` — return it (for the macro
|
|
53
|
+
* to register and inline into `...frag(g)` spreads). Otherwise null.
|
|
54
|
+
*/
|
|
55
|
+
export declare function asFragmentFactory(expr: Expression): FactoryAst | null;
|
|
31
56
|
/**
|
|
32
57
|
* Evaluate a `parser(g => { ... return { ruleName: combinator, ... } })` call.
|
|
33
58
|
* Returns a map of rule names → defined Combinators, or null if the factory
|
|
@@ -43,7 +68,8 @@ export declare function evaluateCombinatorArray(node: Expression, scope: Scope,
|
|
|
43
68
|
* The body-phase entries are stored as `mfSrcs` on localScope entries and
|
|
44
69
|
* replayed when those entries are referenced during return evaluation.
|
|
45
70
|
*/
|
|
46
|
-
export declare function evaluateParserFactory(factoryNode: Expression, scope: Scope, code: string, mapFnSources: string[]
|
|
71
|
+
export declare function evaluateParserFactory(factoryNode: Expression, scope: Scope, code: string, mapFnSources: string[], // receives ONLY the return-expression mfSrcs
|
|
72
|
+
resolveFactory?: FactoryResolver): Map<string, Combinator<unknown>> | null;
|
|
47
73
|
/** A combinator slot created by ref() — has a callable `define`. */
|
|
48
74
|
type DefinableRef = Combinator<unknown> & {
|
|
49
75
|
define(p: Combinator<unknown>): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../src/plugin/evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,UAAU,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../src/plugin/evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,UAAU,EAAE,IAAI,EAChB,uBAAuB,EAAE,QAAQ,IAAI,WAAW,EAKjD,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;AAM3C,KAAK,gBAAgB,GAAG;IAAE,GAAG,EAAE,aAAa,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAA;AAqVhE,0EAA0E;AAC1E,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,KAAK,EACZ,IAAI,CAAC,EAAE,MAAM,GACZ,gBAAgB,GAAG,IAAI,CAUzB;AAED,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,OA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