@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.
@@ -7,7 +7,7 @@ export class Compiler {
7
7
  paramTypes: any[];
8
8
  resultTypes: any[];
9
9
  }[];
10
- ruleIdByName: any;
10
+ ruleIdByName: StringTable;
11
11
  _failureDescriptions: StringTable;
12
12
  _endOfInputFailureId: any;
13
13
  _deferredRuleIds: Set<any>;
@@ -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
- return null;
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))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ohm-js/wasm",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "description": "Compile Ohm.js grammars to WebAsssembly",
5
5
  "main": "dist/index.js",
6
6
  "exports": {