ohm-js 17.1.0 → 17.2.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014-2022 Alessandro Warth and the Ohm project contributors.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [Ohm](https://ohmjs.org/) · [![NPM](https://img.shields.io/npm/v/ohm-js.svg)](https://www.npmjs.com/package/ohm-js) ![Node.js CI](https://github.com/ohmjs/ohm/workflows/Node.js%20CI/badge.svg?style=flat-square) [![Chat on Discord](https://img.shields.io/badge/chat-on%20discord-7289da.svg?sanitize=true)](https://discord.gg/KwxY5gegRQ)
1
+ # [Ohm](https://ohmjs.org/) · [![NPM](https://img.shields.io/npm/v/ohm-js.svg)](https://www.npmjs.com/package/ohm-js) [![Node.js CI](https://github.com/ohmjs/ohm/actions/workflows/node.js.yml/badge.svg)](https://github.com/ohmjs/ohm/actions/workflows/node.js.yml) [![Chat on Discord](https://img.shields.io/badge/chat-on%20discord-7289da.svg?sanitize=true)](https://discord.gg/KwxY5gegRQ)
2
2
 
3
3
  Ohm is a parsing toolkit consisting of a library and a domain-specific language. You can use it to parse custom file formats or quickly build parsers, interpreters, and compilers for programming languages.
4
4
 
@@ -21,6 +21,19 @@ Some awesome things people have built using Ohm:
21
21
  - A [browser-based tool](https://www.arthurcarabott.com/konnakkol/) that turns written _Konnakkol_ (a South Indian vocal percussion art) into audio.
22
22
  - [Wildcard](https://www.geoffreylitt.com/wildcard/), a browser extension that empowers anyone to modify websites to meet their own specific needs, uses Ohm for its spreadsheet formulas.
23
23
 
24
+ ## Sponsors
25
+
26
+ Since 2017, Ohm has been maintained by [@pdubroy](https://github.com/pdubroy) on an unpaid basis. Please consider [becoming a sponsor](http://github.com/sponsors/pdubroy/)!
27
+
28
+ ### Diamond 💎
29
+
30
+ <table>
31
+ <tr>
32
+ <td><a href="https://shopify.com"><img alt="Shopify" src="./doc/images/shopify-logo.png" height="48"></a></td>
33
+ <td><a href="https://projectsubstrate.org"><img alt="Project Substrate" src="./doc/images/substrate-logo.png" height="128"></a></td>
34
+ </tr>
35
+ </table>
36
+
24
37
  ## Getting Started
25
38
 
26
39
  The easiest way to get started with Ohm is to use the [interactive editor](https://ohmjs.org/editor/). Alternatively, you can play with one of the following examples on JSFiddle:
@@ -203,4 +216,4 @@ our [suggestions for publishing grammars](./doc/publishing-grammars.md).
203
216
  ## Contributing to Ohm
204
217
 
205
218
  Interested in contributing to Ohm? Please read [CONTRIBUTING.md](./CONTRIBUTING.md)
206
- and the [Ohm Contributor Guide](doc/contributing.md).
219
+ and the [Ohm Contributor Guide](doc/contributor-guide.md).
@@ -171,6 +171,13 @@ function unexpectedObjToString(obj) {
171
171
  }
172
172
  }
173
173
 
174
+ function checkNotNull(obj, message = 'unexpected null value') {
175
+ if (obj == null) {
176
+ throw new Error(message);
177
+ }
178
+ return obj;
179
+ }
180
+
174
181
  var common = /*#__PURE__*/Object.freeze({
175
182
  __proto__: null,
176
183
  abstract: abstract,
@@ -187,7 +194,8 @@ var common = /*#__PURE__*/Object.freeze({
187
194
  padLeft: padLeft,
188
195
  StringBuffer: StringBuffer,
189
196
  unescapeCodePoint: unescapeCodePoint,
190
- unexpectedObjToString: unexpectedObjToString
197
+ unexpectedObjToString: unexpectedObjToString,
198
+ checkNotNull: checkNotNull
191
199
  });
192
200
 
193
201
  // --------------------------------------------------------------------
@@ -2897,7 +2905,7 @@ any.substituteParams =
2897
2905
  };
2898
2906
 
2899
2907
  Param.prototype.substituteParams = function(actuals) {
2900
- return actuals[this.index];
2908
+ return checkNotNull(actuals[this.index]);
2901
2909
  };
2902
2910
 
2903
2911
  Alt.prototype.substituteParams = function(actuals) {
@@ -5592,6 +5600,9 @@ function initBuiltInSemantics(builtInRules) {
5592
5600
  nonEmpty(first, _, rest) {
5593
5601
  return this.iteration([first].concat(rest.children));
5594
5602
  },
5603
+ self(..._children) {
5604
+ return this;
5605
+ },
5595
5606
  };
5596
5607
 
5597
5608
  Semantics.BuiltInSemantics = Semantics.createSemantics(builtInRules, null).addOperation(
@@ -5601,6 +5612,7 @@ function initBuiltInSemantics(builtInRules) {
5601
5612
  nonemptyListOf: actions.nonEmpty,
5602
5613
  EmptyListOf: actions.empty,
5603
5614
  NonemptyListOf: actions.nonEmpty,
5615
+ _iter: actions.self,
5604
5616
  },
5605
5617
  );
5606
5618
  }
@@ -173,6 +173,13 @@
173
173
  }
174
174
  }
175
175
 
176
+ function checkNotNull(obj, message = 'unexpected null value') {
177
+ if (obj == null) {
178
+ throw new Error(message);
179
+ }
180
+ return obj;
181
+ }
182
+
176
183
  var common = /*#__PURE__*/Object.freeze({
177
184
  __proto__: null,
178
185
  abstract: abstract,
@@ -189,7 +196,8 @@
189
196
  padLeft: padLeft,
190
197
  StringBuffer: StringBuffer,
191
198
  unescapeCodePoint: unescapeCodePoint,
192
- unexpectedObjToString: unexpectedObjToString
199
+ unexpectedObjToString: unexpectedObjToString,
200
+ checkNotNull: checkNotNull
193
201
  });
194
202
 
195
203
  // --------------------------------------------------------------------
@@ -2899,7 +2907,7 @@
2899
2907
  };
2900
2908
 
2901
2909
  Param.prototype.substituteParams = function(actuals) {
2902
- return actuals[this.index];
2910
+ return checkNotNull(actuals[this.index]);
2903
2911
  };
2904
2912
 
2905
2913
  Alt.prototype.substituteParams = function(actuals) {
@@ -5594,6 +5602,9 @@
5594
5602
  nonEmpty(first, _, rest) {
5595
5603
  return this.iteration([first].concat(rest.children));
5596
5604
  },
5605
+ self(..._children) {
5606
+ return this;
5607
+ },
5597
5608
  };
5598
5609
 
5599
5610
  Semantics.BuiltInSemantics = Semantics.createSemantics(builtInRules, null).addOperation(
@@ -5603,6 +5614,7 @@
5603
5614
  nonemptyListOf: actions.nonEmpty,
5604
5615
  EmptyListOf: actions.empty,
5605
5616
  NonemptyListOf: actions.nonEmpty,
5617
+ _iter: actions.self,
5606
5618
  },
5607
5619
  );
5608
5620
  }
