re2js 0.3.3 → 0.4.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.
@@ -165,7 +165,7 @@ export class RE2JSGroupException extends RE2JSException {
165
165
  * An exception thrown by the parser if the pattern was invalid.
166
166
  */
167
167
  export class RE2JSSyntaxException extends RE2JSException {
168
- constructor(error: any, ...args: any[]);
168
+ constructor(error: any, input?: any);
169
169
  error: any;
170
170
  input: any;
171
171
  /**
@@ -247,20 +247,20 @@ declare class Matcher {
247
247
  * @param {string|number} [group=0]
248
248
  * @returns {string}
249
249
  */
250
- start(...args: any[]): string;
250
+ start(group?: string | number): string;
251
251
  /**
252
252
  * Returns the end of the named group of the most recent match, or -1 if the group was not
253
253
  * matched.
254
254
  * @param {string|number} [group=0]
255
255
  * @returns {string}
256
256
  */
257
- end(...args: any[]): string;
257
+ end(group?: string | number): string;
258
258
  /**
259
259
  * Returns the named group of the most recent match, or {@code null} if the group was not matched.
260
260
  * @param {string|number} [group=0]
261
261
  * @returns {string}
262
262
  */
263
- group(...args: any[]): string;
263
+ group(group?: string | number): string;
264
264
  /**
265
265
  * Returns the number of subgroups in this pattern.
266
266
  *
@@ -295,7 +295,7 @@ declare class Matcher {
295
295
  * @returns {boolean} if it finds a match
296
296
  * @throws IndexOutOfBoundsException if start is not a valid input position
297
297
  */
298
- find(...args: any[]): boolean;
298
+ find(start?: string | number): boolean;
299
299
  /**
300
300
  * Helper: does match starting at start, with RE2 anchor flag.
301
301
  * @param {number} startByte
@@ -367,7 +367,7 @@ declare class Matcher {
367
367
  * @returns {string} the input string with the matches replaced
368
368
  * @throws IndexOutOfBoundsException if replacement refers to an invalid group and perlMode is false
369
369
  */
370
- replaceAll(replacement: string, ...args: any[]): string;
370
+ replaceAll(replacement: string, perlMode?: boolean): string;
371
371
  /**
372
372
  * Returns the input with the first match replaced by {@code replacement}, interpreted as for
373
373
  * {@code appendReplacement}.
@@ -377,7 +377,7 @@ declare class Matcher {
377
377
  * @returns {string} the input string with the first match replaced
378
378
  * @throws IndexOutOfBoundsException if replacement refers to an invalid group and perlMode is false
379
379
  */
380
- replaceFirst(replacement: string, ...args: any[]): string;
380
+ replaceFirst(replacement: string, perlMode?: boolean): string;
381
381
  /**
382
382
  * Helper: replaceAll/replaceFirst hybrid.
383
383
  * @param {string} replacement - the replacement string
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.d.ts","sourceRoot":"","sources":["index.esm.js"],"names":[],"mappings":"AA27KA;;;;;;;;;;GAUG;AACH;IACE;;OAEG;IACH,gCAA4B;IAC5B;;OAEG;IACH,sBAAkB;IAClB;;;OAGG;IACH,yBAAqB;IACrB;;OAEG;IACH,sCAAkC;IAClC;;OAEG;IACH,6BAA0B;IAE1B;;;;;;;;;;;OAWG;IACH,kBAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;OAKG;IACH,sBAJW,MAAM,mBAEJ,KAAK,CAyBjB;IAED;;;;;;;OAOG;IACH,sBALW,MAAM,SACN,MAAM,GAAC,MAAM,EAAE,GACb,OAAO,CAKnB;IAED;;;OAGG;IACH,wBAWC;IAED;;;;OAIG;IACH,qBAHW,MAAM,SACN,MAAM,EAOhB;IAHC,qBAA2B;IAE3B,mBAAuB;IAGzB;;;OAGG;IACH,cAEC;IAED;;;OAGG;IACH,SAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,WAFa,MAAM,CAIlB;IACD,WAEC;IAED;;;;;OAKG;IACH,eAHW,MAAM,GAAC,MAAM,EAAE,GACb,OAAO,CAInB;IAED;;;;;OAKG;IACH,eAHW,MAAM,GAAC,MAAM,EAAE,GACb,OAAO,CAOnB;IAED;;;;;;;;;;;;;OAaG;IACH,aAJW,MAAM,mBAEJ,MAAM,EAAE,CAiDpB;IAED;;;OAGG;IACH,YAFa,MAAM,CAIlB;IAED;;;;;OAKG;IACH,cAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,mBAEC;IAED;;;;OAIG;IACH,oBAFa,OAAO,CAUn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;;;;OAIG;IACH,cAFa,MAAM,CAIlB;IAED;;;;;;;;OAQG;IACH,wBALW,MAAM,mBAEJ,MAAM,CAMlB;IAED;;;;;;;;OAQG;IACH,0BALW,MAAM,mBAEJ,MAAM,CAMlB;IAED;;;;;;;OAOG;IACH,gBAaC;CACF;AA7rBD;IACE,4BAIC;IADC,WAAkB;IAEpB,mBAEC;IACD;;;OAGG;IACH,kBAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,WAFa,MAAM,EAAE,CAIpB;IAED;;;OAGG;IACH,UAFa,MAAM,CAIlB;CACF;AACD;IACE,4BAIC;IADC,kBAAgC;IAElC,mBAEC;IAED;;;OAGG;IACH,kBAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,WAFa,MAAM,EAAE,CAIpB;IAED;;;OAGG;IACH,UAFa,MAAM,CAIlB;CACF;AA3FD;;GAEG;AACH;IACE,8BAAkD;IAClD,oBAEC;IAED;;;OAGG;IACH,kBAFa,OAAO,CAInB;IAED;;;OAGG;IACH,mBAFa,OAAO,CAInB;CACF"}
1
+ {"version":3,"file":"index.esm.d.ts","sourceRoot":"","sources":["index.esm.js"],"names":[],"mappings":"AA66KA;;;;;;;;;;GAUG;AACH;IACE;;OAEG;IACH,gCAA4B;IAC5B;;OAEG;IACH,sBAAkB;IAClB;;;OAGG;IACH,yBAAqB;IACrB;;OAEG;IACH,sCAAkC;IAClC;;OAEG;IACH,6BAA0B;IAE1B;;;;;;;;;;;OAWG;IACH,kBAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;OAKG;IACH,sBAJW,MAAM,mBAEJ,KAAK,CAyBjB;IAED;;;;;;;OAOG;IACH,sBALW,MAAM,SACN,MAAM,GAAC,MAAM,EAAE,GACb,OAAO,CAKnB;IAED;;;OAGG;IACH,wBAWC;IAED;;;;OAIG;IACH,qBAHW,MAAM,SACN,MAAM,EAOhB;IAHC,qBAA2B;IAE3B,mBAAuB;IAGzB;;;OAGG;IACH,cAEC;IAED;;;OAGG;IACH,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ular expression engine that provides linear time matching
4
4
  *
5
- * @version v0.3.3
5
+ * @version v0.4.0
6
6
  * @author Alexey Vasiliev
7
7
  * @homepage https://github.com/le0pard/re2js#readme
8
8
  * @repository github:le0pard/re2js
@@ -417,6 +417,8 @@ class Unicode {
417
417
  // equalsIgnoreCase performs case-insensitive equality comparison
418
418
  // on the given runes |r1| and |r2|, with special consideration
419
419
  // for the likely scenario where both runes are ASCII characters.
420
+ // If non-ASCII, Unicode case folding will be performed on |r1|
421
+ // to compare it to |r2|.
420
422
  // -1 is interpreted as the end-of-file mark.
421
423
  static equalsIgnoreCase(r1, r2) {
422
424
  // Runes already match, or one of them is EOF
@@ -675,9 +677,7 @@ class Utils {
675
677
  // example
676
678
  // Encoding[(Encoding['UTF_16'] = 0)] = 'UTF_16'
677
679
  // Encoding[(Encoding['UTF_8'] = 1)] = 'UTF_8'
678
- const createEnum = function () {
679
- let values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
680
- let initNum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
680
+ const createEnum = (values = [], initNum = 0) => {
681
681
  const enumObject = {};
682
682
  for (let i = 0; i < values.length; i++) {
683
683
  const val = values[i];
@@ -812,8 +812,7 @@ class RE2JSException extends Error {
812
812
  * An exception thrown by the parser if the pattern was invalid.
813
813
  */
814
814
  class RE2JSSyntaxException extends RE2JSException {
815
- constructor(error) {
816
- let input = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
815
+ constructor(error, input = null) {
817
816
  let message = `error parsing regexp: ${error}`;
818
817
  if (input) {
819
818
  message += `: \`${input}\``;
@@ -986,8 +985,7 @@ class Matcher {
986
985
  * @param {string|number} [group=0]
987
986
  * @returns {string}
988
987
  */
989
- start() {
990
- let group = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
988
+ start(group = 0) {
991
989
  if (typeof group === 'string') {
992
990
  const groupInt = this.namedGroups[group];
993
991
  if (!Number.isFinite(groupInt)) {
@@ -1005,8 +1003,7 @@ class Matcher {
1005
1003
  * @param {string|number} [group=0]
1006
1004
  * @returns {string}
1007
1005
  */
1008
- end() {
1009
- let group = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
1006
+ end(group = 0) {
1010
1007
  if (typeof group === 'string') {
1011
1008
  const groupInt = this.namedGroups[group];
1012
1009
  if (!Number.isFinite(groupInt)) {
@@ -1023,8 +1020,7 @@ class Matcher {
1023
1020
  * @param {string|number} [group=0]
1024
1021
  * @returns {string}
1025
1022
  */
1026
- group() {
1027
- let group = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
1023
+ group(group = 0) {
1028
1024
  if (typeof group === 'string') {
1029
1025
  const groupInt = this.namedGroups[group];
1030
1026
  if (!Number.isFinite(groupInt)) {
@@ -1104,8 +1100,7 @@ class Matcher {
1104
1100
  * @returns {boolean} if it finds a match
1105
1101
  * @throws IndexOutOfBoundsException if start is not a valid input position
1106
1102
  */
1107
- find() {
1108
- let start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1103
+ find(start = null) {
1109
1104
  if (start !== null) {
1110
1105
  if (start < 0 || start > this.matcherInputLength) {
1111
1106
  throw new RE2JSGroupException(`start index out of bounds: ${start}`);
@@ -1188,8 +1183,7 @@ class Matcher {
1188
1183
  * @throws IndexOutOfBoundsException if replacement refers to an invalid group
1189
1184
  * @private
1190
1185
  */
1191
- appendReplacement(replacement) {
1192
- let perlMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1186
+ appendReplacement(replacement, perlMode = false) {
1193
1187
  let res = '';
1194
1188
  const s = this.start();
1195
1189
  const e = this.end();
@@ -1373,8 +1367,7 @@ class Matcher {
1373
1367
  * @returns {string} the input string with the matches replaced
1374
1368
  * @throws IndexOutOfBoundsException if replacement refers to an invalid group and perlMode is false
1375
1369
  */
1376
- replaceAll(replacement) {
1377
- let perlMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1370
+ replaceAll(replacement, perlMode = false) {
1378
1371
  return this.replace(replacement, true, perlMode);
1379
1372
  }
1380
1373
 
@@ -1387,8 +1380,7 @@ class Matcher {
1387
1380
  * @returns {string} the input string with the first match replaced
1388
1381
  * @throws IndexOutOfBoundsException if replacement refers to an invalid group and perlMode is false
1389
1382
  */
1390
- replaceFirst(replacement) {
1391
- let perlMode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1383
+ replaceFirst(replacement, perlMode = false) {
1392
1384
  return this.replace(replacement, false, perlMode);
1393
1385
  }
1394
1386
 
@@ -1400,9 +1392,7 @@ class Matcher {
1400
1392
  * @returns {string}
1401
1393
  * @private
1402
1394
  */
1403
- replace(replacement) {
1404
- let all = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1405
- let perlMode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1395
+ replace(replacement, all = true, perlMode = false) {
1406
1396
  let res = '';
1407
1397
  this.reset();
1408
1398
  while (this.find()) {
@@ -1998,6 +1988,10 @@ class Inst {
1998
1988
  // class.
1999
1989
  if (this.runes.length === 1) {
2000
1990
  const r0 = this.runes[0];
1991
+ // If this pattern is case-insensitive, apply Unicode case folding to compare the two runes.
1992
+ // Note that this may result in a case-folding loop when executed,
1993
+ // so attempt to reduce the chance of that occurring
1994
+ // by performing case folding on |r0| from the pattern rather than |r| from the input.
2001
1995
  if ((this.arg & RE2Flags.FOLD_CASE) !== 0) {
2002
1996
  return Unicode.equalsIgnoreCase(r0, r);
2003
1997
  }
@@ -2229,10 +2223,7 @@ class Prog {
2229
2223
  * @class
2230
2224
  */
2231
2225
  class Frag {
2232
- constructor() {
2233
- let i = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
2234
- let out = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
2235
- let nullable = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
2226
+ constructor(i = 0, out = 0, nullable = false) {
2236
2227
  this.i = i; // an instruction address (pc).
2237
2228
  this.out = out; // a patch list; see explanation in Prog.js
2238
2229
  this.nullable = nullable; // whether the fragment can match the empty string
@@ -2725,8 +2716,7 @@ class CharClass {
2725
2716
  CharClass.qsortIntPair(array, i, right);
2726
2717
  }
2727
2718
  }
2728
- constructor() {
2729
- let r = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Utils.emptyInts();
2719
+ constructor(r = Utils.emptyInts()) {
2730
2720
  this.r = r; // inclusive ranges, pairs of [lo,hi]. r.length is even.
2731
2721
  this.len = r.length; // prefix of |r| that is defined. Even.
2732
2722
  }
@@ -3400,8 +3390,7 @@ class Parser {
3400
3390
  static concatRunes(x, y) {
3401
3391
  return [...x, ...y];
3402
3392
  }
3403
- constructor(wholeRegexp) {
3404
- let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
3393
+ constructor(wholeRegexp, flags = 0) {
3405
3394
  this.wholeRegexp = wholeRegexp;
3406
3395
  // Flags control the behavior of the parser and record information about
3407
3396
  // regexp context.
@@ -4143,21 +4132,22 @@ class Parser {
4143
4132
  // support all three as well. EcmaScript 4 uses only the Python form.
4144
4133
  //
4145
4134
  // In both the open source world (via Code Search) and the
4146
- // Google source tree, (?P<expr>name) is the dominant form,
4147
- // so that's the one we implement. One is enough.
4135
+ // Google source tree, (?P<name>expr) and (?<name>expr) are the
4136
+ // dominant forms of named captures and both are supported.
4148
4137
  const s = t.rest();
4149
- if (s.startsWith('(?P<')) {
4138
+ if (s.startsWith('(?P<') || s.startsWith('(?<')) {
4150
4139
  // Pull out name.
4140
+ const begin = s.charAt(2) === 'P' ? 4 : 3;
4151
4141
  const end = s.indexOf('>');
4152
4142
  if (end < 0) {
4153
4143
  throw new RE2JSSyntaxException(Parser.ERR_INVALID_NAMED_CAPTURE, s);
4154
4144
  }
4155
- const name = s.substring(4, end); // "name"
4145
+ const name = s.substring(begin, end); // "name"
4156
4146
  t.skipString(name);
4157
- t.skip(5); // "(?P<>"
4147
+ t.skip(begin + 1); // "(?P<>" or "(?<>"
4158
4148
  if (!Parser.isValidCaptureName(name)) {
4159
4149
  // "(?P<name>"
4160
- throw new RE2JSSyntaxException(Parser.ERR_INVALID_NAMED_CAPTURE, s.substring(0, end));
4150
+ throw new RE2JSSyntaxException(Parser.ERR_INVALID_NAMED_CAPTURE, s.substring(0, end + 1)); // "(?P<name>" or "(?<name>"
4161
4151
  }
4162
4152
  // Like ordinary capture, but named.
4163
4153
  const re = this.op(Regexp.Op.LEFT_PAREN);
@@ -4629,8 +4619,7 @@ class Machine {
4629
4619
  }
4630
4620
 
4631
4621
  // Frees all threads on the thread queue, returning them to the free pool.
4632
- freeQueue(queue) {
4633
- let from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
4622
+ freeQueue(queue, from = 0) {
4634
4623
  const numberOfThread = queue.size - from;
4635
4624
  const requiredPoolLength = this.poolSize + numberOfThread;
4636
4625
  if (this.pool.length < requiredPoolLength) {
@@ -4960,9 +4949,7 @@ class RE2 {
4960
4949
  static match(pattern, s) {
4961
4950
  return RE2.compile(pattern).match(s);
4962
4951
  }
4963
- constructor(expr, prog) {
4964
- let numSubexp = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
4965
- let longest = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
4952
+ constructor(expr, prog, numSubexp = 0, longest = 0) {
4966
4953
  this.expr = expr; // as passed to Compile
4967
4954
  this.prog = prog; // compiled program
4968
4955
  this.numSubexp = numSubexp;
@@ -5196,8 +5183,7 @@ class RE2 {
5196
5183
  }
5197
5184
 
5198
5185
  // Find matches in input.
5199
- allMatches(input, n) {
5200
- let deliverFun = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : v => v;
5186
+ allMatches(input, n, deliverFun = v => v) {
5201
5187
  let result = [];
5202
5188
  const end = input.endPos();
5203
5189
  if (n < 0) {