@ohm-js/wasm 0.7.3 → 0.7.4
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/src/Compiler.d.ts +1 -1
- package/dist/src/Compiler.js +10 -2
- package/package.json +1 -1
package/dist/src/Compiler.d.ts
CHANGED
package/dist/src/Compiler.js
CHANGED
|
@@ -718,7 +718,7 @@ export class Compiler {
|
|
|
718
718
|
return JSON.stringify(exp.value);
|
|
719
719
|
case 'End':
|
|
720
720
|
return 'end of input';
|
|
721
|
-
case 'Apply':
|
|
721
|
+
case 'Apply': {
|
|
722
722
|
if (exp.descriptionId != null && exp.descriptionId >= 0) {
|
|
723
723
|
return this._failureDescriptions.getStr(exp.descriptionId);
|
|
724
724
|
}
|
|
@@ -726,7 +726,15 @@ export class Compiler {
|
|
|
726
726
|
return 'end of input';
|
|
727
727
|
if (exp.ruleName === 'any')
|
|
728
728
|
return 'any character';
|
|
729
|
-
|
|
729
|
+
// For lifted rules, expand their body to get a meaningful description.
|
|
730
|
+
if (exp.ruleName.startsWith('$lifted')) {
|
|
731
|
+
const ruleInfo = this.rules.get(exp.ruleName);
|
|
732
|
+
if (ruleInfo)
|
|
733
|
+
return this.toFailureDescription(ruleInfo.body);
|
|
734
|
+
}
|
|
735
|
+
const article = /^[aeiouAEIOU]/.test(exp.ruleName) ? 'an' : 'a';
|
|
736
|
+
return article + ' ' + exp.ruleName;
|
|
737
|
+
}
|
|
730
738
|
case 'Alt': {
|
|
731
739
|
const strs = exp.children.map(c => this.toFailureDescription(c));
|
|
732
740
|
if (strs.some(s => s == null))
|