File without changes
package/dist/ohm.cjs CHANGED
@@ -171,6 +171,13 @@ function unexpectedObjToString(obj) {
171
171
  }
172
172
  }
173
173
 
174
+ function checkNotNull(obj, message = 'unexpected null value') {
175
+ if (obj == null) {
176
+ throw new Error(message);
177
+ }
178
+ return obj;
179
+ }
180
+
174
181
  var common = /*#__PURE__*/Object.freeze({
175
182
  __proto__: null,
176
183
  abstract: abstract,
@@ -187,7 +194,8 @@ var common = /*#__PURE__*/Object.freeze({
187
194
  padLeft: padLeft,
188
195
  StringBuffer: StringBuffer,
189
196
  unescapeCodePoint: unescapeCodePoint,
190
- unexpectedObjToString: unexpectedObjToString
197
+ unexpectedObjToString: unexpectedObjToString,
198
+ checkNotNull: checkNotNull
191
199
  });
192
200
 
193
201
  // These are just categories that are used in ES5/ES2015.
@@ -2606,7 +2614,7 @@ any.substituteParams =
2606
2614
  };
2607
2615
 
2608
2616
  Param.prototype.substituteParams = function(actuals) {
2609
- return actuals[this.index];
2617
+ return checkNotNull(actuals[this.index]);
2610
2618
  };
2611
2619
 
2612
2620
  Alt.prototype.substituteParams = function(actuals) {
@@ -5327,6 +5335,9 @@ function initBuiltInSemantics(builtInRules) {
5327
5335
  nonEmpty(first, _, rest) {
5328
5336
  return this.iteration([first].concat(rest.children));
5329
5337
  },
5338
+ self(..._children) {
5339
+ return this;
5340
+ },
5330
5341
  };
5331
5342
 
5332
5343
  Semantics.BuiltInSemantics = Semantics.createSemantics(builtInRules, null).addOperation(
@@ -5336,6 +5347,7 @@ function initBuiltInSemantics(builtInRules) {
5336
5347
  nonemptyListOf: actions.nonEmpty,
5337
5348
  EmptyListOf: actions.empty,
5338
5349
  NonemptyListOf: actions.nonEmpty,
5350
+ _iter: actions.self,
5339
5351
  },
5340
5352
  );
5341
5353
  }
@@ -5541,7 +5553,7 @@ Object.assign(IndentationSensitive, {
5541
5553
  });
5542
5554
 
5543
5555
  // Generated by scripts/prebuild.js
5544
- const version = '17.1.0';
5556
+ const version = '17.2.0';
5545
5557
 
5546
5558
  Grammar.initApplicationParser(ohmGrammar, buildGrammar);
5547
5559