parseman 0.61.1 → 0.61.2
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/analysis/diagnostics.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/plugin/index.d.ts +3 -1
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +33 -11
- package/dist/plugin/index.js.map +1 -1
- package/dist/table/index.js +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/plugin/index.ts +30 -13
- package/src/version.ts +1 -1
package/dist/cli/index.js
CHANGED
package/dist/index.js
CHANGED
package/dist/plugin/index.d.ts
CHANGED
|
@@ -84,7 +84,9 @@ export type AssemblyProfile = {
|
|
|
84
84
|
/** The rule each corpus file is parsed from, e.g. `'Stylesheet'`. A grammar
|
|
85
85
|
* without this rule keeps the static ranking. */
|
|
86
86
|
readonly entry: string;
|
|
87
|
-
/** Paths of representative inputs.
|
|
87
|
+
/** Paths of representative inputs. At least one must have content, and each that
|
|
88
|
+
* does has to parse in full without recovery, or the build fails. A file with only
|
|
89
|
+
* whitespace counts as empty. */
|
|
88
90
|
readonly files: readonly string[];
|
|
89
91
|
};
|
|
90
92
|
declare const _default: import("unplugin").UnpluginInstance<ParsecraftPluginOptions, boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAyBA,OAAO,WAAW,MAAM,cAAc,CAAA;AActC,OAAO,EAAsC,KAAK,OAAO,EAAE,MAAM,uBAAuB,CAAA;AA6BxF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AACzE;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG;IAAE,I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B,eAAe,CAAC,EAAE,eAAe,EACjC,cAAc,SAA0B,EACxC,WAAW,CAAC,EAAE,WAAW,GACxB,oBAAoB,GAAG,IAAI,CAW7B"}
|
package/dist/plugin/index.js
CHANGED
|
@@ -5619,7 +5619,7 @@ function sourceLeaf(root, fn) {
|
|
|
5619
5619
|
}
|
|
5620
5620
|
|
|
5621
5621
|
// src/version.ts
|
|
5622
|
-
var PARSEMAN_VERSION = "0.61.
|
|
5622
|
+
var PARSEMAN_VERSION = "0.61.2";
|
|
5623
5623
|
|
|
5624
5624
|
// src/table/lex-body.ts
|
|
5625
5625
|
function buildLexBodyRecognizer(spec, constants) {
|
|
@@ -24332,23 +24332,45 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
|
|
|
24332
24332
|
};
|
|
24333
24333
|
const profileOf = (compiled) => {
|
|
24334
24334
|
if (assemblyProfile === void 0 || compiled.hostMode !== "ast" || compiled.prog.lines === 1 || !(assemblyProfile.entry in compiled.prog.rules)) return void 0;
|
|
24335
|
-
|
|
24335
|
+
const refuse = (why) => {
|
|
24336
|
+
throw new Error(`${id} \u2014 assemblyProfile: ${why}`);
|
|
24337
|
+
};
|
|
24338
|
+
if (corpusTexts(assemblyProfile).every((text) => text.trim() === "")) refuse("`files` has no non-empty file");
|
|
24339
|
+
let thrower;
|
|
24336
24340
|
const fns = compiled.prog.fns.map((fn) => {
|
|
24337
24341
|
const type = fn?.[INERT_BUILDER];
|
|
24338
|
-
|
|
24342
|
+
if (type !== void 0) return (children3, _fields, span) => ({ type, span, children: children3 });
|
|
24343
|
+
return typeof fn !== "function" ? fn : new Proxy(fn, {
|
|
24344
|
+
apply(target, self, args) {
|
|
24345
|
+
try {
|
|
24346
|
+
return Reflect.apply(target, self, args);
|
|
24347
|
+
} catch (e) {
|
|
24348
|
+
thrower ??= target;
|
|
24349
|
+
throw e;
|
|
24350
|
+
}
|
|
24351
|
+
}
|
|
24352
|
+
});
|
|
24339
24353
|
});
|
|
24340
|
-
|
|
24354
|
+
return countSiteVisits(compiled.prog, (rules3) => {
|
|
24341
24355
|
const entry = rules3[assemblyProfile.entry];
|
|
24342
|
-
|
|
24356
|
+
corpusTexts(assemblyProfile).forEach((text, i) => {
|
|
24357
|
+
const file = assemblyProfile.files[i];
|
|
24358
|
+
if (text.trim() === "") return;
|
|
24359
|
+
let result2;
|
|
24343
24360
|
try {
|
|
24344
|
-
|
|
24345
|
-
} catch {
|
|
24361
|
+
result2 = run(entry, text);
|
|
24362
|
+
} catch (e) {
|
|
24363
|
+
const source = String(thrower).replace(/\s+/g, " ").slice(0, 200);
|
|
24364
|
+
throw new Error(`${id} \u2014 assemblyProfile: ${thrower === void 0 ? "the parse" : `gate or reducer \`${source}\``} threw on ${file}: ${String(e)}`, { cause: e });
|
|
24346
24365
|
}
|
|
24347
|
-
|
|
24366
|
+
if (!result2.ok || result2.unconsumedFrom !== null) {
|
|
24367
|
+
refuse(`${file} does not parse from rule "${assemblyProfile.entry}": it stops at offset ${result2.ok ? result2.unconsumedFrom : result2.span.end}`);
|
|
24368
|
+
}
|
|
24369
|
+
if (result2.errors.length > 0) {
|
|
24370
|
+
refuse(`${file} parses only by recovering from ${result2.errors.length} error(s), first at offset ${result2.errors[0].span.start}`);
|
|
24371
|
+
}
|
|
24372
|
+
});
|
|
24348
24373
|
}, fns);
|
|
24349
|
-
if (parsed > 0) return counts;
|
|
24350
|
-
warnings.push(`${id} \u2014 assemblyProfile: no corpus file parsed from rule "${assemblyProfile.entry}"; using the static ranking`);
|
|
24351
|
-
return void 0;
|
|
24352
24374
|
};
|
|
24353
24375
|
const assembledReplacement = (compiled, metadata, select) => select.size === 0 ? compiled.replacementWithMetadata(metadata) : supercompileRuleMapReplacement(compiled.prog, compiled.replacementWithMetadata(metadata, { select }), select);
|
|
24354
24376
|
const compileComposeLeafCall = (init) => {
|