@zigsterz/parzing 1.1.0 → 1.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/dist/builder.d.ts CHANGED
@@ -8,7 +8,7 @@ import { CutParser, FailParser, Parser, ParserType, PassParser, RefParser } from
8
8
  import { AnyOfParser } from "./parsers/AnyOfParser";
9
9
  import { RegexParser } from "./parsers/RegexParser";
10
10
  import { TokenParser } from "./parsers/TokenParser";
11
- declare type WithPostfixSupport<T> = T & {
11
+ type WithPostfixSupport<T> = T & {
12
12
  _<R>(f: (target: WithPostfixSupport<T>) => R): WithPostfixSupport<R>;
13
13
  };
14
14
  export declare function addPostfixSupport<T>(who: T): WithPostfixSupport<T>;
@@ -19,7 +19,7 @@ export declare class ParserBuilder {
19
19
  token(tok: string): WithPostfixSupport<TokenParser>;
20
20
  anyOf(alts: string, minLen?: number | null, maxLen?: number | null): WithPostfixSupport<AnyOfParser>;
21
21
  regex(re: RegExp): WithPostfixSupport<RegexParser>;
22
- fail(message?: string): WithPostfixSupport<FailParser>;
22
+ fail(message: string): WithPostfixSupport<FailParser>;
23
23
  pass(): WithPostfixSupport<PassParser>;
24
24
  cut(): WithPostfixSupport<CutParser>;
25
25
  ref<T>(f: () => Parser<T>): WithPostfixSupport<RefParser<T>>;
@@ -27,7 +27,7 @@ export declare class ParserBuilder {
27
27
  map<V extends Parser<unknown>, T>(parser: V, mapper: (i: ParserType<V>) => T): WithPostfixSupport<MapParser<V, T>>;
28
28
  sequence<TS extends Parser<unknown>[]>(...s: TS): WithPostfixSupport<SequenceCombinator<TS>>;
29
29
  choice<T extends Parser<any>[]>(...parsers: T): ChooseCombinator<T>;
30
- many<T>(parser: Parser<T>, sep?: Parser<unknown> | null, min?: number, max?: number): WithPostfixSupport<ManyCombinator<T>>;
30
+ many<T>(parser: Parser<T>, sep?: Parser<unknown>, min?: number, max?: number): WithPostfixSupport<ManyCombinator<T>>;
31
31
  optional<T>(parser: Parser<T>): WithPostfixSupport<OptionalCombinator<T>>;
32
32
  private _ws;
33
33
  }
package/dist/builder.js CHANGED
@@ -1,92 +1,76 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParserBuilder = exports.addPostfixSupport = void 0;
4
- var AttemptParser_1 = require("./combinators/AttemptParser");
5
- var ChooseCombinator_1 = require("./combinators/ChooseCombinator");
6
- var ManyCombinator_1 = require("./combinators/ManyCombinator");
7
- var MapParser_1 = require("./combinators/MapParser");
8
- var OptionalCombinator_1 = require("./combinators/OptionalCombinator");
9
- var SequenceCombinator_1 = require("./combinators/SequenceCombinator");
10
- var core_1 = require("./core");
11
- var AnyOfParser_1 = require("./parsers/AnyOfParser");
12
- var RegexParser_1 = require("./parsers/RegexParser");
13
- var TokenParser_1 = require("./parsers/TokenParser");
3
+ exports.ParserBuilder = void 0;
4
+ exports.addPostfixSupport = addPostfixSupport;
5
+ const AttemptParser_1 = require("./combinators/AttemptParser");
6
+ const ChooseCombinator_1 = require("./combinators/ChooseCombinator");
7
+ const ManyCombinator_1 = require("./combinators/ManyCombinator");
8
+ const MapParser_1 = require("./combinators/MapParser");
9
+ const OptionalCombinator_1 = require("./combinators/OptionalCombinator");
10
+ const SequenceCombinator_1 = require("./combinators/SequenceCombinator");
11
+ const core_1 = require("./core");
12
+ const AnyOfParser_1 = require("./parsers/AnyOfParser");
13
+ const RegexParser_1 = require("./parsers/RegexParser");
14
+ const TokenParser_1 = require("./parsers/TokenParser");
14
15
  function addPostfixSupport(who) {
15
- var ret = who;
16
+ const ret = who;
16
17
  ret._ = function (f) {
17
18
  return addPostfixSupport(f(ret));
18
19
  };
19
20
  return ret;
20
21
  }
21
- exports.addPostfixSupport = addPostfixSupport;
22
- var ParserBuilder = /** @class */ (function () {
23
- function ParserBuilder(whitespaceParser) {
24
- if (whitespaceParser === void 0) { whitespaceParser = null; }
22
+ class ParserBuilder {
23
+ constructor(whitespaceParser = null) {
25
24
  this._ws = whitespaceParser;
26
25
  }
27
- ParserBuilder.prototype.postProcessParser = function (parser) {
28
- var p = parser;
26
+ postProcessParser(parser) {
27
+ let p = parser;
29
28
  if (p instanceof core_1.ParserWithInternalWhitespaceSupport && this._ws) {
30
29
  p = p.whitespace(this._ws);
31
30
  }
32
31
  return addPostfixSupport(p);
33
- };
34
- ParserBuilder.prototype.parser = function (p) {
32
+ }
33
+ parser(p) {
35
34
  return this.postProcessParser(p);
36
- };
37
- ParserBuilder.prototype.token = function (tok) {
35
+ }
36
+ token(tok) {
38
37
  return this.postProcessParser(new TokenParser_1.TokenParser(tok));
39
- };
40
- ParserBuilder.prototype.anyOf = function (alts, minLen, maxLen) {
41
- if (minLen === void 0) { minLen = 1; }
42
- if (maxLen === void 0) { maxLen = null; }
38
+ }
39
+ anyOf(alts, minLen = 1, maxLen = null) {
43
40
  return this.postProcessParser(new AnyOfParser_1.AnyOfParser(alts, minLen, maxLen));
44
- };
45
- ParserBuilder.prototype.regex = function (re) {
41
+ }
42
+ regex(re) {
46
43
  return this.postProcessParser(new RegexParser_1.RegexParser(re));
47
- };
48
- ParserBuilder.prototype.fail = function (message) {
49
- if (message === void 0) { message = null; }
44
+ }
45
+ fail(message) {
50
46
  return this.postProcessParser(new core_1.FailParser(message));
51
- };
52
- ParserBuilder.prototype.pass = function () {
47
+ }
48
+ pass() {
53
49
  return this.postProcessParser(new core_1.PassParser());
54
- };
55
- ParserBuilder.prototype.cut = function () {
50
+ }
51
+ cut() {
56
52
  return this.postProcessParser(new core_1.CutParser());
57
- };
58
- ParserBuilder.prototype.ref = function (f) {
53
+ }
54
+ ref(f) {
59
55
  return this.postProcessParser(new core_1.RefParser(f));
60
- };
61
- ParserBuilder.prototype.attempt = function (p) {
56
+ }
57
+ attempt(p) {
62
58
  return this.postProcessParser(new AttemptParser_1.AttemptParser(p));
63
- };
64
- ParserBuilder.prototype.map = function (parser, mapper) {
59
+ }
60
+ map(parser, mapper) {
65
61
  return this.postProcessParser(new MapParser_1.MapParser(parser, mapper));
66
- };
67
- ParserBuilder.prototype.sequence = function () {
68
- var s = [];
69
- for (var _i = 0; _i < arguments.length; _i++) {
70
- s[_i] = arguments[_i];
71
- }
62
+ }
63
+ sequence(...s) {
72
64
  return this.postProcessParser(new SequenceCombinator_1.SequenceCombinator(s));
73
- };
74
- ParserBuilder.prototype.choice = function () {
75
- var parsers = [];
76
- for (var _i = 0; _i < arguments.length; _i++) {
77
- parsers[_i] = arguments[_i];
78
- }
65
+ }
66
+ choice(...parsers) {
79
67
  return new ChooseCombinator_1.ChooseCombinator(parsers);
80
- };
81
- ParserBuilder.prototype.many = function (parser, sep, min, max) {
82
- if (sep === void 0) { sep = null; }
83
- if (min === void 0) { min = 0; }
84
- if (max === void 0) { max = 0; }
68
+ }
69
+ many(parser, sep, min = 0, max = 0) {
85
70
  return this.postProcessParser(new ManyCombinator_1.ManyCombinator(parser, sep, min, max));
86
- };
87
- ParserBuilder.prototype.optional = function (parser) {
71
+ }
72
+ optional(parser) {
88
73
  return this.postProcessParser(new OptionalCombinator_1.OptionalCombinator(parser));
89
- };
90
- return ParserBuilder;
91
- }());
74
+ }
75
+ }
92
76
  exports.ParserBuilder = ParserBuilder;
@@ -1,29 +1,18 @@
1
1
  "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
- if (ar || !(i in from)) {
5
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
- ar[i] = from[i];
7
- }
8
- }
9
- return to.concat(ar || Array.prototype.slice.call(from));
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.AstBuilder = void 0;
13
- var core_1 = require("../core");
14
- var AstBuilder = /** @class */ (function () {
15
- function AstBuilder(_parser, _ctor) {
4
+ const core_1 = require("../core");
5
+ class AstBuilder {
6
+ constructor(_parser, _ctor) {
16
7
  this._parser = _parser;
17
8
  this._ctor = _ctor;
18
9
  }
19
- AstBuilder.prototype.parse = function (parserContext) {
20
- var _a;
21
- var s = this._parser.parse(parserContext);
10
+ parse(parserContext) {
11
+ const s = this._parser.parse(parserContext);
22
12
  if (!s.successful) {
23
13
  return s;
24
14
  }
25
- return core_1.ParseResult.successful(new ((_a = this._ctor).bind.apply(_a, __spreadArray([void 0], s.result, false)))());
26
- };
27
- return AstBuilder;
28
- }());
15
+ return core_1.ParseResult.successful(new this._ctor(...s.result));
16
+ }
17
+ }
29
18
  exports.AstBuilder = AstBuilder;
@@ -1,15 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AttemptParser = void 0;
4
- var AttemptParser = /** @class */ (function () {
5
- function AttemptParser(_parser) {
4
+ class AttemptParser {
5
+ constructor(_parser) {
6
6
  this._parser = _parser;
7
7
  }
8
- AttemptParser.prototype.parse = function (parserContext) {
9
- var s = this._parser.parse(parserContext);
8
+ parse(parserContext) {
9
+ const s = this._parser.parse(parserContext);
10
10
  parserContext.cutEncountered = false;
11
11
  return s;
12
- };
13
- return AttemptParser;
14
- }());
12
+ }
13
+ }
15
14
  exports.AttemptParser = AttemptParser;
@@ -1,5 +1,5 @@
1
1
  import { Parser, ParserContext, ParseResult, ParserType } from "../core";
2
- declare type ChooseResult<E> = E extends [infer Head, ...infer Tails] ? ParserType<Head> | ChooseResult<Tails> : never;
2
+ type ChooseResult<E> = E extends [infer Head, ...infer Tails] ? ParserType<Head> | ChooseResult<Tails> : never;
3
3
  export declare class ChooseCombinator<E extends Parser<any>[]> implements Parser<ChooseResult<E>> {
4
4
  private _parsers;
5
5
  constructor(_parsers: E);
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ChooseCombinator = void 0;
4
- var core_1 = require("../core");
5
- var ChooseCombinator = /** @class */ (function () {
6
- function ChooseCombinator(_parsers) {
4
+ const core_1 = require("../core");
5
+ class ChooseCombinator {
6
+ constructor(_parsers) {
7
7
  this._parsers = _parsers;
8
8
  }
9
- ChooseCombinator.prototype.parse = function (parserContext) {
10
- var input = parserContext.input;
11
- var bm = input.getBookmark();
12
- for (var i = 0; i < this._parsers.length; i++) {
13
- var combOpt = this._parsers[i].parse(parserContext);
9
+ parse(parserContext) {
10
+ const input = parserContext.input;
11
+ const bm = input.getBookmark();
12
+ for (let i = 0; i < this._parsers.length; i++) {
13
+ const combOpt = this._parsers[i].parse(parserContext);
14
14
  if (combOpt.successful || parserContext.cutEncountered) {
15
15
  return combOpt;
16
16
  }
@@ -19,7 +19,6 @@ var ChooseCombinator = /** @class */ (function () {
19
19
  }
20
20
  }
21
21
  return core_1.ParseResult.failed(core_1.ParseError.parserRejected(this, parserContext));
22
- };
23
- return ChooseCombinator;
24
- }());
22
+ }
23
+ }
25
24
  exports.ChooseCombinator = ChooseCombinator;
@@ -1,9 +1,9 @@
1
1
  import { Parser, ParserContext, ParseResult, ParserWithInternalWhitespaceSupport } from "../core";
2
2
  export declare class ManyCombinator<T> extends ParserWithInternalWhitespaceSupport<T[]> {
3
3
  private _parser;
4
- private _sepParser;
4
+ private _sepParser?;
5
5
  private _min;
6
6
  private _max;
7
- constructor(_parser: Parser<T>, _sepParser?: Parser<unknown>, _min?: number, _max?: number);
7
+ constructor(_parser: Parser<T>, _sepParser?: Parser<unknown> | undefined, _min?: number, _max?: number);
8
8
  parse(parserContext: ParserContext): ParseResult<T[]>;
9
9
  }
@@ -1,45 +1,25 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.ManyCombinator = void 0;
19
- var core_1 = require("../core");
20
- var ManyCombinator = /** @class */ (function (_super) {
21
- __extends(ManyCombinator, _super);
22
- function ManyCombinator(_parser, _sepParser, _min, _max) {
23
- if (_sepParser === void 0) { _sepParser = null; }
24
- if (_min === void 0) { _min = 0; }
25
- if (_max === void 0) { _max = 0; }
26
- var _this = _super.call(this) || this;
27
- _this._parser = _parser;
28
- _this._sepParser = _sepParser;
29
- _this._min = _min;
30
- _this._max = _max;
31
- return _this;
4
+ const core_1 = require("../core");
5
+ class ManyCombinator extends core_1.ParserWithInternalWhitespaceSupport {
6
+ constructor(_parser, _sepParser, _min = 0, _max = 0) {
7
+ super();
8
+ this._parser = _parser;
9
+ this._sepParser = _sepParser;
10
+ this._min = _min;
11
+ this._max = _max;
32
12
  }
33
- ManyCombinator.prototype.parse = function (parserContext) {
34
- var output = [];
35
- var pce = parserContext.cutEncountered;
36
- var mustParseElement = false;
13
+ parse(parserContext) {
14
+ const output = [];
15
+ const pce = parserContext.cutEncountered;
16
+ let mustParseElement = false;
37
17
  try {
38
18
  do {
39
19
  // Parse element
40
- var bm = parserContext.input.getBookmark();
20
+ let bm = parserContext.input.getBookmark();
41
21
  parserContext.cutEncountered = false;
42
- var psr = this._parser.parse(parserContext);
22
+ const psr = this._parser.parse(parserContext);
43
23
  if (psr.successful) {
44
24
  output.push(psr.result);
45
25
  }
@@ -55,7 +35,7 @@ var ManyCombinator = /** @class */ (function (_super) {
55
35
  mustParseElement = false;
56
36
  // Parse WS
57
37
  parserContext.cutEncountered = false;
58
- var wpr = this.parseWhitespace(parserContext);
38
+ let wpr = this.parseWhitespace(parserContext);
59
39
  if (!wpr.successful) {
60
40
  return wpr;
61
41
  }
@@ -63,7 +43,7 @@ var ManyCombinator = /** @class */ (function (_super) {
63
43
  if (this._sepParser) {
64
44
  parserContext.cutEncountered = false;
65
45
  bm = parserContext.input.getBookmark();
66
- var sepr = this._sepParser.parse(parserContext);
46
+ const sepr = this._sepParser.parse(parserContext);
67
47
  if (sepr.successful) {
68
48
  mustParseElement = true;
69
49
  // Parse WS post separator
@@ -84,9 +64,9 @@ var ManyCombinator = /** @class */ (function (_super) {
84
64
  }
85
65
  }
86
66
  } while (true);
87
- if ((output.length < this._min) ||
88
- ((this._max > 0) && output.length > this._max)) {
89
- return core_1.ParseResult.failed(core_1.ParseError.parserRejected(this, parserContext, "Expected occurences in range {" + this._min + ", " + this._max + "}; found " + output.length));
67
+ if (output.length < this._min ||
68
+ (this._max > 0 && output.length > this._max)) {
69
+ return core_1.ParseResult.failed(core_1.ParseError.parserRejected(this, parserContext, `Expected occurences in range {${this._min}, ${this._max}}; found ${output.length}`));
90
70
  }
91
71
  else {
92
72
  return core_1.ParseResult.successful(output);
@@ -95,7 +75,6 @@ var ManyCombinator = /** @class */ (function (_super) {
95
75
  finally {
96
76
  parserContext.cutEncountered = pce;
97
77
  }
98
- };
99
- return ManyCombinator;
100
- }(core_1.ParserWithInternalWhitespaceSupport));
78
+ }
79
+ }
101
80
  exports.ManyCombinator = ManyCombinator;
@@ -1,19 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MapParser = void 0;
4
- var core_1 = require("../core");
5
- var MapParser = /** @class */ (function () {
6
- function MapParser(_parser, _fn) {
4
+ const core_1 = require("../core");
5
+ class MapParser {
6
+ constructor(_parser, _fn) {
7
7
  this._parser = _parser;
8
8
  this._fn = _fn;
9
9
  }
10
- MapParser.prototype.parse = function (parserContext) {
11
- var s = this._parser.parse(parserContext);
10
+ parse(parserContext) {
11
+ const s = this._parser.parse(parserContext);
12
12
  if (!s.successful) {
13
13
  return s;
14
14
  }
15
15
  return core_1.ParseResult.successful(this._fn(s.result));
16
- };
17
- return MapParser;
18
- }());
16
+ }
17
+ }
19
18
  exports.MapParser = MapParser;
@@ -1,24 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OptionalCombinator = void 0;
4
- var core_1 = require("../core");
5
- var OptionalCombinator = /** @class */ (function () {
6
- function OptionalCombinator(_parser) {
4
+ const core_1 = require("../core");
5
+ class OptionalCombinator {
6
+ constructor(_parser) {
7
7
  this._parser = _parser;
8
8
  }
9
- OptionalCombinator.prototype.parse = function (parserContext) {
10
- var input = parserContext.input;
11
- var bm = input.getBookmark();
12
- var pce = parserContext.cutEncountered;
9
+ parse(parserContext) {
10
+ const input = parserContext.input;
11
+ const bm = input.getBookmark();
12
+ const pce = parserContext.cutEncountered;
13
13
  parserContext.cutEncountered = false;
14
- var ret = this._parser.parse(parserContext);
14
+ let ret = this._parser.parse(parserContext);
15
15
  if (!ret.successful && !parserContext.cutEncountered) {
16
16
  input.seekToBookmark(bm);
17
17
  ret = core_1.ParseResult.successful(null);
18
18
  }
19
19
  parserContext.cutEncountered = pce;
20
20
  return ret;
21
- };
22
- return OptionalCombinator;
23
- }());
21
+ }
22
+ }
24
23
  exports.OptionalCombinator = OptionalCombinator;
@@ -1,5 +1,5 @@
1
1
  import { Parser, ParserContext, ParseResult } from "../core";
2
- declare type ResultWithIndices<T> = {
2
+ type ResultWithIndices<T> = {
3
3
  result: T;
4
4
  start: number;
5
5
  length: number;
@@ -1,20 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ParserWithIndices = void 0;
4
- var core_1 = require("../core");
5
- var ParserWithIndices = /** @class */ (function () {
6
- function ParserWithIndices(_underlying) {
4
+ const core_1 = require("../core");
5
+ class ParserWithIndices {
6
+ constructor(_underlying) {
7
7
  this._underlying = _underlying;
8
8
  }
9
- ParserWithIndices.prototype.parse = function (parserContext) {
10
- var startOfs = parserContext.input.tell();
11
- var ret = this._underlying.parse(parserContext);
12
- var endOfs = parserContext.input.tell();
9
+ parse(parserContext) {
10
+ const startOfs = parserContext.input.tell();
11
+ const ret = this._underlying.parse(parserContext);
12
+ const endOfs = parserContext.input.tell();
13
13
  if (!ret.successful) {
14
14
  return ret;
15
15
  }
16
16
  return core_1.ParseResult.successful({ result: ret.result, start: startOfs, length: endOfs - startOfs });
17
- };
18
- return ParserWithIndices;
19
- }());
17
+ }
18
+ }
20
19
  exports.ParserWithIndices = ParserWithIndices;
@@ -1,6 +1,6 @@
1
1
  import { Parser, ParserContext, ParseResult, ParserType, ParserWithInternalWhitespaceSupport } from "../core";
2
- export declare type FilterVoid<T> = T extends [infer Head, ...infer Rest] ? (Head extends void ? [...FilterVoid<Rest>] : [Head, ...FilterVoid<Rest>]) : T;
3
- export declare type SeqType<TS extends Parser<unknown>[]> = FilterVoid<{
2
+ export type FilterVoid<T> = T extends [infer Head, ...infer Rest] ? (Head extends void ? [...FilterVoid<Rest>] : [Head, ...FilterVoid<Rest>]) : T;
3
+ export type SeqType<TS extends Parser<unknown>[]> = FilterVoid<{
4
4
  [i in keyof TS]: ParserType<TS[i]>;
5
5
  }>;
6
6
  export declare class SequenceCombinator<TS extends Parser<unknown>[]> extends ParserWithInternalWhitespaceSupport<SeqType<TS>> {
@@ -1,39 +1,22 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.SequenceCombinator = void 0;
19
- var core_1 = require("../core");
20
- var SequenceCombinator = /** @class */ (function (_super) {
21
- __extends(SequenceCombinator, _super);
22
- function SequenceCombinator(_parsers) {
23
- var _this = _super.call(this) || this;
24
- _this._parsers = _parsers;
25
- return _this;
4
+ const core_1 = require("../core");
5
+ class SequenceCombinator extends core_1.ParserWithInternalWhitespaceSupport {
6
+ constructor(_parsers) {
7
+ super();
8
+ this._parsers = _parsers;
26
9
  }
27
- SequenceCombinator.prototype.parse = function (parserContext) {
28
- var results = [];
29
- for (var i = 0; i < this._parsers.length; i++) {
10
+ parse(parserContext) {
11
+ const results = [];
12
+ for (let i = 0; i < this._parsers.length; i++) {
30
13
  if (i) {
31
- var wsr = this.parseWhitespace(parserContext);
14
+ const wsr = this.parseWhitespace(parserContext);
32
15
  if (!wsr.successful) {
33
16
  return wsr;
34
17
  }
35
18
  }
36
- var psr = this._parsers[i].parse(parserContext);
19
+ const psr = this._parsers[i].parse(parserContext);
37
20
  if (psr.successful) {
38
21
  if (psr.result !== undefined) {
39
22
  results.push(psr.result);
@@ -44,7 +27,6 @@ var SequenceCombinator = /** @class */ (function (_super) {
44
27
  }
45
28
  }
46
29
  return core_1.ParseResult.successful(results);
47
- };
48
- return SequenceCombinator;
49
- }(core_1.ParserWithInternalWhitespaceSupport));
30
+ }
31
+ }
50
32
  exports.SequenceCombinator = SequenceCombinator;
package/dist/core.d.ts CHANGED
@@ -6,7 +6,7 @@ export interface ParserInput {
6
6
  readRegex?(regex: RegExp): string | null;
7
7
  peekRegex?(regex: RegExp): string | null;
8
8
  getBookmark(): ParserInputBookmark;
9
- seekToBookmark(bm: ParserInputBookmark): any;
9
+ seekToBookmark(bm: ParserInputBookmark): void;
10
10
  eof(): boolean;
11
11
  tell(): number;
12
12
  }
@@ -33,7 +33,7 @@ export declare class ParserContext {
33
33
  get input(): ParserInput;
34
34
  cutEncountered: boolean;
35
35
  }
36
- export declare type ParseResult<T> = {
36
+ export type ParseResult<T> = {
37
37
  successful: true;
38
38
  failed: false;
39
39
  result: T;
@@ -54,8 +54,8 @@ export interface Parser<T> {
54
54
  export declare function isParser(p: any): p is Parser<unknown>;
55
55
  export declare class FailParser implements Parser<unknown> {
56
56
  private _message;
57
- constructor(_message?: string);
58
- parse(parserContext: ParserContext): any;
57
+ constructor(_message: string);
58
+ parse(parserContext: ParserContext): ParseResult<unknown>;
59
59
  }
60
60
  export declare class PassParser implements Parser<void> {
61
61
  parse(parserContext: ParserContext): ParseResult<void>;
@@ -67,9 +67,9 @@ export declare class RefParser<T> implements Parser<T> {
67
67
  private _parserProvider;
68
68
  constructor(_parserProvider: () => Parser<T>);
69
69
  parse(parserContext: ParserContext): ParseResult<T>;
70
- private _parser;
70
+ private _parser?;
71
71
  }
72
- export declare type ParserType<pt> = pt extends Parser<infer T> ? T : never;
72
+ export type ParserType<pt> = pt extends Parser<infer T> ? T : never;
73
73
  export declare class ParserWithInternalWhitespaceSupport<T> implements Parser<T> {
74
74
  parse(parserContext: ParserContext): ParseResult<T>;
75
75
  whitespace(whitespaceParser: Parser<unknown> | null): ParserWithInternalWhitespaceSupport<T>;
package/dist/core.js CHANGED
@@ -1,32 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParseError = exports.parse = exports.ParserWithInternalWhitespaceSupport = exports.RefParser = exports.CutParser = exports.PassParser = exports.FailParser = exports.isParser = exports.ParseResult = exports.ParserContext = exports.StringParserInput = void 0;
4
- var StringParserInput = /** @class */ (function () {
5
- function StringParserInput(_text) {
3
+ exports.ParseError = exports.ParserWithInternalWhitespaceSupport = exports.RefParser = exports.CutParser = exports.PassParser = exports.FailParser = exports.ParseResult = exports.ParserContext = exports.StringParserInput = void 0;
4
+ exports.isParser = isParser;
5
+ exports.parse = parse;
6
+ class StringParserInput {
7
+ constructor(_text) {
6
8
  this._text = _text;
7
9
  this._index = 0;
8
10
  }
9
- StringParserInput.prototype.read = function (readLen) {
11
+ read(readLen) {
10
12
  if (this._index + readLen > this._text.length) {
11
13
  this._index = this._text.length;
12
- throw new ParseError(this, this.getBookmark(), null, "Attempt to read beyond EOF");
14
+ throw new ParseError(this, this.getBookmark(), null, `Attempt to read beyond EOF`);
13
15
  }
14
- var ret = this._text.substr(this._index, readLen);
16
+ const ret = this._text.substr(this._index, readLen);
15
17
  this._index += readLen;
16
18
  return ret;
17
- };
18
- StringParserInput.prototype.peek = function (readLen) {
19
+ }
20
+ peek(readLen) {
19
21
  return this._text.substr(this._index, readLen);
20
- };
21
- StringParserInput.prototype.readRegex = function (regex) {
22
- var ret = this.peekRegex(regex);
22
+ }
23
+ readRegex(regex) {
24
+ const ret = this.peekRegex(regex);
23
25
  if (ret) {
24
26
  this._index += ret.length;
25
27
  }
26
28
  return ret;
27
- };
28
- StringParserInput.prototype.peekRegex = function (regex) {
29
- var matchResult = regex.exec(this._text.substring(this._index));
29
+ }
30
+ peekRegex(regex) {
31
+ let matchResult = regex.exec(this._text.substring(this._index));
30
32
  if (!matchResult) {
31
33
  return null;
32
34
  }
@@ -34,49 +36,42 @@ var StringParserInput = /** @class */ (function () {
34
36
  return null;
35
37
  }
36
38
  return matchResult[0];
37
- };
38
- StringParserInput.prototype.getBookmark = function () {
39
+ }
40
+ getBookmark() {
39
41
  return this._index;
40
- };
41
- StringParserInput.prototype.seekToBookmark = function (bm) {
42
+ }
43
+ seekToBookmark(bm) {
42
44
  this._index = bm;
43
- };
44
- StringParserInput.prototype.eof = function () {
45
+ }
46
+ eof() {
45
47
  return this._index >= this._text.length;
46
- };
47
- StringParserInput.prototype.remainder = function () {
48
+ }
49
+ remainder() {
48
50
  return this._text.substr(this._index);
49
- };
50
- StringParserInput.prototype.skip = function (howMuch) {
51
+ }
52
+ skip(howMuch) {
51
53
  this._index += howMuch;
52
- };
53
- StringParserInput.prototype.tell = function () {
54
+ }
55
+ tell() {
54
56
  return this._index;
55
- };
56
- return StringParserInput;
57
- }());
57
+ }
58
+ }
58
59
  exports.StringParserInput = StringParserInput;
59
- var ParserContext = /** @class */ (function () {
60
- function ParserContext(_input, _whitespaceParser) {
61
- if (_whitespaceParser === void 0) { _whitespaceParser = null; }
60
+ class ParserContext {
61
+ constructor(_input, _whitespaceParser = null) {
62
62
  this._input = _input;
63
63
  this._whitespaceParser = _whitespaceParser;
64
64
  this.cutEncountered = false;
65
65
  }
66
- ParserContext.prototype.parseWhitespace = function () {
66
+ parseWhitespace() {
67
67
  if (this._whitespaceParser) {
68
68
  this._whitespaceParser.parse(this);
69
69
  }
70
- };
71
- Object.defineProperty(ParserContext.prototype, "input", {
72
- get: function () {
73
- return this._input;
74
- },
75
- enumerable: false,
76
- configurable: true
77
- });
78
- return ParserContext;
79
- }());
70
+ }
71
+ get input() {
72
+ return this._input;
73
+ }
74
+ }
80
75
  exports.ParserContext = ParserContext;
81
76
  var ParseResult;
82
77
  (function (ParseResult) {
@@ -85,7 +80,7 @@ var ParseResult;
85
80
  }
86
81
  ParseResult.successful = successful;
87
82
  function voidSuccessful() {
88
- return { successful: true, failed: false, result: undefined };
83
+ return { successful: true, failed: false, result: void 0 };
89
84
  }
90
85
  ParseResult.voidSuccessful = voidSuccessful;
91
86
  function failed(r) {
@@ -96,108 +91,93 @@ var ParseResult;
96
91
  if (p.successful) {
97
92
  return p.result;
98
93
  }
99
- else if (p.failed) {
94
+ else {
100
95
  throw p.parseError;
101
96
  }
102
97
  }
103
98
  ParseResult.resultOrThrow = resultOrThrow;
104
- })(ParseResult = exports.ParseResult || (exports.ParseResult = {}));
105
- ;
99
+ })(ParseResult || (exports.ParseResult = ParseResult = {}));
106
100
  function isParser(p) {
107
- return 'parse' in p;
101
+ return "parse" in p;
108
102
  }
109
- exports.isParser = isParser;
110
- var FailParser = /** @class */ (function () {
111
- function FailParser(_message) {
112
- if (_message === void 0) { _message = null; }
103
+ class FailParser {
104
+ constructor(_message) {
113
105
  this._message = _message;
114
106
  }
115
- FailParser.prototype.parse = function (parserContext) {
107
+ parse(parserContext) {
116
108
  return ParseResult.failed(ParseError.parserRejected(this, parserContext, this._message));
117
- };
118
- return FailParser;
119
- }());
120
- exports.FailParser = FailParser;
121
- var PassParser = /** @class */ (function () {
122
- function PassParser() {
123
109
  }
124
- PassParser.prototype.parse = function (parserContext) {
110
+ }
111
+ exports.FailParser = FailParser;
112
+ class PassParser {
113
+ parse(parserContext) {
125
114
  return ParseResult.voidSuccessful();
126
- };
127
- return PassParser;
128
- }());
129
- exports.PassParser = PassParser;
130
- var CutParser = /** @class */ (function () {
131
- function CutParser() {
132
115
  }
133
- CutParser.prototype.parse = function (parserContext) {
116
+ }
117
+ exports.PassParser = PassParser;
118
+ class CutParser {
119
+ parse(parserContext) {
134
120
  parserContext.cutEncountered = true;
135
121
  return ParseResult.voidSuccessful();
136
- };
137
- return CutParser;
138
- }());
122
+ }
123
+ }
139
124
  exports.CutParser = CutParser;
140
- var RefParser = /** @class */ (function () {
141
- function RefParser(_parserProvider) {
125
+ class RefParser {
126
+ constructor(_parserProvider) {
142
127
  this._parserProvider = _parserProvider;
143
128
  }
144
- RefParser.prototype.parse = function (parserContext) {
129
+ parse(parserContext) {
145
130
  if (!this._parser) {
146
131
  this._parser = this._parserProvider();
147
132
  }
148
133
  return this._parser.parse(parserContext);
149
- };
150
- return RefParser;
151
- }());
134
+ }
135
+ }
152
136
  exports.RefParser = RefParser;
153
- var ParserWithInternalWhitespaceSupport = /** @class */ (function () {
154
- function ParserWithInternalWhitespaceSupport() {
137
+ class ParserWithInternalWhitespaceSupport {
138
+ constructor() {
155
139
  this._whitespace = null;
156
140
  }
157
- ParserWithInternalWhitespaceSupport.prototype.parse = function (parserContext) {
158
- throw new Error('Method not implemented');
159
- };
160
- ParserWithInternalWhitespaceSupport.prototype.whitespace = function (whitespaceParser) {
141
+ parse(parserContext) {
142
+ throw new Error("Method not implemented");
143
+ }
144
+ whitespace(whitespaceParser) {
161
145
  this._whitespace = whitespaceParser;
162
146
  return this;
163
- };
164
- ParserWithInternalWhitespaceSupport.prototype.parseWhitespace = function (parserContext) {
147
+ }
148
+ parseWhitespace(parserContext) {
165
149
  if (this._whitespace) {
166
150
  return this._whitespace.parse(parserContext);
167
151
  }
168
152
  else {
169
153
  return ParseResult.voidSuccessful();
170
154
  }
171
- };
172
- return ParserWithInternalWhitespaceSupport;
173
- }());
155
+ }
156
+ }
174
157
  exports.ParserWithInternalWhitespaceSupport = ParserWithInternalWhitespaceSupport;
175
- function parse(parser, input, allowPartial) {
176
- if (allowPartial === void 0) { allowPartial = false; }
177
- if (typeof (input) === 'string') {
158
+ function parse(parser, input, allowPartial = false) {
159
+ if (typeof input === "string") {
178
160
  input = new StringParserInput(input);
179
161
  }
180
- var context = new ParserContext(input);
181
- var ret = parser.parse(context);
162
+ let context = new ParserContext(input);
163
+ const ret = parser.parse(context);
182
164
  if (!allowPartial && !input.eof()) {
183
- throw new ParseError(input, input.getBookmark(), null, "End of input expected");
165
+ throw new ParseError(input, input.getBookmark(), null, `End of input expected`);
184
166
  }
185
167
  return ParseResult.resultOrThrow(ret);
186
168
  }
187
- exports.parse = parse;
188
- var ParseError = /** @class */ (function () {
189
- function ParseError(input, bookmark, parser, contentMessage) {
169
+ class ParseError {
170
+ constructor(input, bookmark, parser, contentMessage) {
190
171
  this.message = contentMessage;
191
172
  if (bookmark) {
192
- this.message = this.message + " at " + bookmark + " ('" + input.peek(5) + "')";
173
+ this.message = `${this.message} at ${bookmark} ('${input.peek(5)}')`;
193
174
  }
194
175
  }
195
- ParseError.prototype.toString = function () {
196
- return "Error: " + this.message;
197
- };
198
- ParseError.parserRejected = function (parser, context, message) {
199
- return new ParseError(context.input, context.input.getBookmark(), parser, message || "Parser rejected input");
200
- };
201
- return ParseError;
202
- }());
176
+ toString() {
177
+ return `Error: ${this.message}`;
178
+ }
179
+ static parserRejected(parser, context, message) {
180
+ return new ParseError(context.input, context.input.getBookmark(), parser, message || `Parser rejected input`);
181
+ }
182
+ }
203
183
  exports.ParseError = ParseError;
package/dist/operators.js CHANGED
@@ -1,46 +1,46 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ParserOperators = void 0;
4
- var AstBuilder_1 = require("./combinators/AstBuilder");
5
- var MapParser_1 = require("./combinators/MapParser");
6
- var OptionalCombinator_1 = require("./combinators/OptionalCombinator");
7
- var ParserWithIndices_1 = require("./combinators/ParserWithIndices");
4
+ const AstBuilder_1 = require("./combinators/AstBuilder");
5
+ const MapParser_1 = require("./combinators/MapParser");
6
+ const OptionalCombinator_1 = require("./combinators/OptionalCombinator");
7
+ const ParserWithIndices_1 = require("./combinators/ParserWithIndices");
8
8
  var ParserOperators;
9
9
  (function (ParserOperators) {
10
10
  function map(mapper) {
11
- return function (p) {
11
+ return (p) => {
12
12
  return new MapParser_1.MapParser(p, mapper);
13
13
  };
14
14
  }
15
15
  ParserOperators.map = map;
16
16
  function optional() {
17
- return function (p) {
17
+ return (p) => {
18
18
  return new OptionalCombinator_1.OptionalCombinator(p);
19
19
  };
20
20
  }
21
21
  ParserOperators.optional = optional;
22
22
  function build(ctor) {
23
- return function (p) {
23
+ return (p) => {
24
24
  return new AstBuilder_1.AstBuilder(p, ctor);
25
25
  };
26
26
  }
27
27
  ParserOperators.build = build;
28
28
  function omit() {
29
- return function (p) {
30
- return new MapParser_1.MapParser(p, function (a) { });
29
+ return (p) => {
30
+ return new MapParser_1.MapParser(p, (a) => { });
31
31
  };
32
32
  }
33
33
  ParserOperators.omit = omit;
34
34
  function whitespace(ws) {
35
- return function (p) {
35
+ return (p) => {
36
36
  return p.whitespace(ws);
37
37
  };
38
38
  }
39
39
  ParserOperators.whitespace = whitespace;
40
40
  function withIndices() {
41
- return function (p) {
41
+ return (p) => {
42
42
  return new ParserWithIndices_1.ParserWithIndices(p);
43
43
  };
44
44
  }
45
45
  ParserOperators.withIndices = withIndices;
46
- })(ParserOperators = exports.ParserOperators || (exports.ParserOperators = {}));
46
+ })(ParserOperators || (exports.ParserOperators = ParserOperators = {}));
@@ -1,20 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AnyOfParser = void 0;
4
- var core_1 = require("../core");
5
- var AnyOfParser = /** @class */ (function () {
6
- function AnyOfParser(_characters, _minLen, _maxLen) {
7
- if (_minLen === void 0) { _minLen = 1; }
8
- if (_maxLen === void 0) { _maxLen = null; }
4
+ const core_1 = require("../core");
5
+ class AnyOfParser {
6
+ constructor(_characters, _minLen = 1, _maxLen = null) {
9
7
  this._characters = _characters;
10
8
  this._minLen = _minLen;
11
9
  this._maxLen = _maxLen;
12
- var charBitmap = [];
10
+ const charBitmap = [];
13
11
  this._charBitmap = charBitmap;
14
- for (var i = 0; i < _characters.length; i++) {
15
- var ccode = _characters.charCodeAt(i);
12
+ for (let i = 0; i < _characters.length; i++) {
13
+ const ccode = _characters.charCodeAt(i);
16
14
  if (ccode < 256) {
17
- charBitmap[ccode >> 3] = (charBitmap[ccode >> 3] || 0) | (1 << (ccode & 7));
15
+ charBitmap[ccode >> 3] =
16
+ (charBitmap[ccode >> 3] || 0) | (1 << (ccode & 7));
18
17
  }
19
18
  else {
20
19
  this._charBitmap = null;
@@ -22,14 +21,14 @@ var AnyOfParser = /** @class */ (function () {
22
21
  }
23
22
  }
24
23
  }
25
- AnyOfParser.prototype.parse = function (parserContext) {
26
- var ret = [];
27
- var cont = true;
28
- var input = parserContext.input;
24
+ parse(parserContext) {
25
+ let ret = [];
26
+ let cont = true;
27
+ const input = parserContext.input;
29
28
  while (cont && !input.eof()) {
30
- var str = input.peek(1);
29
+ const str = input.peek(1);
31
30
  if (this._charBitmap) {
32
- var ccode = str.charCodeAt(0);
31
+ const ccode = str.charCodeAt(0);
33
32
  cont = (this._charBitmap[ccode >> 3] & (1 << (ccode & 7))) != 0;
34
33
  }
35
34
  else {
@@ -42,10 +41,9 @@ var AnyOfParser = /** @class */ (function () {
42
41
  }
43
42
  if ((this._maxLen != null && ret.length > this._maxLen) ||
44
43
  (this._minLen != null && ret.length < this._minLen)) {
45
- return core_1.ParseResult.failed(core_1.ParseError.parserRejected(this, parserContext, "Expecting AnyOf " + this._characters));
44
+ return core_1.ParseResult.failed(core_1.ParseError.parserRejected(this, parserContext, `Expecting AnyOf ${this._characters}`));
46
45
  }
47
- return core_1.ParseResult.successful(ret.join(''));
48
- };
49
- return AnyOfParser;
50
- }());
46
+ return core_1.ParseResult.successful(ret.join(""));
47
+ }
48
+ }
51
49
  exports.AnyOfParser = AnyOfParser;
@@ -1,21 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RegexParser = void 0;
4
- var core_1 = require("../core");
5
- var RegexParser = /** @class */ (function () {
6
- function RegexParser(_regex) {
4
+ const core_1 = require("../core");
5
+ class RegexParser {
6
+ constructor(_regex) {
7
7
  this._regex = _regex;
8
+ this._charBitmap = null;
8
9
  }
9
- RegexParser.prototype.parse = function (parserContext) {
10
+ parse(parserContext) {
10
11
  if (!parserContext.input.readRegex) {
11
12
  throw core_1.ParseError.parserRejected(this, parserContext, "Input doesn't support regex parsing");
12
13
  }
13
- var reResult = parserContext.input.readRegex(this._regex);
14
+ const reResult = parserContext.input.readRegex(this._regex);
14
15
  if (!reResult) {
15
- return core_1.ParseResult.failed(core_1.ParseError.parserRejected(this, parserContext, "Expected " + this._regex.source));
16
+ return core_1.ParseResult.failed(core_1.ParseError.parserRejected(this, parserContext, `Expected ${this._regex.source}`));
16
17
  }
17
18
  return core_1.ParseResult.successful(reResult);
18
- };
19
- return RegexParser;
20
- }());
19
+ }
20
+ }
21
21
  exports.RegexParser = RegexParser;
@@ -1,23 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TokenParser = void 0;
4
- var core_1 = require("../core");
5
- var TokenParser = /** @class */ (function () {
6
- function TokenParser(_token) {
4
+ const core_1 = require("../core");
5
+ class TokenParser {
6
+ constructor(_token) {
7
7
  this._token = _token;
8
8
  }
9
- TokenParser.prototype.parse = function (parserContext) {
9
+ parse(parserContext) {
10
10
  try {
11
- var str = parserContext.input.read(this._token.length);
11
+ const str = parserContext.input.read(this._token.length);
12
12
  if (str !== this._token) {
13
- return core_1.ParseResult.failed(core_1.ParseError.parserRejected(this, parserContext, "Expected token " + this._token));
13
+ return core_1.ParseResult.failed(core_1.ParseError.parserRejected(this, parserContext, `Expected token ${this._token}`));
14
14
  }
15
15
  return core_1.ParseResult.successful(str);
16
16
  }
17
17
  catch (e) {
18
- return core_1.ParseResult.failed(e);
18
+ if (e instanceof core_1.ParseError) {
19
+ return core_1.ParseResult.failed(e);
20
+ }
21
+ throw e;
19
22
  }
20
- };
21
- return TokenParser;
22
- }());
23
+ }
24
+ }
23
25
  exports.TokenParser = TokenParser;
@@ -1,6 +1,6 @@
1
- import { Parser, ParserContext } from "../core";
1
+ import { Parser, ParserContext, ParseResult } from "../core";
2
2
  export declare class WhitespaceParser implements Parser<void> {
3
3
  private _mandatory;
4
4
  constructor(_mandatory: boolean);
5
- parse(parserContext: ParserContext): any;
5
+ parse(parserContext: ParserContext): ParseResult<void>;
6
6
  }
@@ -1,16 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WhitespaceParser = void 0;
4
- var core_1 = require("../core");
5
- var WhitespaceParser = /** @class */ (function () {
6
- function WhitespaceParser(_mandatory) {
4
+ const core_1 = require("../core");
5
+ class WhitespaceParser {
6
+ constructor(_mandatory) {
7
7
  this._mandatory = _mandatory;
8
8
  }
9
- WhitespaceParser.prototype.parse = function (parserContext) {
10
- var input = parserContext.input;
11
- var c;
12
- var found = false;
13
- while (!input.eof() && (c = input.peek(1), c == ' ' || c == '\t' || c == '\n')) {
9
+ parse(parserContext) {
10
+ const input = parserContext.input;
11
+ let c;
12
+ let found = false;
13
+ while (!input.eof() &&
14
+ ((c = input.peek(1)), c == " " || c == "\t" || c == "\n")) {
14
15
  input.read(1);
15
16
  found = true;
16
17
  }
@@ -20,7 +21,6 @@ var WhitespaceParser = /** @class */ (function () {
20
21
  else {
21
22
  return core_1.ParseResult.voidSuccessful();
22
23
  }
23
- };
24
- return WhitespaceParser;
25
- }());
24
+ }
25
+ }
26
26
  exports.WhitespaceParser = WhitespaceParser;
package/dist/parzing.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
- {
1
+ {
2
2
  "name": "@zigsterz/parzing",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Parser combinators library",
5
+ "keywords": [
6
+ "parser",
7
+ "grammar"
8
+ ],
5
9
  "scripts": {
6
10
  "test": "ts-mocha test/**.ts",
7
11
  "build": "tsc && npm pack"
8
-
9
12
  },
10
13
  "main": "dist/parzing.js",
11
14
  "types": "dist/parzing.d.ts",
@@ -14,18 +17,15 @@
14
17
  ],
15
18
  "author": "Eldan Ben-Haim",
16
19
  "license": "MIT",
17
- "repository": {
20
+ "repository": {
18
21
  "url": "https://github.com/eldanb/parzing"
19
22
  },
20
23
  "devDependencies": {
21
24
  "@types/mocha": "^9.0.0",
22
25
  "@types/node": "^16.10.3",
23
- "mocha": "^9.1.2",
24
- "ts-mocha": "^8.0.0",
25
- "typescript": "^4.4.3",
26
- "assert": "^2.0.0"
27
- },
28
- "dependencies": {
29
-
26
+ "assert": "^2.0.0",
27
+ "mocha": "^11.7.6",
28
+ "ts-mocha": "^11.1.0",
29
+ "typescript": "^6.0.3"
30
30
  }
31
31
  }