parseman 0.42.0 → 0.42.1
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/combinators/parser.d.ts +6 -0
- package/dist/combinators/parser.d.ts.map +1 -1
- package/dist/compiler/codegen.d.ts +2 -0
- package/dist/compiler/codegen.d.ts.map +1 -1
- package/dist/compiler/linker.d.ts +1 -0
- package/dist/compiler/linker.d.ts.map +1 -1
- package/dist/index.cjs +149 -112
- package/dist/index.cjs.map +3 -3
- package/dist/index.js +149 -112
- package/dist/index.js.map +3 -3
- package/dist/language-service/index.cjs.map +1 -1
- package/dist/language-service/index.js.map +1 -1
- package/dist/plugin/index.cjs +336 -100
- package/dist/plugin/index.cjs.map +4 -4
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +336 -100
- package/dist/plugin/index.js.map +4 -4
- package/dist/spec/index.cjs +322 -307
- package/dist/spec/index.cjs.map +4 -4
- package/dist/spec/index.js +322 -307
- package/dist/spec/index.js.map +4 -4
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -71,6 +71,12 @@ export type RulesOptions = {
|
|
|
71
71
|
* quietly producing the wrong tree shape.
|
|
72
72
|
*/
|
|
73
73
|
hostMode?: HostMode;
|
|
74
|
+
/**
|
|
75
|
+
* Compile-time line tracking for this grammar. Under the macro this emits a
|
|
76
|
+
* separate line-aware artifact from the same factory; the default artifact
|
|
77
|
+
* remains free of line-tracking helpers and branches.
|
|
78
|
+
*/
|
|
79
|
+
trackLines?: boolean;
|
|
74
80
|
};
|
|
75
81
|
export declare function rules<T extends Record<string, Combinator<unknown>>>(factory: (self: any) => T): T;
|
|
76
82
|
export declare function rules<T extends Record<string, Combinator<unknown>>>(options: RulesOptions, factory: (self: any) => T): T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/combinators/parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/combinators/parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAKtD;;;;GAIG;AACH,eAAO,MAAM,UAAU,wBAAwB,CAAA;AA0B/C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;8EAC0E;IAC1E,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,CAAA;IACnC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAA;IACvC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAA;AAKD,wBAAgB,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,CAAA;AAClG,wBAAgB,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,CAAA"}
|
|
@@ -200,6 +200,7 @@ export declare function compileRuleMap(ruleMap: ReadonlyArray<readonly [string,
|
|
|
200
200
|
scanSkip?: Combinator<unknown>[];
|
|
201
201
|
recovery?: boolean;
|
|
202
202
|
hostMode?: HostMode;
|
|
203
|
+
trackLines?: boolean;
|
|
203
204
|
coverage?: boolean;
|
|
204
205
|
gating?: GatingOption;
|
|
205
206
|
duplication?: DuplicationOption;
|
|
@@ -288,6 +289,7 @@ export declare function compileLinkable(ruleMapArg: ReadonlyArray<readonly [stri
|
|
|
288
289
|
scanSkip?: Combinator<unknown>[];
|
|
289
290
|
recovery?: boolean;
|
|
290
291
|
hostMode?: HostMode;
|
|
292
|
+
trackLines?: boolean;
|
|
291
293
|
captureTerminals?: boolean;
|
|
292
294
|
coverage?: GrammarCoveragePlan;
|
|
293
295
|
gating?: GatingOption;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../src/compiler/codegen.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,UAAU,EAAa,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAA4B,MAAM,aAAa,CAAA;AAKnI,OAAO,EAA4B,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC7E,OAAO,EAA2D,KAAK,YAAY,EAAE,KAAK,eAAe,EAAqB,MAAM,uBAAuB,CAAA;AAC3J,OAAO,EAA2H,KAAK,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAE/L;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAOH,MAAM,MAAM,WAAW,GAAG;IAAE,GAAG,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAC5E,MAAM,MAAM,cAAc,GAAG;IAAE,IAAI,EAAE,WAAW,EAAE,EAAE,CAAA;CAAE,CAAA;AACtD,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,IAAI,GAAE,GAAG,CAAC,UAAU,CAAC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C,OAAO,CAAC,EAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAAC,MAAM,CAAC,EAAE,YAAY,CAAC;IAAC,WAAW,CAAC,EAAE,iBAAiB,CAAA;CAAE,GAC3P,cAAc,GAAG,IAAI,CAsQvB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,GAC7D,OAAO,CAeT"}
|
|
@@ -86,6 +86,7 @@ export declare function composedPiecesOf(grammar: Record<string, unknown>): Read
|
|
|
86
86
|
export type IRPiece = {
|
|
87
87
|
ns: string;
|
|
88
88
|
ir: string;
|
|
89
|
+
trackLines?: true;
|
|
89
90
|
};
|
|
90
91
|
/** Memoize a zero-arg thunk, keeping it LAZY. Used where two diagnostic thunks want
|
|
91
92
|
* the same carried-IR hydration: the work must not happen when the diagnostic is off,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linker.d.ts","sourceRoot":"","sources":["../../src/compiler/linker.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,cAAc,EAAkB,QAAQ,EAAE,MAAM,cAAc,CAAA;AAG5E,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,oBAAoB,EAAY,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAanH,wBAAgB,QAAQ,CACtB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,EAC7C,EAAE,CAAC,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,EAK5B,QAAQ,CAAC,EAAE,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AK,CAAC,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACtD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAE3B"}
|
package/dist/index.cjs
CHANGED
|
@@ -2898,6 +2898,101 @@ function markUnusedValues(root) {
|
|
|
2898
2898
|
visit(resolveRoot(root), true);
|
|
2899
2899
|
}
|
|
2900
2900
|
|
|
2901
|
+
// src/combinators/grammar.ts
|
|
2902
|
+
function annotateResultLines(result, index) {
|
|
2903
|
+
const annotated = { ...result, span: annotateSpan(result.span, index) };
|
|
2904
|
+
const errors = annotated.errors;
|
|
2905
|
+
if (errors) {
|
|
2906
|
+
;
|
|
2907
|
+
annotated.errors = errors.map((error) => ({
|
|
2908
|
+
...error,
|
|
2909
|
+
span: annotateSpan(error.span, index)
|
|
2910
|
+
}));
|
|
2911
|
+
}
|
|
2912
|
+
return annotated;
|
|
2913
|
+
}
|
|
2914
|
+
function createParseLineContext(input, pos) {
|
|
2915
|
+
const lineIndex = createLineIndex();
|
|
2916
|
+
if (pos > 0) recordLineRange(lineIndex, input, 0, pos);
|
|
2917
|
+
return { lineIndex, lineScannedTo: pos };
|
|
2918
|
+
}
|
|
2919
|
+
function parser(opts, root) {
|
|
2920
|
+
const clearTrivia = opts.trivia === null;
|
|
2921
|
+
return {
|
|
2922
|
+
_tag: "grammar",
|
|
2923
|
+
_meta: root._meta,
|
|
2924
|
+
_def: {
|
|
2925
|
+
tag: "grammar",
|
|
2926
|
+
parser: root,
|
|
2927
|
+
triviaParser: clearTrivia ? void 0 : opts.trivia ?? void 0,
|
|
2928
|
+
clearTrivia,
|
|
2929
|
+
...opts.captureTrivia ? { captureTrivia: true } : {},
|
|
2930
|
+
trackLines: opts.trackLines ?? false
|
|
2931
|
+
},
|
|
2932
|
+
parse(input, pos, _ctx) {
|
|
2933
|
+
const trackLines = opts.trackLines ?? _ctx?.trackLines ?? false;
|
|
2934
|
+
const lineContext = trackLines && _ctx?._lineIndex === void 0 && _ctx?._lineStarts === void 0 ? createParseLineContext(input, pos ?? 0) : void 0;
|
|
2935
|
+
const lineIndex = trackLines ? _ctx?._lineIndex ?? (_ctx?._lineStarts ? { lineStarts: _ctx._lineStarts } : lineContext.lineIndex) : void 0;
|
|
2936
|
+
const ctx = {
|
|
2937
|
+
..._ctx,
|
|
2938
|
+
trackLines,
|
|
2939
|
+
...lineIndex ? { _lineIndex: lineIndex } : {},
|
|
2940
|
+
...lineContext ? { _lineScannedTo: lineContext.lineScannedTo } : {},
|
|
2941
|
+
// trivia: null clears (contiguous terms); a Combinator sets; undefined inherits.
|
|
2942
|
+
...clearTrivia ? {
|
|
2943
|
+
trivia: void 0,
|
|
2944
|
+
triviaKindLabels: void 0
|
|
2945
|
+
} : opts.trivia != null ? {
|
|
2946
|
+
trivia: opts.trivia,
|
|
2947
|
+
...opts.trivia._meta.triviaKindLabels ? { triviaKindLabels: opts.trivia._meta.triviaKindLabels } : {}
|
|
2948
|
+
} : {},
|
|
2949
|
+
...opts.captureTrivia || _ctx?.captureTrivia ? { captureTrivia: true } : {},
|
|
2950
|
+
// Kind-filter for per-node capture. Resolve against this scope's trivia
|
|
2951
|
+
// labels — this parser's own trivia if it declares one, else the INHERITED
|
|
2952
|
+
// labels (`_ctx.triviaKindLabels`), so captureTriviaKinds still applies when
|
|
2953
|
+
// trivia is inherited rather than re-declared here. No labels → undefined
|
|
2954
|
+
// (capture all).
|
|
2955
|
+
...opts.captureTriviaKinds && !clearTrivia ? { _triviaCaptureMask: triviaKindMask(opts.trivia?._meta.triviaKindLabels ?? _ctx?.triviaKindLabels, opts.captureTriviaKinds) } : {}
|
|
2956
|
+
};
|
|
2957
|
+
const result = root.parse(input, pos ?? 0, ctx);
|
|
2958
|
+
if (trackLines && _ctx && ctx._lineScannedTo !== void 0) {
|
|
2959
|
+
_ctx._lineScannedTo = Math.max(_ctx._lineScannedTo ?? 0, ctx._lineScannedTo);
|
|
2960
|
+
}
|
|
2961
|
+
return lineIndex ? annotateResultLines(result, normalizeLineIndex(lineIndex)) : result;
|
|
2962
|
+
}
|
|
2963
|
+
};
|
|
2964
|
+
}
|
|
2965
|
+
function noTrivia(root) {
|
|
2966
|
+
return parser({ trivia: null }, root);
|
|
2967
|
+
}
|
|
2968
|
+
var _analyzed = /* @__PURE__ */ new WeakSet();
|
|
2969
|
+
function parse(combinator, input, opts = {}) {
|
|
2970
|
+
if (!_analyzed.has(combinator)) {
|
|
2971
|
+
_analyzed.add(combinator);
|
|
2972
|
+
markUnusedValues(combinator);
|
|
2973
|
+
}
|
|
2974
|
+
const trackLines = opts.trackLines ?? combinator._meta.grammarTrackLines ?? false;
|
|
2975
|
+
const lineContext = trackLines ? createParseLineContext(input, 0) : void 0;
|
|
2976
|
+
const lineIndex = lineContext?.lineIndex;
|
|
2977
|
+
const _errors = opts.recover ? [] : void 0;
|
|
2978
|
+
const _probe = opts.recover ? { offset: input.length, best: null } : void 0;
|
|
2979
|
+
const grammarTrivia = combinator._meta.grammarTrivia;
|
|
2980
|
+
const grammarScanSkip = combinator._meta.grammarScanSkip;
|
|
2981
|
+
const ctx = {
|
|
2982
|
+
trackLines,
|
|
2983
|
+
...lineIndex ? { _lineIndex: lineIndex } : {},
|
|
2984
|
+
...lineContext ? { _lineScannedTo: lineContext.lineScannedTo } : {},
|
|
2985
|
+
...grammarTrivia !== void 0 ? { trivia: grammarTrivia, ...grammarTrivia._meta.triviaKindLabels ? { triviaKindLabels: grammarTrivia._meta.triviaKindLabels } : {} } : {},
|
|
2986
|
+
...grammarScanSkip !== void 0 ? { scanSkip: grammarScanSkip } : {},
|
|
2987
|
+
..._errors !== void 0 ? { _errors } : {},
|
|
2988
|
+
..._probe !== void 0 ? { _probe } : {}
|
|
2989
|
+
};
|
|
2990
|
+
const result = combinator.parse(input, 0, ctx);
|
|
2991
|
+
if (!result.ok) return lineIndex ? annotateResultLines(result, normalizeLineIndex(lineIndex)) : result;
|
|
2992
|
+
const withErrors = _errors !== void 0 ? { ...result, errors: _errors, furthestFail: _probe?.best ?? null } : result;
|
|
2993
|
+
return lineIndex ? annotateResultLines(withErrors, normalizeLineIndex(lineIndex)) : withErrors;
|
|
2994
|
+
}
|
|
2995
|
+
|
|
2901
2996
|
// src/combinators/parser.ts
|
|
2902
2997
|
var RULE_ORDER = "__parsemanRuleOrder";
|
|
2903
2998
|
function tagRule(r, key) {
|
|
@@ -2973,6 +3068,21 @@ function rules(a, b) {
|
|
|
2973
3068
|
if (rule && !rule._meta.isTrivia) rule._meta.grammarHostMode = "cst";
|
|
2974
3069
|
}
|
|
2975
3070
|
}
|
|
3071
|
+
if (options?.trackLines === true) {
|
|
3072
|
+
for (const key of Object.keys(definitions)) {
|
|
3073
|
+
const rule = cache[key];
|
|
3074
|
+
if (rule && !rule._meta.isTrivia) rule._meta.grammarTrackLines = true;
|
|
3075
|
+
}
|
|
3076
|
+
for (const key of Object.keys(definitions)) {
|
|
3077
|
+
const rule = cache[key];
|
|
3078
|
+
if (rule && !rule._meta.isTrivia && rule._def.tag !== "grammar") {
|
|
3079
|
+
const wrapped = parser({ trackLines: true }, rule);
|
|
3080
|
+
tagRule(wrapped, key);
|
|
3081
|
+
wrapped._meta.grammarTrackLines = true;
|
|
3082
|
+
cache[key] = wrapped;
|
|
3083
|
+
}
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
2976
3086
|
for (const key of Object.keys(definitions)) {
|
|
2977
3087
|
markUnusedValues(cache[key]);
|
|
2978
3088
|
}
|
|
@@ -3429,101 +3539,6 @@ function field(name, combinator) {
|
|
|
3429
3539
|
};
|
|
3430
3540
|
}
|
|
3431
3541
|
|
|
3432
|
-
// src/combinators/grammar.ts
|
|
3433
|
-
function annotateResultLines(result, index) {
|
|
3434
|
-
const annotated = { ...result, span: annotateSpan(result.span, index) };
|
|
3435
|
-
const errors = annotated.errors;
|
|
3436
|
-
if (errors) {
|
|
3437
|
-
;
|
|
3438
|
-
annotated.errors = errors.map((error) => ({
|
|
3439
|
-
...error,
|
|
3440
|
-
span: annotateSpan(error.span, index)
|
|
3441
|
-
}));
|
|
3442
|
-
}
|
|
3443
|
-
return annotated;
|
|
3444
|
-
}
|
|
3445
|
-
function createParseLineContext(input, pos) {
|
|
3446
|
-
const lineIndex = createLineIndex();
|
|
3447
|
-
if (pos > 0) recordLineRange(lineIndex, input, 0, pos);
|
|
3448
|
-
return { lineIndex, lineScannedTo: pos };
|
|
3449
|
-
}
|
|
3450
|
-
function parser(opts, root) {
|
|
3451
|
-
const clearTrivia = opts.trivia === null;
|
|
3452
|
-
return {
|
|
3453
|
-
_tag: "grammar",
|
|
3454
|
-
_meta: root._meta,
|
|
3455
|
-
_def: {
|
|
3456
|
-
tag: "grammar",
|
|
3457
|
-
parser: root,
|
|
3458
|
-
triviaParser: clearTrivia ? void 0 : opts.trivia ?? void 0,
|
|
3459
|
-
clearTrivia,
|
|
3460
|
-
...opts.captureTrivia ? { captureTrivia: true } : {},
|
|
3461
|
-
trackLines: opts.trackLines ?? false
|
|
3462
|
-
},
|
|
3463
|
-
parse(input, pos, _ctx) {
|
|
3464
|
-
const trackLines = opts.trackLines ?? _ctx?.trackLines ?? false;
|
|
3465
|
-
const lineContext = trackLines && _ctx?._lineIndex === void 0 && _ctx?._lineStarts === void 0 ? createParseLineContext(input, pos ?? 0) : void 0;
|
|
3466
|
-
const lineIndex = trackLines ? _ctx?._lineIndex ?? (_ctx?._lineStarts ? { lineStarts: _ctx._lineStarts } : lineContext.lineIndex) : void 0;
|
|
3467
|
-
const ctx = {
|
|
3468
|
-
..._ctx,
|
|
3469
|
-
trackLines,
|
|
3470
|
-
...lineIndex ? { _lineIndex: lineIndex } : {},
|
|
3471
|
-
...lineContext ? { _lineScannedTo: lineContext.lineScannedTo } : {},
|
|
3472
|
-
// trivia: null clears (contiguous terms); a Combinator sets; undefined inherits.
|
|
3473
|
-
...clearTrivia ? {
|
|
3474
|
-
trivia: void 0,
|
|
3475
|
-
triviaKindLabels: void 0
|
|
3476
|
-
} : opts.trivia != null ? {
|
|
3477
|
-
trivia: opts.trivia,
|
|
3478
|
-
...opts.trivia._meta.triviaKindLabels ? { triviaKindLabels: opts.trivia._meta.triviaKindLabels } : {}
|
|
3479
|
-
} : {},
|
|
3480
|
-
...opts.captureTrivia || _ctx?.captureTrivia ? { captureTrivia: true } : {},
|
|
3481
|
-
// Kind-filter for per-node capture. Resolve against this scope's trivia
|
|
3482
|
-
// labels — this parser's own trivia if it declares one, else the INHERITED
|
|
3483
|
-
// labels (`_ctx.triviaKindLabels`), so captureTriviaKinds still applies when
|
|
3484
|
-
// trivia is inherited rather than re-declared here. No labels → undefined
|
|
3485
|
-
// (capture all).
|
|
3486
|
-
...opts.captureTriviaKinds && !clearTrivia ? { _triviaCaptureMask: triviaKindMask(opts.trivia?._meta.triviaKindLabels ?? _ctx?.triviaKindLabels, opts.captureTriviaKinds) } : {}
|
|
3487
|
-
};
|
|
3488
|
-
const result = root.parse(input, pos ?? 0, ctx);
|
|
3489
|
-
if (trackLines && _ctx && ctx._lineScannedTo !== void 0) {
|
|
3490
|
-
_ctx._lineScannedTo = Math.max(_ctx._lineScannedTo ?? 0, ctx._lineScannedTo);
|
|
3491
|
-
}
|
|
3492
|
-
return lineIndex ? annotateResultLines(result, normalizeLineIndex(lineIndex)) : result;
|
|
3493
|
-
}
|
|
3494
|
-
};
|
|
3495
|
-
}
|
|
3496
|
-
function noTrivia(root) {
|
|
3497
|
-
return parser({ trivia: null }, root);
|
|
3498
|
-
}
|
|
3499
|
-
var _analyzed = /* @__PURE__ */ new WeakSet();
|
|
3500
|
-
function parse(combinator, input, opts = {}) {
|
|
3501
|
-
if (!_analyzed.has(combinator)) {
|
|
3502
|
-
_analyzed.add(combinator);
|
|
3503
|
-
markUnusedValues(combinator);
|
|
3504
|
-
}
|
|
3505
|
-
const trackLines = opts.trackLines ?? false;
|
|
3506
|
-
const lineContext = trackLines ? createParseLineContext(input, 0) : void 0;
|
|
3507
|
-
const lineIndex = lineContext?.lineIndex;
|
|
3508
|
-
const _errors = opts.recover ? [] : void 0;
|
|
3509
|
-
const _probe = opts.recover ? { offset: input.length, best: null } : void 0;
|
|
3510
|
-
const grammarTrivia = combinator._meta.grammarTrivia;
|
|
3511
|
-
const grammarScanSkip = combinator._meta.grammarScanSkip;
|
|
3512
|
-
const ctx = {
|
|
3513
|
-
trackLines,
|
|
3514
|
-
...lineIndex ? { _lineIndex: lineIndex } : {},
|
|
3515
|
-
...lineContext ? { _lineScannedTo: lineContext.lineScannedTo } : {},
|
|
3516
|
-
...grammarTrivia !== void 0 ? { trivia: grammarTrivia, ...grammarTrivia._meta.triviaKindLabels ? { triviaKindLabels: grammarTrivia._meta.triviaKindLabels } : {} } : {},
|
|
3517
|
-
...grammarScanSkip !== void 0 ? { scanSkip: grammarScanSkip } : {},
|
|
3518
|
-
..._errors !== void 0 ? { _errors } : {},
|
|
3519
|
-
..._probe !== void 0 ? { _probe } : {}
|
|
3520
|
-
};
|
|
3521
|
-
const result = combinator.parse(input, 0, ctx);
|
|
3522
|
-
if (!result.ok) return lineIndex ? annotateResultLines(result, normalizeLineIndex(lineIndex)) : result;
|
|
3523
|
-
const withErrors = _errors !== void 0 ? { ...result, errors: _errors, furthestFail: _probe?.best ?? null } : result;
|
|
3524
|
-
return lineIndex ? annotateResultLines(withErrors, normalizeLineIndex(lineIndex)) : withErrors;
|
|
3525
|
-
}
|
|
3526
|
-
|
|
3527
3542
|
// src/combinators/token.ts
|
|
3528
3543
|
function token(root) {
|
|
3529
3544
|
const meta = {
|
|
@@ -3620,7 +3635,7 @@ function leaf(root, fn) {
|
|
|
3620
3635
|
}
|
|
3621
3636
|
|
|
3622
3637
|
// src/version.ts
|
|
3623
|
-
var PARSEMAN_VERSION = "0.42.
|
|
3638
|
+
var PARSEMAN_VERSION = "0.42.1";
|
|
3624
3639
|
|
|
3625
3640
|
// src/cst/host-mode.ts
|
|
3626
3641
|
var FUSED_HOST_MODE = /* @__PURE__ */ Symbol.for("parseman.fusedHostMode");
|
|
@@ -6980,13 +6995,16 @@ function reindentStmts(stmts, targetLevels) {
|
|
|
6980
6995
|
const targetPrefix = " ".repeat(targetLevels);
|
|
6981
6996
|
return stmts.map((s) => s.trim().length === 0 ? "" : targetPrefix + s.slice(minLeading));
|
|
6982
6997
|
}
|
|
6983
|
-
function failReturn(expected, posExpr) {
|
|
6998
|
+
function failReturn(ctx, expected, posExpr) {
|
|
6999
|
+
if (ctx.lineTracking) return `return { ok: false, expected: [${expected}], span: ${emitSpanExpr(ctx, posExpr, posExpr)} }`;
|
|
6984
7000
|
return `return { ok: false, expected: [${expected}], span: { start: ${posExpr}, end: ${posExpr} } }`;
|
|
6985
7001
|
}
|
|
6986
|
-
function failReturnArr(expectedArr, posExpr) {
|
|
7002
|
+
function failReturnArr(ctx, expectedArr, posExpr) {
|
|
7003
|
+
if (ctx.lineTracking) return `return { ok: false, expected: ${expectedArr}, span: ${emitSpanExpr(ctx, posExpr, posExpr)} }`;
|
|
6987
7004
|
return `return { ok: false, expected: ${expectedArr}, span: { start: ${posExpr}, end: ${posExpr} } }`;
|
|
6988
7005
|
}
|
|
6989
|
-
function committedReturnArr(expectedArr, posExpr) {
|
|
7006
|
+
function committedReturnArr(ctx, expectedArr, posExpr) {
|
|
7007
|
+
if (ctx.lineTracking) return `return { ok: false, expected: [...${expectedArr}], span: ${emitSpanExpr(ctx, posExpr, posExpr)}, committed: true }`;
|
|
6990
7008
|
return `return { ok: false, expected: [...${expectedArr}], span: { start: ${posExpr}, end: ${posExpr} }, committed: true }`;
|
|
6991
7009
|
}
|
|
6992
7010
|
function hoistExpected(ctx, constArrSource) {
|
|
@@ -7011,7 +7029,7 @@ function failBody(ctx, expected, posExpr) {
|
|
|
7011
7029
|
if (!ctx.recordFail) return probe ? `{ ${probe}${trace}break ${ctx.failLabel} }` : trace ? `{ ${trace}break ${ctx.failLabel} }` : `break ${ctx.failLabel}`;
|
|
7012
7030
|
return `{ ${probe}_ctx._fe = ${posExpr}; _ctx._fx = ${hoistExpected(ctx, `[${expected}]`)}; ${trace}break ${ctx.failLabel} }`;
|
|
7013
7031
|
}
|
|
7014
|
-
return probe + trace + failReturn(expected, posExpr);
|
|
7032
|
+
return probe + trace + failReturn(ctx, expected, posExpr);
|
|
7015
7033
|
}
|
|
7016
7034
|
function failArrBody(ctx, expectedArr, posExpr, constant = true) {
|
|
7017
7035
|
const probe = probeUpdate(ctx, expectedArr, posExpr, constant);
|
|
@@ -7021,18 +7039,19 @@ function failArrBody(ctx, expectedArr, posExpr, constant = true) {
|
|
|
7021
7039
|
const fx = constant ? hoistExpected(ctx, expectedArr) : expectedArr;
|
|
7022
7040
|
return `{ ${probe}_ctx._fe = ${posExpr}; _ctx._fx = ${fx}; ${trace}break ${ctx.failLabel} }`;
|
|
7023
7041
|
}
|
|
7024
|
-
if (!constant) return `${probe}${trace}return { ok: false, expected: [...${expectedArr}], span: { start: ${posExpr}, end: ${posExpr} } }`;
|
|
7025
|
-
return probe + trace + failReturnArr(expectedArr, posExpr);
|
|
7042
|
+
if (!constant) return `${probe}${trace}return { ok: false, expected: [...${expectedArr}], span: ${ctx.lineTracking ? emitSpanExpr(ctx, posExpr, posExpr) : `{ start: ${posExpr}, end: ${posExpr} }`} }`;
|
|
7043
|
+
return probe + trace + failReturnArr(ctx, expectedArr, posExpr);
|
|
7026
7044
|
}
|
|
7027
|
-
function resultFromRecorded(feExpr = "_ctx._fe", fxExpr = "_ctx._fx") {
|
|
7028
|
-
|
|
7045
|
+
function resultFromRecorded(ctx, feExpr = "_ctx._fe", fxExpr = "_ctx._fx") {
|
|
7046
|
+
const spanExpr = ctx.lineTracking ? emitSpanExpr(ctx, feExpr, feExpr) : `{ start: ${feExpr}, end: ${feExpr} }`;
|
|
7047
|
+
return `return { ok: false, expected: [...${fxExpr}], span: ${spanExpr}, ...(_ctx._fc ? { committed: true } : {}) }`;
|
|
7029
7048
|
}
|
|
7030
7049
|
function committedFailBody(ctx, expectedArr = "_ctx._fx", posExpr = "_ctx._fe") {
|
|
7031
7050
|
if (ctx.failLabel) {
|
|
7032
7051
|
if (!ctx.recordFail) return `{ _ctx._fc = true; break ${ctx.failLabel} }`;
|
|
7033
7052
|
return `{ _ctx._fc = true; _ctx._fe = ${posExpr}; _ctx._fx = ${expectedArr}; break ${ctx.failLabel} }`;
|
|
7034
7053
|
}
|
|
7035
|
-
return committedReturnArr(expectedArr, posExpr);
|
|
7054
|
+
return committedReturnArr(ctx, expectedArr, posExpr);
|
|
7036
7055
|
}
|
|
7037
7056
|
function propagateFailBody(ctx, srcCtx = "_ctx") {
|
|
7038
7057
|
if (srcCtx !== "_ctx") {
|
|
@@ -7040,10 +7059,10 @@ function propagateFailBody(ctx, srcCtx = "_ctx") {
|
|
|
7040
7059
|
if (!ctx.recordFail) return `break ${ctx.failLabel}`;
|
|
7041
7060
|
return `{ _ctx._fe = ${srcCtx}._fe; _ctx._fx = ${srcCtx}._fx; _ctx._fc = ${srcCtx}._fc; break ${ctx.failLabel} }`;
|
|
7042
7061
|
}
|
|
7043
|
-
return `{ _ctx._fe = ${srcCtx}._fe; _ctx._fx = ${srcCtx}._fx; _ctx._fc = ${srcCtx}._fc; ${resultFromRecorded()} }`;
|
|
7062
|
+
return `{ _ctx._fe = ${srcCtx}._fe; _ctx._fx = ${srcCtx}._fx; _ctx._fc = ${srcCtx}._fc; ${resultFromRecorded(ctx)} }`;
|
|
7044
7063
|
}
|
|
7045
7064
|
if (ctx.failLabel) return `break ${ctx.failLabel}`;
|
|
7046
|
-
return resultFromRecorded();
|
|
7065
|
+
return resultFromRecorded(ctx);
|
|
7047
7066
|
}
|
|
7048
7067
|
function emitIfFail(ctx, cond, body) {
|
|
7049
7068
|
return [
|
|
@@ -8476,7 +8495,7 @@ function emitAttempt(p, def, ctx, pos) {
|
|
|
8476
8495
|
if (!ctx.recovery && !ctx.coverage && needsFirstSetGuard(def.parser)) {
|
|
8477
8496
|
const gcV = v(ctx, "_agc");
|
|
8478
8497
|
const gExp = armStaticExpected(ctx, def.parser);
|
|
8479
|
-
const gFail = ctx.failLabel ? `{ _ctx._fe = ${pos};${ctx.recordFail ? ` _ctx._fx = ${gExp};` : ""} break ${ctx.failLabel} }` : `{ _ctx._fe = ${pos}; ${failReturnArr(gExp, pos)} }`;
|
|
8498
|
+
const gFail = ctx.failLabel ? `{ _ctx._fe = ${pos};${ctx.recordFail ? ` _ctx._fx = ${gExp};` : ""} break ${ctx.failLabel} }` : `{ _ctx._fe = ${pos}; ${failReturnArr(ctx, gExp, pos)} }`;
|
|
8480
8499
|
preGuard.push(
|
|
8481
8500
|
`${ind(ctx)}const ${gcV} = ${pos} < input.length ? (input.codePointAt(${pos}) ?? -1) : -1`,
|
|
8482
8501
|
`${ind(ctx)}if (!(${firstSetCond(gcV, def.parser._meta.firstSet)})) ${gFail}`
|
|
@@ -8975,7 +8994,7 @@ ${i}const ${chV} = ${chAlloc}, ${rawV} = ${profileRecognizer} ? undefined : [],
|
|
|
8975
8994
|
if (!ctx.recovery && !ctx.coverage && (capturesChildren || structural) && needsFirstSetGuard(def.parser)) {
|
|
8976
8995
|
const gcV = v(ctx, "_ngc");
|
|
8977
8996
|
const gExp = armStaticExpected(ctx, def.parser);
|
|
8978
|
-
const gFail = ctx.failLabel ? ctx.recordFail ? `{ _ctx._fe = ${pos}; _ctx._fx = ${gExp}; break ${ctx.failLabel} }` : `break ${ctx.failLabel}` : failReturnArr(gExp, pos);
|
|
8997
|
+
const gFail = ctx.failLabel ? ctx.recordFail ? `{ _ctx._fe = ${pos}; _ctx._fx = ${gExp}; break ${ctx.failLabel} }` : `break ${ctx.failLabel}` : failReturnArr(ctx, gExp, pos);
|
|
8979
8998
|
preGuard.push(
|
|
8980
8999
|
`${i}const ${gcV} = ${pos} < input.length ? (input.codePointAt(${pos}) ?? -1) : -1`,
|
|
8981
9000
|
`${i}if (!(${firstSetCond(gcV, def.parser._meta.firstSet)})) ${gFail}`
|
|
@@ -9491,6 +9510,7 @@ function hasLineTrackingDef(p, seen = /* @__PURE__ */ new Set()) {
|
|
|
9491
9510
|
if (seen.has(p)) return false;
|
|
9492
9511
|
seen.add(p);
|
|
9493
9512
|
const d = p._def;
|
|
9513
|
+
if (p._meta.grammarTrackLines) return true;
|
|
9494
9514
|
if (d.tag === "grammar" && d.trackLines) return true;
|
|
9495
9515
|
if (d.tag === "lazy") {
|
|
9496
9516
|
try {
|
|
@@ -9848,6 +9868,7 @@ function compile(combinator, mapFnSources, opts) {
|
|
|
9848
9868
|
const grammarTrivia = combinator._meta.grammarTrivia;
|
|
9849
9869
|
const grammarScanSkip = combinator._meta.grammarScanSkip;
|
|
9850
9870
|
const grammarHostMode = combinator._meta.grammarHostMode;
|
|
9871
|
+
const grammarTrackLines = combinator._meta.grammarTrackLines;
|
|
9851
9872
|
const ctx = {
|
|
9852
9873
|
vars: 0,
|
|
9853
9874
|
indent: 1,
|
|
@@ -9868,7 +9889,7 @@ function compile(combinator, mapFnSources, opts) {
|
|
|
9868
9889
|
capturing: hasNodeDef(combinator),
|
|
9869
9890
|
recovery: opts?.recovery ?? false,
|
|
9870
9891
|
hostMode: opts?.hostMode ?? grammarHostMode ?? "ast",
|
|
9871
|
-
lineTracking: opts?.trackLines === true || hasLineTrackingDef(combinator),
|
|
9892
|
+
lineTracking: opts?.trackLines === true || grammarTrackLines === true || hasLineTrackingDef(combinator),
|
|
9872
9893
|
...opts?.coverage ? { coverage: { plan: buildGrammarPlan(combinator), entry: combinator } } : {},
|
|
9873
9894
|
lazyUsage: analyzeLazyUsage(combinator),
|
|
9874
9895
|
...grammarTrivia ? { activeTrivia: grammarTrivia, triviaKindLabels: grammarTrivia._meta.triviaKindLabels } : {},
|
|
@@ -10032,6 +10053,7 @@ function compileLinkable(ruleMapArg, ns, opts) {
|
|
|
10032
10053
|
const grammarTrivia = opts?.trivia ?? ruleMapArg.map(([, r]) => r._meta.grammarTrivia).find(Boolean);
|
|
10033
10054
|
const grammarScanSkip = opts?.scanSkip ?? ruleMapArg.map(([, r]) => r._meta.grammarScanSkip).find(Boolean);
|
|
10034
10055
|
const grammarHostMode = opts?.hostMode ?? ruleMapArg.map(([, r]) => r._meta.grammarHostMode).find(Boolean);
|
|
10056
|
+
const grammarTrackLines = opts?.trackLines === true || ruleMapArg.some(([, r]) => r._meta.grammarTrackLines === true);
|
|
10035
10057
|
const ruleMap = ruleMapArg.filter(([, val]) => {
|
|
10036
10058
|
const d = val._def;
|
|
10037
10059
|
if (d.tag !== "lazy") return true;
|
|
@@ -10066,6 +10088,7 @@ function compileLinkable(ruleMapArg, ns, opts) {
|
|
|
10066
10088
|
capturing: opts?.captureTerminals === true || ruleMap.some(([, rule]) => hasNodeDef(rule)),
|
|
10067
10089
|
recovery: opts?.recovery ?? false,
|
|
10068
10090
|
hostMode: grammarHostMode ?? "ast",
|
|
10091
|
+
lineTracking: grammarTrackLines,
|
|
10069
10092
|
...opts?.coverage ? { coverage: { plan: opts.coverage } } : {},
|
|
10070
10093
|
lazyUsage: analyzeLazyUsageMulti(ruleMap.map(([, rule]) => rule)),
|
|
10071
10094
|
ns,
|
|
@@ -10162,6 +10185,10 @@ function compileLinkable(ruleMapArg, ns, opts) {
|
|
|
10162
10185
|
perEntry.push({ key, rule, r: emitNamedFnCall(ctx, fn, "_pos") });
|
|
10163
10186
|
}
|
|
10164
10187
|
if (ctx.runtimeParsers.length !== 0) return null;
|
|
10188
|
+
if (ctx.lineTracking) {
|
|
10189
|
+
ctx.needsLineTrack = true;
|
|
10190
|
+
ctx.needsLineSpan = true;
|
|
10191
|
+
}
|
|
10165
10192
|
const mfSrcs = ctx.mapFns.length > 0 && ctx.mapFnSrcs.every((s) => s !== null) ? ctx.mapFnSrcs : null;
|
|
10166
10193
|
const buildSrcs = ctx.buildFns.length > 0 && ctx.buildSrcs.every((s) => s !== null) ? ctx.buildSrcs : null;
|
|
10167
10194
|
const ruleFns = /* @__PURE__ */ new Map();
|
|
@@ -10175,6 +10202,8 @@ function compileLinkable(ruleMapArg, ns, opts) {
|
|
|
10175
10202
|
const mfDecl = ctx.mapFns.length === 0 ? "" : mfSrcs ? `const ${mfRef(ctx)} = [${mfSrcs.join(", ")}]` : `const ${mfRef(ctx)} = _env[${JSON.stringify(nsp(ctx) + "mf")}]`;
|
|
10176
10203
|
const buildDecl = ctx.buildFns.length === 0 ? "" : buildSrcs ? `const ${buildRef(ctx)} = [${buildSrcs.join(", ")}]` : `const ${buildRef(ctx)} = _env[${JSON.stringify(nsp(ctx) + "build")}]`;
|
|
10177
10204
|
const prelude = [
|
|
10205
|
+
ctx.needsLineTrack ? LINE_TRACK_DECL : "",
|
|
10206
|
+
ctx.needsLineSpan ? LINE_SPAN_DECL : "",
|
|
10178
10207
|
...ctx.regexDecls,
|
|
10179
10208
|
...ctx.expectedDecls,
|
|
10180
10209
|
mfDecl,
|
|
@@ -10183,11 +10212,18 @@ function compileLinkable(ruleMapArg, ns, opts) {
|
|
|
10183
10212
|
].filter(Boolean);
|
|
10184
10213
|
const wrappers = /* @__PURE__ */ new Map();
|
|
10185
10214
|
for (const { key, rule, r } of perEntry) {
|
|
10215
|
+
const linePreamble = ctx.lineTracking ? [
|
|
10216
|
+
` if (_ctx._lineStarts === undefined) _ctx = { ..._ctx, trackLines: true, _lineStarts: [0], _lineScannedTo: 0 }`,
|
|
10217
|
+
` else _ctx.trackLines = true`,
|
|
10218
|
+
` if (_pos > (_ctx._lineScannedTo ?? 0)) _trackLines(_ctx, input, 0, _pos)`
|
|
10219
|
+
] : [];
|
|
10220
|
+
const resultSpan = ctx.lineTracking ? `_spanLines(_ctx, _pos, ${r.endVar})` : `{ start: _pos, end: ${r.endVar} }`;
|
|
10186
10221
|
wrappers.set(key, publicRuleWrapperSource(rule, [
|
|
10187
10222
|
`function(input, _pos, _ctx) {`,
|
|
10223
|
+
...linePreamble,
|
|
10188
10224
|
` let pos = _pos`,
|
|
10189
10225
|
...r.stmts,
|
|
10190
|
-
` return { ok: true, value: ${r.valueVar}, span:
|
|
10226
|
+
` return { ok: true, value: ${r.valueVar}, span: ${resultSpan} }`,
|
|
10191
10227
|
`}`
|
|
10192
10228
|
].join("\n"), ctx.triviaKindLabels));
|
|
10193
10229
|
}
|
|
@@ -11075,7 +11111,8 @@ function materializePiece(p, trivia2, captureTerminals = false, hostMode) {
|
|
|
11075
11111
|
const pieces = compileLinkable(evalRuleMapIR(p.ir), p.ns, {
|
|
11076
11112
|
...trivia2 ? { trivia: trivia2 } : {},
|
|
11077
11113
|
...captureTerminals ? { captureTerminals: true } : {},
|
|
11078
|
-
...hostMode ? { hostMode } : {}
|
|
11114
|
+
...hostMode ? { hostMode } : {},
|
|
11115
|
+
...p.trackLines ? { trackLines: true } : {}
|
|
11079
11116
|
});
|
|
11080
11117
|
if (!pieces) throw new Error(`compose: carried IR for ns "${p.ns}" could not be re-lowered`);
|
|
11081
11118
|
return pieces;
|