A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/mysticatea/regexpp/commit/024a64a24e1091fbd564c88a56e15dade3e378f5 below:

✨ Supports ES2022 RegExp Match Indices (#22) · mysticatea/regexpp@024a64a · GitHub

File tree Expand file treeCollapse file tree 19 files changed

+1415

-652

lines changed

Filter options

Expand file treeCollapse file tree 19 files changed

+1415

-652

lines changed Original file line number Diff line number Diff line change

@@ -288,6 +288,7 @@ export interface Flags extends NodeBase {

288 288

parent: RegExpLiteral | null

289 289

dotAll: boolean

290 290

global: boolean

291 +

hasIndices: boolean

291 292

ignoreCase: boolean

292 293

multiline: boolean

293 294

sticky: boolean

Original file line number Diff line number Diff line change

@@ -1 +1,10 @@

1 -

export type EcmaVersion = 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021

1 +

export type EcmaVersion =

2 +

| 5

3 +

| 2015

4 +

| 2016

5 +

| 2017

6 +

| 2018

7 +

| 2019

8 +

| 2020

9 +

| 2021

10 +

| 2022

Original file line number Diff line number Diff line change

@@ -40,7 +40,7 @@ class RegExpParserState {

40 40 41 41

public constructor(options?: RegExpParser.Options) {

42 42

this.strict = Boolean(options && options.strict)

43 -

this.ecmaVersion = (options && options.ecmaVersion) || 2020

43 +

this.ecmaVersion = (options && options.ecmaVersion) || 2022

44 44

}

45 45 46 46

public get pattern(): Pattern {

@@ -66,6 +66,7 @@ class RegExpParserState {

66 66

unicode: boolean,

67 67

sticky: boolean,

68 68

dotAll: boolean,

69 +

hasIndices: boolean,

69 70

): void {

70 71

this._flags = {

71 72

type: "Flags",

@@ -79,6 +80,7 @@ class RegExpParserState {

79 80

unicode,

80 81

sticky,

81 82

dotAll,

83 +

hasIndices,

82 84

}

83 85

}

84 86

@@ -502,11 +504,12 @@ export namespace RegExpParser {

502 504

strict?: boolean

503 505 504 506

/**

505 -

* ECMAScript version. Default is `2020`.

507 +

* ECMAScript version. Default is `2022`.

506 508

* - `2015` added `u` and `y` flags.

507 509

* - `2018` added `s` flag, Named Capturing Group, Lookbehind Assertion,

508 510

* and Unicode Property Escape.

509 511

* - `2019`, `2020`, and `2021` added more valid Unicode Property Escapes.

512 +

* - `2022` added `d` flag.

510 513

*/

511 514

ecmaVersion?: EcmaVersion

512 515

}

Original file line number Diff line number Diff line change

@@ -127,11 +127,12 @@ export namespace RegExpValidator {

127 127

strict?: boolean

128 128 129 129

/**

130 -

* ECMAScript version. Default is `2020`.

130 +

* ECMAScript version. Default is `2022`.

131 131

* - `2015` added `u` and `y` flags.

132 132

* - `2018` added `s` flag, Named Capturing Group, Lookbehind Assertion,

133 133

* and Unicode Property Escape.

134 134

* - `2019`, `2020`, and `2021` added more valid Unicode Property Escapes.

135 +

* - `2022` added `d` flag.

135 136

*/

136 137

ecmaVersion?: EcmaVersion

137 138

@@ -158,6 +159,7 @@ export namespace RegExpValidator {

158 159

* @param unicode `u` flag.

159 160

* @param sticky `y` flag.

160 161

* @param dotAll `s` flag.

162 +

* @param hasIndices `d` flag.

161 163

*/

162 164

onFlags?(

163 165

start: number,

@@ -168,6 +170,7 @@ export namespace RegExpValidator {

168 170

unicode: boolean,

169 171

sticky: boolean,

170 172

dotAll: boolean,

173 +

hasIndices: boolean,

171 174

): void

172 175 173 176

/**

@@ -476,6 +479,7 @@ export class RegExpValidator {

476 479

let sticky = false

477 480

let unicode = false

478 481

let dotAll = false

482 +

let hasIndices = false

479 483

for (let i = start; i < end; ++i) {

480 484

const flag = source.charCodeAt(i)

481 485

@@ -496,6 +500,8 @@ export class RegExpValidator {

496 500

sticky = true

497 501

} else if (flag === LatinSmallLetterS && this.ecmaVersion >= 2018) {

498 502

dotAll = true

503 +

} else if (flag === LatinSmallLetterD && this.ecmaVersion >= 2022) {

504 +

hasIndices = true

499 505

} else {

500 506

this.raise(`Invalid flag '${source[i]}'`)

501 507

}

@@ -509,6 +515,7 @@ export class RegExpValidator {

509 515

unicode,

510 516

sticky,

511 517

dotAll,

518 +

hasIndices,

512 519

)

513 520

}

514 521

@@ -548,7 +555,7 @@ export class RegExpValidator {

548 555

}

549 556 550 557

private get ecmaVersion() {

551 -

return this._options.ecmaVersion || 2020

558 +

return this._options.ecmaVersion || 2022

552 559

}

553 560 554 561

private onLiteralEnter(start: number): void {

@@ -572,6 +579,7 @@ export class RegExpValidator {

572 579

unicode: boolean,

573 580

sticky: boolean,

574 581

dotAll: boolean,

582 +

hasIndices: boolean,

575 583

): void {

576 584

if (this._options.onFlags) {

577 585

this._options.onFlags(

@@ -583,6 +591,7 @@ export class RegExpValidator {

583 591

unicode,

584 592

sticky,

585 593

dotAll,

594 +

hasIndices,

586 595

)

587 596

}

588 597

}

Original file line number Diff line number Diff line change

@@ -3,7 +3,19 @@ import path from "path"

3 3 4 4

type FixtureData = {

5 5

[filename: string]: {

6 -

options: { strict: boolean; ecmaVersion: 5 | 2015 | 2016 | 2017 | 2018 }

6 +

options: {

7 +

strict: boolean

8 +

ecmaVersion:

9 +

| 5

10 +

| 2015

11 +

| 2016

12 +

| 2017

13 +

| 2018

14 +

| 2019

15 +

| 2020

16 +

| 2021

17 +

| 2022

18 +

}

7 19

patterns: {

8 20

[source: string]:

9 21

| { ast: object }

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4