ohm-js 16.3.0 → 16.3.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.
@@ -1,13 +1,5 @@
1
1
  'use strict';
2
2
 
3
- // --------------------------------------------------------------------
4
- // Imports
5
- // --------------------------------------------------------------------
6
-
7
- const pexprs = require('../src/pexprs');
8
- const MatchResult = require('../src/MatchResult');
9
- const Grammar = require('../src/Grammar');
10
-
11
3
  // --------------------------------------------------------------------
12
4
  // Operations
13
5
  // --------------------------------------------------------------------
@@ -23,11 +15,6 @@ const defaultOperation = {
23
15
 
24
16
  // without customization
25
17
  if (!Object.prototype.hasOwnProperty.call(mapping, ctorName)) {
26
- // intermediate node
27
- if (this._node instanceof pexprs.Alt || this._node instanceof pexprs.Apply) {
28
- return children[0].toAST(mapping);
29
- }
30
-
31
18
  // lexical rule
32
19
  if (this.isLexical()) {
33
20
  return this.sourceString;
@@ -111,8 +98,8 @@ const defaultOperation = {
111
98
  // The optional `mapping` parameter can be used to customize how the nodes of the CST
112
99
  // are mapped to the AST (see /doc/extras.md#toastmatchresult-mapping).
113
100
  function toAST(res, mapping) {
114
- if (!(res instanceof MatchResult) || res.failed()) {
115
- throw new Error('toAST() expects a succesfull MatchResult as first parameter');
101
+ if (typeof res.failed !== 'function' || res.failed()) {
102
+ throw new Error('toAST() expects a succesful MatchResult as first parameter');
116
103
  }
117
104
 
118
105
  mapping = Object.assign({}, mapping);
@@ -130,7 +117,7 @@ function toAST(res, mapping) {
130
117
 
131
118
  // Returns a semantics containg the toAST(mapping) operation for the given grammar g.
132
119
  function semanticsForToAST(g) {
133
- if (!(g instanceof Grammar)) {
120
+ if (typeof g.createSemantics !== 'function') {
134
121
  throw new Error('semanticsToAST() expects a Grammar as parameter');
135
122
  }
136
123
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ohm-js",
3
- "version": "16.3.0",
3
+ "version": "16.3.1",
4
4
  "description": "An object-oriented language for parsing and pattern matching",
5
5
  "repository": "https://github.com/harc/ohm",
6
6
  "keywords": [
@@ -15,7 +15,7 @@
15
15
  "rapid",
16
16
  "prototyping"
17
17
  ],
18
- "homepage": "https://ohmlang.github.io/",
18
+ "homepage": "https://ohmjs.org",
19
19
  "bugs": "https://github.com/harc/ohm/issues",
20
20
  "main": "index.js",
21
21
  "module": "dist/ohm.esm.js",
package/src/errors.js CHANGED
@@ -218,7 +218,10 @@ function invalidCodePoint(applyWrapper) {
218
218
  // Get an interval that covers all of the hex digits.
219
219
  const digitIntervals = applyWrapper.children.slice(1, -1).map(d => d.source);
220
220
  const fullInterval = digitIntervals[0].coverageWith(...digitIntervals.slice(1));
221
- return createError(`U+${fullInterval.contents} is not a valid Unicode code point`, fullInterval);
221
+ return createError(
222
+ `U+${fullInterval.contents} is not a valid Unicode code point`,
223
+ fullInterval
224
+ );
222
225
  }
223
226
 
224
227
  // ----------------- Kleene operators -----------------