@ohm-js/wasm 0.6.15 → 0.6.17

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.
@@ -38,7 +38,7 @@ export declare class WasmGrammar {
38
38
  private _fillInputBuffer;
39
39
  getRightmostFailurePosition(): number;
40
40
  }
41
- export interface MatchContext {
41
+ interface MatchContext {
42
42
  ruleNames: string[];
43
43
  view: DataView;
44
44
  input: string;
@@ -201,18 +201,18 @@ export declare class MatchResult {
201
201
  succeeded(): this is SucceededMatchResult;
202
202
  failed(): this is FailedMatchResult;
203
203
  toString(): string;
204
- use<T>(cb: (r: MatchResult) => T): T;
204
+ use<T>(cb: (r: this) => T): T;
205
205
  }
206
- declare class SucceededMatchResult extends MatchResult {
206
+ export declare class SucceededMatchResult extends MatchResult {
207
207
  _cst: CstNode;
208
208
  constructor(grammar: WasmGrammar, startExpr: string, ctx: MatchContext, succeeded: boolean);
209
209
  }
210
- declare class FailedMatchResult extends MatchResult {
210
+ export declare class FailedMatchResult extends MatchResult {
211
211
  constructor(grammar: WasmGrammar, startExpr: string, ctx: MatchContext, succeeded: boolean, rightmostFailurePosition: number, optRecordedFailures?: any);
212
212
  _rightmostFailurePosition: number;
213
213
  _rightmostFailures: any;
214
- shortMessage?: string;
215
- message?: string;
214
+ shortMessage: string;
215
+ message: string;
216
216
  getRightmostFailurePosition(): number;
217
217
  getRightmostFailures(): any;
218
218
  getExpectedText(): string;
@@ -573,22 +573,20 @@ function createMatchResult(grammar, startExpr, ctx, succeeded) {
573
573
  ? new SucceededMatchResult(grammar, startExpr, ctx, succeeded)
574
574
  : new FailedMatchResult(grammar, startExpr, ctx, succeeded, grammar.getRightmostFailurePosition());
575
575
  }
576
- class SucceededMatchResult extends MatchResult {
576
+ export class SucceededMatchResult extends MatchResult {
577
577
  _cst;
578
578
  constructor(grammar, startExpr, ctx, succeeded) {
579
579
  super(grammar, startExpr, ctx, succeeded);
580
580
  this._cst = grammar.getCstRoot();
581
581
  }
582
582
  }
583
- class FailedMatchResult extends MatchResult {
583
+ export class FailedMatchResult extends MatchResult {
584
584
  constructor(grammar, startExpr, ctx, succeeded, rightmostFailurePosition, optRecordedFailures) {
585
585
  super(grammar, startExpr, ctx, succeeded);
586
586
  this._rightmostFailurePosition = rightmostFailurePosition;
587
587
  this._rightmostFailures = optRecordedFailures;
588
588
  // TODO: Define these as lazy properties, like in the JS implementation.
589
- if (this.failed()) {
590
- this.shortMessage = this.message = `Match failed at pos ${rightmostFailurePosition}`;
591
- }
589
+ this.shortMessage = this.message = `Match failed at pos ${rightmostFailurePosition}`;
592
590
  }
593
591
  _rightmostFailurePosition;
594
592
  _rightmostFailures;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ohm-js/wasm",
3
- "version": "0.6.15",
3
+ "version": "0.6.17",
4
4
  "description": "Compile Ohm.js grammars to WebAsssembly",
5
5
  "main": "dist/index.js",
6
6
  "exports": {