phy-js-base-tokenizer 0.1.0rc5__tar.gz
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.
Potentially problematic release.
This version of phy-js-base-tokenizer might be problematic. Click here for more details.
- phy_js_base_tokenizer-0.1.0rc5/PKG-INFO +59 -0
- phy_js_base_tokenizer-0.1.0rc5/README.md +39 -0
- phy_js_base_tokenizer-0.1.0rc5/pyproject.toml +41 -0
- phy_js_base_tokenizer-0.1.0rc5/pyproject.toml.orig +38 -0
- phy_js_base_tokenizer-0.1.0rc5/src/phy_js_base_tokenizer/__init__.py +6 -0
- phy_js_base_tokenizer-0.1.0rc5/src/phy_js_base_tokenizer/_base_toknzer.py +187 -0
- phy_js_base_tokenizer-0.1.0rc5/src/phy_js_base_tokenizer/_compat.py +272 -0
- phy_js_base_tokenizer-0.1.0rc5/src/phy_js_base_tokenizer/_js/main.mjs +10 -0
- phy_js_base_tokenizer-0.1.0rc5/src/phy_js_base_tokenizer/_meta.py +3 -0
- phy_js_base_tokenizer-0.1.0rc5/src/phy_js_base_tokenizer/_tok.py +97 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: phy-js-base-tokenizer
|
|
3
|
+
Version: 0.1.0rc5
|
|
4
|
+
Summary: Base tokenizer for phy project to tokenize javascript.
|
|
5
|
+
Author: alfred-du
|
|
6
|
+
Author-email: alfred-du <ihearmywords@hotmail.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
15
|
+
Requires-Python: >=3.10, <4
|
|
16
|
+
Project-URL: Homepage, https://github.com/phy-precompiler/js-base-tokenizer
|
|
17
|
+
Project-URL: Repository, https://github.com/phy-precompiler/js-base-tokenizer
|
|
18
|
+
Project-URL: Issues, https://github.com/phy-precompiler/js-base-tokenizer/issues
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# PHY-js-base-tokenizer
|
|
22
|
+
|
|
23
|
+
<p align="left">
|
|
24
|
+
<a href="#"><img alt="PyPI" src="https://img.shields.io/pypi/v/phy-js-base-tokenizer.svg"></a>
|
|
25
|
+
<a href="#"><img alt="Python Versions" src="https://img.shields.io/pypi/pyversions/phy-js-base-tokenizer.svg"></a>
|
|
26
|
+
<a href="#"><img alt="License" src="https://img.shields.io/badge/license-MIT-blue.svg"></a>
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
Javascript tokenizer that conforms the base-tokenizor protocol of project `phy`.
|
|
30
|
+
|
|
31
|
+
This project is part of [`phy`](https://github.com/phy-precompiler).
|
|
32
|
+
|
|
33
|
+
## Install
|
|
34
|
+
|
|
35
|
+
```shell
|
|
36
|
+
pip install phy-js-base-tokenizer
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## How to use
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from io import StringIO
|
|
43
|
+
from phy_js_base_tokenizer import JavascriptsBaseToknzer
|
|
44
|
+
|
|
45
|
+
code = '''const x = /abc/g;'''
|
|
46
|
+
code_str_readline = StringIO(code).readline
|
|
47
|
+
|
|
48
|
+
js_tokenizer = JavascriptsBaseToknzer()
|
|
49
|
+
for _token in js_tokenizer.generate_toks(code_str_readline):
|
|
50
|
+
print(_token)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
# Develop
|
|
54
|
+
|
|
55
|
+
Build the package with `uv`:
|
|
56
|
+
|
|
57
|
+
```shell
|
|
58
|
+
uv build
|
|
59
|
+
```
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# PHY-js-base-tokenizer
|
|
2
|
+
|
|
3
|
+
<p align="left">
|
|
4
|
+
<a href="#"><img alt="PyPI" src="https://img.shields.io/pypi/v/phy-js-base-tokenizer.svg"></a>
|
|
5
|
+
<a href="#"><img alt="Python Versions" src="https://img.shields.io/pypi/pyversions/phy-js-base-tokenizer.svg"></a>
|
|
6
|
+
<a href="#"><img alt="License" src="https://img.shields.io/badge/license-MIT-blue.svg"></a>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
Javascript tokenizer that conforms the base-tokenizor protocol of project `phy`.
|
|
10
|
+
|
|
11
|
+
This project is part of [`phy`](https://github.com/phy-precompiler).
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```shell
|
|
16
|
+
pip install phy-js-base-tokenizer
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## How to use
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from io import StringIO
|
|
23
|
+
from phy_js_base_tokenizer import JavascriptsBaseToknzer
|
|
24
|
+
|
|
25
|
+
code = '''const x = /abc/g;'''
|
|
26
|
+
code_str_readline = StringIO(code).readline
|
|
27
|
+
|
|
28
|
+
js_tokenizer = JavascriptsBaseToknzer()
|
|
29
|
+
for _token in js_tokenizer.generate_toks(code_str_readline):
|
|
30
|
+
print(_token)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
# Develop
|
|
34
|
+
|
|
35
|
+
Build the package with `uv`:
|
|
36
|
+
|
|
37
|
+
```shell
|
|
38
|
+
uv build
|
|
39
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "phy-js-base-tokenizer"
|
|
3
|
+
version = "0.1.0rc5"
|
|
4
|
+
description = "Base tokenizer for phy project to tokenize javascript."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10, <4"
|
|
7
|
+
classifiers = [
|
|
8
|
+
"Programming Language :: Python :: 3",
|
|
9
|
+
"Programming Language :: Python :: 3.10",
|
|
10
|
+
"Programming Language :: Python :: 3.11",
|
|
11
|
+
"Programming Language :: Python :: 3.12",
|
|
12
|
+
"Programming Language :: Python :: 3.13",
|
|
13
|
+
"Programming Language :: Python :: 3.14",
|
|
14
|
+
"Programming Language :: Python :: 3.15",
|
|
15
|
+
]
|
|
16
|
+
dependencies = []
|
|
17
|
+
|
|
18
|
+
[[project.authors]]
|
|
19
|
+
name = "alfred-du"
|
|
20
|
+
email = "ihearmywords@hotmail.com"
|
|
21
|
+
|
|
22
|
+
[project.license]
|
|
23
|
+
text = "MIT"
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
Homepage = "https://github.com/phy-precompiler/js-base-tokenizer"
|
|
27
|
+
Repository = "https://github.com/phy-precompiler/js-base-tokenizer"
|
|
28
|
+
Issues = "https://github.com/phy-precompiler/js-base-tokenizer/issues"
|
|
29
|
+
|
|
30
|
+
[build-system]
|
|
31
|
+
requires = ["uv_build>=0.10.4,<0.11"]
|
|
32
|
+
build-backend = "uv_build"
|
|
33
|
+
|
|
34
|
+
[dependency-groups]
|
|
35
|
+
dev = [
|
|
36
|
+
"polars>=2.2.0",
|
|
37
|
+
"pylint>=4.0.2",
|
|
38
|
+
"pytest-dependency>=0.6.0",
|
|
39
|
+
"pytest>=8.3.5",
|
|
40
|
+
"ruff>=0.16.8",
|
|
41
|
+
]
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "phy-js-base-tokenizer"
|
|
3
|
+
version = "0.1.0rc5"
|
|
4
|
+
description = "Base tokenizer for phy project to tokenize javascript."
|
|
5
|
+
authors = [{ name = "alfred-du", email = "ihearmywords@hotmail.com" }]
|
|
6
|
+
license = { text = "MIT" }
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
requires-python = ">=3.10, <4"
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Programming Language :: Python :: 3",
|
|
11
|
+
"Programming Language :: Python :: 3.10",
|
|
12
|
+
"Programming Language :: Python :: 3.11",
|
|
13
|
+
"Programming Language :: Python :: 3.12",
|
|
14
|
+
"Programming Language :: Python :: 3.13",
|
|
15
|
+
"Programming Language :: Python :: 3.14",
|
|
16
|
+
"Programming Language :: Python :: 3.15",
|
|
17
|
+
]
|
|
18
|
+
dependencies = [
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[project.urls]
|
|
22
|
+
Homepage = "https://github.com/phy-precompiler/js-base-tokenizer"
|
|
23
|
+
Repository = "https://github.com/phy-precompiler/js-base-tokenizer"
|
|
24
|
+
Issues = "https://github.com/phy-precompiler/js-base-tokenizer/issues"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
[build-system]
|
|
28
|
+
requires = ["uv_build>=0.10.4,<0.11"]
|
|
29
|
+
build-backend = "uv_build"
|
|
30
|
+
|
|
31
|
+
[dependency-groups]
|
|
32
|
+
dev = [
|
|
33
|
+
"polars>=2.2.0",
|
|
34
|
+
"pylint>=4.0.2",
|
|
35
|
+
"pytest-dependency>=0.6.0",
|
|
36
|
+
"pytest>=8.3.5",
|
|
37
|
+
"ruff>=0.16.8",
|
|
38
|
+
]
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"""Javascript code tokenizer that comform base tokenizer protocol of project `phy`."""
|
|
2
|
+
|
|
3
|
+
# imports
|
|
4
|
+
import json
|
|
5
|
+
import shutil
|
|
6
|
+
import subprocess
|
|
7
|
+
import token as builtin_token
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import Callable, Dict
|
|
10
|
+
|
|
11
|
+
# local imports
|
|
12
|
+
from phy_js_base_tokenizer._compat import StdTokType, TokGen, TokInfo
|
|
13
|
+
from phy_js_base_tokenizer._meta import FOREIGN_JS_NAMESPACE
|
|
14
|
+
from phy_js_base_tokenizer._tok import (
|
|
15
|
+
INVALID_TEMPLATE,
|
|
16
|
+
KEYWORD_LITERALS,
|
|
17
|
+
OP_LITERALS,
|
|
18
|
+
PRIVATE_ID,
|
|
19
|
+
REGEXP,
|
|
20
|
+
SHEBANG,
|
|
21
|
+
TEMPLATE,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
# constants
|
|
25
|
+
JS_ENTRY_FILE = Path(__file__).resolve().parent / '_js' / 'main.mjs'
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class JavascriptsBaseToknzer:
|
|
29
|
+
"""This base tokenizer delegates lexing work to `acronjs`. Since acronjs is a nodejs
|
|
30
|
+
library, a bridge based on subprocess is used to share data.
|
|
31
|
+
|
|
32
|
+
Performance is not the primary consideration for this plugin yet:
|
|
33
|
+
+ Lazy source inputs (which `readline` gives) will be concatencated until EOF for an
|
|
34
|
+
entire source. This is essential for recognize real line segmentations.
|
|
35
|
+
+ It actually involves AST parser to recongnize certain tokens, not only lexer.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
# class attributes
|
|
39
|
+
_js_entry_file: Path = JS_ENTRY_FILE
|
|
40
|
+
_std_tok_type_map: Dict[str, StdTokType] = {
|
|
41
|
+
'name': StdTokType.NAME,
|
|
42
|
+
'num': StdTokType.NUMBER,
|
|
43
|
+
'string': StdTokType.STRING,
|
|
44
|
+
'newline': StdTokType.NEWLINE,
|
|
45
|
+
'eof': StdTokType.ENDMARKER,
|
|
46
|
+
'commentLine': StdTokType.COMMENT,
|
|
47
|
+
'commentBlock': StdTokType.COMMENT,
|
|
48
|
+
}
|
|
49
|
+
_ns_tok_type_map: Dict[str, StdTokType] = {
|
|
50
|
+
'regexp': REGEXP,
|
|
51
|
+
'template': TEMPLATE,
|
|
52
|
+
'invalidTemplate': INVALID_TEMPLATE,
|
|
53
|
+
'privateId': PRIVATE_ID,
|
|
54
|
+
'shebang': SHEBANG,
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
# instance attributes
|
|
58
|
+
_nodejs_executable: str
|
|
59
|
+
|
|
60
|
+
def __init__(self):
|
|
61
|
+
"""check node runtime & necessary packages"""
|
|
62
|
+
# check nodejs executable
|
|
63
|
+
nodejs_executable = shutil.which('node')
|
|
64
|
+
if nodejs_executable is None:
|
|
65
|
+
raise RuntimeError(
|
|
66
|
+
'Node.js is required. Please install Node.js and ensure it is in PATH.'
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
self._nodejs_executable = nodejs_executable
|
|
70
|
+
|
|
71
|
+
# check npm & acornjs installed (either locally or globally)
|
|
72
|
+
npm_executable = shutil.which('npm')
|
|
73
|
+
acornjs_found = False
|
|
74
|
+
if npm_executable is not None:
|
|
75
|
+
acornjs_found = (
|
|
76
|
+
subprocess.run(
|
|
77
|
+
[npm_executable, 'list', '-g', 'acorn', '--depth=0'],
|
|
78
|
+
stdout=subprocess.DEVNULL,
|
|
79
|
+
stderr=subprocess.DEVNULL,
|
|
80
|
+
).returncode
|
|
81
|
+
== 0
|
|
82
|
+
) or (
|
|
83
|
+
subprocess.run(
|
|
84
|
+
[npm_executable, 'list', 'acorn', '--depth=0'],
|
|
85
|
+
stdout=subprocess.DEVNULL,
|
|
86
|
+
stderr=subprocess.DEVNULL,
|
|
87
|
+
).returncode
|
|
88
|
+
== 0
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
if not acornjs_found:
|
|
92
|
+
raise RuntimeError(
|
|
93
|
+
'acronjs is required. Please install it globally via `npm install -g acron` '
|
|
94
|
+
'or locally via `npm install acron`.'
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
def generate_toks(self, str_readline: Callable[[], str]) -> TokGen:
|
|
98
|
+
"""tokenize readline callable that return str"""
|
|
99
|
+
# read all lines; some complex lexing work involves parser that relies on full code
|
|
100
|
+
entire_content = ''.join(iter(str_readline, ''))
|
|
101
|
+
|
|
102
|
+
# run node script and outputs to stdout
|
|
103
|
+
_json_lines_result = subprocess.run(
|
|
104
|
+
['node', str(self._js_entry_file)],
|
|
105
|
+
input=entire_content,
|
|
106
|
+
capture_output=True,
|
|
107
|
+
encoding="utf-8",
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
# catch stderr for js syntax error
|
|
111
|
+
if _json_lines_result.returncode != 0:
|
|
112
|
+
try:
|
|
113
|
+
error = json.loads(_json_lines_result.stderr)
|
|
114
|
+
except json.JSONDecodeError:
|
|
115
|
+
print(_json_lines_result.stderr)
|
|
116
|
+
|
|
117
|
+
raise RuntimeError(_json_lines_result.stderr)
|
|
118
|
+
|
|
119
|
+
raise SyntaxError(
|
|
120
|
+
error["message"],
|
|
121
|
+
(
|
|
122
|
+
"<javascript>",
|
|
123
|
+
error["loc"]["line"],
|
|
124
|
+
error["loc"]["column"] + 1,
|
|
125
|
+
None,
|
|
126
|
+
),
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
# parse json lines of stdout to `phy` tokinfo
|
|
130
|
+
for line in _json_lines_result.stdout.split('\n'):
|
|
131
|
+
if not line:
|
|
132
|
+
continue
|
|
133
|
+
|
|
134
|
+
_row_token = json.loads(line)
|
|
135
|
+
|
|
136
|
+
_token_type = _row_token['type']
|
|
137
|
+
_line = ''.join(_row_token['src_lines'])
|
|
138
|
+
_token_string = _row_token['string']
|
|
139
|
+
_start = tuple(_row_token['start'].values())
|
|
140
|
+
_end = tuple(_row_token['end'].values())
|
|
141
|
+
|
|
142
|
+
if _token_type in OP_LITERALS:
|
|
143
|
+
yield TokInfo.new_op(
|
|
144
|
+
# DO NOT use `_token_type`, in case for union op literal like '++/--'
|
|
145
|
+
op_literal=_token_string,
|
|
146
|
+
start=_start,
|
|
147
|
+
end=_end,
|
|
148
|
+
line=_line,
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
elif _token_type in KEYWORD_LITERALS:
|
|
152
|
+
yield TokInfo(
|
|
153
|
+
type=builtin_token.NAME,
|
|
154
|
+
string=_token_string,
|
|
155
|
+
start=_start,
|
|
156
|
+
end=_end,
|
|
157
|
+
line=_line,
|
|
158
|
+
std_type=StdTokType.NAME,
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
elif _token_type in self._std_tok_type_map:
|
|
162
|
+
yield TokInfo.new_std(
|
|
163
|
+
ns_type=self._std_tok_type_map[_token_type],
|
|
164
|
+
string=_token_string,
|
|
165
|
+
start=_start,
|
|
166
|
+
end=_end,
|
|
167
|
+
line=_line,
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
elif _token_type in self._ns_tok_type_map:
|
|
171
|
+
yield TokInfo(
|
|
172
|
+
type=None,
|
|
173
|
+
string=_token_string,
|
|
174
|
+
start=_start,
|
|
175
|
+
end=_end,
|
|
176
|
+
line=_line,
|
|
177
|
+
std_type=None,
|
|
178
|
+
ns_type=self._ns_tok_type_map[_token_type],
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
else:
|
|
182
|
+
raise NotImplementedError(f'unrecognized token type {_token_type}')
|
|
183
|
+
|
|
184
|
+
class Meta:
|
|
185
|
+
"""meta internal class"""
|
|
186
|
+
|
|
187
|
+
namespace = FOREIGN_JS_NAMESPACE
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
"""Compatible layer for `phy-core`. This submodule should be removed after adding
|
|
2
|
+
`phy-core` as dependency.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
# imports
|
|
6
|
+
import token as builtin_token
|
|
7
|
+
from dataclasses import dataclass
|
|
8
|
+
from enum import Enum
|
|
9
|
+
from typing import Generator, Optional, Protocol, Tuple, Union
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class TokType(Protocol):
|
|
13
|
+
"""structural typing for union `StdTokType` and `NamespacedTokType`"""
|
|
14
|
+
|
|
15
|
+
# instance attributes
|
|
16
|
+
namespace: Optional[str]
|
|
17
|
+
name: str
|
|
18
|
+
|
|
19
|
+
# instance methods
|
|
20
|
+
# these boolean properties are defined in cpython source `Include/internal/pycore_token.h`
|
|
21
|
+
def is_terminal(self) -> bool: ...
|
|
22
|
+
def is_eof(self) -> bool: ...
|
|
23
|
+
def is_whitespace(self) -> bool: ...
|
|
24
|
+
def is_string_lit(self) -> bool: ...
|
|
25
|
+
|
|
26
|
+
# these boolean properties are for untokenizing
|
|
27
|
+
def is_curly_bracket_escaped(self) -> bool: ...
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class StdTokType(Enum):
|
|
31
|
+
"""Standard token types are enums of token types in latest python versions (for now 3.14). Removed
|
|
32
|
+
token types (like ASYNC / AWAIT in <3.13) are not inclueded.
|
|
33
|
+
|
|
34
|
+
This enum may change regarding python upgrades.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
# these token types are consistent across python versions
|
|
38
|
+
ENDMARKER = 0
|
|
39
|
+
NAME = 1
|
|
40
|
+
NUMBER = 2
|
|
41
|
+
STRING = 3
|
|
42
|
+
NEWLINE = 4
|
|
43
|
+
INDENT = 5
|
|
44
|
+
DEDENT = 6
|
|
45
|
+
NT_OFFSET = 256
|
|
46
|
+
# Leave room for exact operators token types, which are defined in `StdOpExactTokType` enum and
|
|
47
|
+
# takes int value from 7 ~ 54.
|
|
48
|
+
|
|
49
|
+
# these token types are inconsistent across python versions
|
|
50
|
+
OP = 128
|
|
51
|
+
TYPE_IGNORE = 129
|
|
52
|
+
TYPE_COMMENT = 130
|
|
53
|
+
SOFT_KEYWORD = 131
|
|
54
|
+
ERRORTOKEN = 132
|
|
55
|
+
ENCODING = 133 # this token type is not used in c tokenizer but exists in `tokenize.py`
|
|
56
|
+
N_TOKENS = 134
|
|
57
|
+
COMMENT = (
|
|
58
|
+
135 # this token type is not used in c tokenizer <3.12, but exists in `tokenize.py`
|
|
59
|
+
)
|
|
60
|
+
NL = 136 # this token type is not used in c tokenizer <3.12, but exists in `tokenize.py`
|
|
61
|
+
|
|
62
|
+
# these token types are absent in earlier python versions
|
|
63
|
+
FSTRING_START = 137
|
|
64
|
+
FSTRING_MIDDLE = 138
|
|
65
|
+
FSTRING_END = 139
|
|
66
|
+
TSTRING_START = 140
|
|
67
|
+
TSTRING_MIDDLE = 141
|
|
68
|
+
TSTRING_END = 142
|
|
69
|
+
|
|
70
|
+
# these token types are not builtin ones, but created for compatible use
|
|
71
|
+
FSTRING_STRING = 143 # compatible with fstring on cpython <3.12
|
|
72
|
+
TSTRING_STRING = 144 # use tstring cpython <3.14
|
|
73
|
+
|
|
74
|
+
# protocol properties
|
|
75
|
+
@property
|
|
76
|
+
def namespace(self) -> None:
|
|
77
|
+
return None
|
|
78
|
+
|
|
79
|
+
def __repr__(self):
|
|
80
|
+
"""consistent with namespaced token type"""
|
|
81
|
+
return self.name
|
|
82
|
+
|
|
83
|
+
# these boolean properties are defined in cpython source `Include/internal/pycore_token.h`
|
|
84
|
+
def is_terminal(self) -> bool:
|
|
85
|
+
"""(x) < NT_OFFSET"""
|
|
86
|
+
return self != StdTokType.NT_OFFSET
|
|
87
|
+
|
|
88
|
+
def is_eof(self) -> bool:
|
|
89
|
+
"""(x) == ENDMARKER"""
|
|
90
|
+
return self == StdTokType.ENDMARKER
|
|
91
|
+
|
|
92
|
+
def is_whitespace(self) -> bool:
|
|
93
|
+
"""(x) == ENDMARKER ||
|
|
94
|
+
(x) == NEWLINE ||
|
|
95
|
+
(x) == INDENT ||
|
|
96
|
+
(x) == DEDENT
|
|
97
|
+
"""
|
|
98
|
+
return self in (
|
|
99
|
+
StdTokType.ENDMARKER,
|
|
100
|
+
StdTokType.NEWLINE,
|
|
101
|
+
StdTokType.INDENT,
|
|
102
|
+
StdTokType.DEDENT,
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
def is_string_lit(self) -> bool:
|
|
106
|
+
"""(x) == STRING ||
|
|
107
|
+
(x) == FSTRING_MIDDLE ||
|
|
108
|
+
(x) == TSTRING_MIDDLE)
|
|
109
|
+
"""
|
|
110
|
+
return self in (
|
|
111
|
+
StdTokType.STRING,
|
|
112
|
+
StdTokType.FSTRING_MIDDLE,
|
|
113
|
+
StdTokType.TSTRING_MIDDLE,
|
|
114
|
+
StdTokType.FSTRING_STRING,
|
|
115
|
+
StdTokType.TSTRING_STRING,
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
# these boolean properties are for untokenizing
|
|
119
|
+
def is_curly_bracket_escaped(self) -> bool:
|
|
120
|
+
"""Whether curly bracket should be escaped.
|
|
121
|
+
|
|
122
|
+
REMINDER: returned value of this method for compatible token type
|
|
123
|
+
`FSTRING_STRING` & `TSTRING_STRING` SHOULD BE `False`, otherwise
|
|
124
|
+
the result of untokenzie method will raise error.
|
|
125
|
+
"""
|
|
126
|
+
return self in (
|
|
127
|
+
StdTokType.FSTRING_MIDDLE,
|
|
128
|
+
StdTokType.TSTRING_MIDDLE,
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
@dataclass(frozen=True, slots=True, repr=False)
|
|
133
|
+
class NamespacedTokType:
|
|
134
|
+
"""New token types that defined in `phy` plugins.
|
|
135
|
+
|
|
136
|
+
Builtin token use integer as token value; however single integer may cause conflicts among
|
|
137
|
+
`phy` plugins, so a combine of namespace & scope-unique value is used instead; although this value can
|
|
138
|
+
be integer like builtin token does, but a string value is more convenient when matching grammar
|
|
139
|
+
defined rules (in grammar definition file, token type is referred with name, not integer value).
|
|
140
|
+
"""
|
|
141
|
+
|
|
142
|
+
# instance attributes
|
|
143
|
+
namespace: str
|
|
144
|
+
name: str # should be consist with token variable identifier when defined
|
|
145
|
+
|
|
146
|
+
literal_str: Optional[str] = None # exact token string of Keyword, Soft keyword & OP
|
|
147
|
+
|
|
148
|
+
# these not-required attributes mainly used for boolean properties like `is_terminal()`
|
|
149
|
+
_is_terminal: bool = True
|
|
150
|
+
_is_eof: bool = False
|
|
151
|
+
_is_whitespace: bool = False
|
|
152
|
+
_is_string_lit: bool = False
|
|
153
|
+
_is_curly_bracket_escaped: bool = False
|
|
154
|
+
|
|
155
|
+
def __repr__(self):
|
|
156
|
+
"""use double underscore to separate namespace & name"""
|
|
157
|
+
return f'{self.namespace}__{self.name}'
|
|
158
|
+
|
|
159
|
+
def __eq__(self, other: Union['NamespacedTokType', Tuple[str, str]]): # type: ignore[override]
|
|
160
|
+
"""overload `==` operator; plain tuple of namespace & name are supported"""
|
|
161
|
+
if isinstance(other, NamespacedTokType):
|
|
162
|
+
return self.namespace == other.namespace and self.name == other.name
|
|
163
|
+
elif isinstance(other, tuple) and len(other) == 2:
|
|
164
|
+
return self.namespace == other[0] and self.name == other[1]
|
|
165
|
+
else:
|
|
166
|
+
# DO NOT return False; return `NotImplemented` can make `==` operator commutative
|
|
167
|
+
return NotImplemented
|
|
168
|
+
|
|
169
|
+
def __hash__(self):
|
|
170
|
+
return hash((self.namespace, self.name))
|
|
171
|
+
|
|
172
|
+
# same boolean properties like standard token types; can be overrode in subclass
|
|
173
|
+
def is_terminal(self) -> bool:
|
|
174
|
+
return self._is_terminal
|
|
175
|
+
|
|
176
|
+
def is_eof(self) -> bool:
|
|
177
|
+
return self._is_eof
|
|
178
|
+
|
|
179
|
+
def is_whitespace(self) -> bool:
|
|
180
|
+
return self._is_whitespace
|
|
181
|
+
|
|
182
|
+
def is_string_lit(self) -> bool:
|
|
183
|
+
return self._is_string_lit
|
|
184
|
+
|
|
185
|
+
# these boolean properties are for untokenizing
|
|
186
|
+
def is_curly_bracket_escaped(self) -> bool:
|
|
187
|
+
"""whether curly bracket should be escaped"""
|
|
188
|
+
return self._is_curly_bracket_escaped
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
@dataclass(frozen=True, slots=True)
|
|
192
|
+
class TokInfo:
|
|
193
|
+
"""Counterpart of `phy` to builtin `tokenize.TokenInfo` type.
|
|
194
|
+
|
|
195
|
+
This struct is intended to be fully compatible with builtin ones. Extended attributes are
|
|
196
|
+
named differently.
|
|
197
|
+
"""
|
|
198
|
+
|
|
199
|
+
# `None` if self is not builtin type; this attribute is only for compatible with builtin one, and it
|
|
200
|
+
# is not used within `phy` project. Always use `std_type` and `ns_type` instead.
|
|
201
|
+
type: Optional[int]
|
|
202
|
+
|
|
203
|
+
string: str
|
|
204
|
+
start: Tuple[int, int] # (lineno, offset)
|
|
205
|
+
end: Tuple[int, int]
|
|
206
|
+
|
|
207
|
+
# Original code of this token.
|
|
208
|
+
# REMINDER: STRING, FSTRING_MIDDLE & TSTRING_MIDDLE may cross lines, then the line attribute of such
|
|
209
|
+
# token will contains all this lines.
|
|
210
|
+
line: str
|
|
211
|
+
|
|
212
|
+
# standard token type or namespaced token type; the two attributes are mutually exclusive.
|
|
213
|
+
std_type: Optional[StdTokType] = None
|
|
214
|
+
ns_type: Optional[NamespacedTokType] = None
|
|
215
|
+
|
|
216
|
+
@property
|
|
217
|
+
def union_type(self) -> TokType:
|
|
218
|
+
"""use this property when common method is called"""
|
|
219
|
+
return self.std_type if self.std_type is not None else self.ns_type
|
|
220
|
+
|
|
221
|
+
def is_type(self, tok_type: TokType) -> bool:
|
|
222
|
+
"""whether this token is of given type"""
|
|
223
|
+
return self.std_type == tok_type or self.ns_type == tok_type
|
|
224
|
+
|
|
225
|
+
def __matmul__(self, tok_type: TokType) -> bool:
|
|
226
|
+
"""overload operator "@" to provide a shorthand for `is_type()`"""
|
|
227
|
+
return self.std_type == tok_type or self.ns_type == tok_type
|
|
228
|
+
|
|
229
|
+
@classmethod
|
|
230
|
+
def new_op(
|
|
231
|
+
cls,
|
|
232
|
+
op_literal: str,
|
|
233
|
+
start: Tuple[int, int],
|
|
234
|
+
end: Tuple[int, int],
|
|
235
|
+
line: str,
|
|
236
|
+
) -> 'TokInfo':
|
|
237
|
+
"""This is a convenient constructor to create new operator token. Create new operator other
|
|
238
|
+
than std operators is a frequent scenario in new syntax.
|
|
239
|
+
"""
|
|
240
|
+
return TokInfo(
|
|
241
|
+
type=builtin_token.OP,
|
|
242
|
+
string=op_literal,
|
|
243
|
+
start=start,
|
|
244
|
+
end=end,
|
|
245
|
+
line=line,
|
|
246
|
+
ns_type=StdTokType.OP,
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
@classmethod
|
|
250
|
+
def new_std(
|
|
251
|
+
cls,
|
|
252
|
+
ns_type: StdTokType,
|
|
253
|
+
string: str,
|
|
254
|
+
start: Tuple[int, int],
|
|
255
|
+
end: Tuple[int, int],
|
|
256
|
+
line: str,
|
|
257
|
+
) -> 'TokInfo':
|
|
258
|
+
"""This is a convenient constructor to create new std token without manually pass corresponding
|
|
259
|
+
builtin token int value.
|
|
260
|
+
"""
|
|
261
|
+
return TokInfo(
|
|
262
|
+
type=getattr(builtin_token, ns_type.name, None),
|
|
263
|
+
string=string,
|
|
264
|
+
start=start,
|
|
265
|
+
end=end,
|
|
266
|
+
line=line,
|
|
267
|
+
ns_type=ns_type,
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
# generator that yields `phy` tokeninfo
|
|
272
|
+
TokGen = Generator[TokInfo, None, None]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{readFileSync as e}from"node:fs";var t=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,31,4,33,15,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,199,7,137,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,55,9,7,0,259,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,481,1,61,4,4,5,9,7,3,6,31,3,149,2,12,2,9,1,3,0,33,1,1357,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,233,0,3,0,8,1,6,0,475,6,110,6,6,9,4759,9,787719,239],n=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,13,65,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,7,25,39,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,5,18,21,18,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,18,0,182,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,24,43,22,0,239,18,16,0,2,12,2,33,125,0,80,921,103,111,6,206,13,310,2314,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,33,24,3,24,45,74,6,0,67,12,65,1,2,0,15,4,10,7386,37,33,96,114,14,913,15,50,7710,3,2,6,2,1,2,296,10,0,30,2,3,0,15,4,8,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,340,2,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,129,15,6,55,50,49,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,208,30,2,2,2,1,2,6,3,4,10,1,225,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4382,2,5773,3,7472,16,621,2467,541,1507,4938,6,8489,39815,11327],r=`·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄ-ؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・`,i=`ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿ-ℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ--ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ`,a={3:`abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile`,5:`class enum extends super const export import`,6:`enum`,strict:`implements interface let package private protected public static yield`,strictBind:`eval arguments`},o=`break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this`,s={5:o,"5module":o+` export import`,6:o+` const class extends export import super`},c=/^in(stanceof)?$/,l=RegExp(`[`+i+`]`),u=RegExp(`[`+i+r+`]`);function d(e,t){for(var n=65536,r=0;r<t.length;r+=2){if(n+=t[r],n>e)return!1;if(n+=t[r+1],n>=e)return!0}return!1}function f(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&l.test(String.fromCharCode(e)):t!==!1&&d(e,n)}function p(e,r){return e<48?e===36:e<58?!0:e<65?!1:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&u.test(String.fromCharCode(e)):r===!1?!1:d(e,n)||d(e,t)}var m=function(e,t){t===void 0&&(t={}),this.label=e,this.keyword=t.keyword,this.beforeExpr=!!t.beforeExpr,this.startsExpr=!!t.startsExpr,this.isLoop=!!t.isLoop,this.isAssign=!!t.isAssign,this.prefix=!!t.prefix,this.postfix=!!t.postfix,this.binop=t.binop||null,this.updateContext=null};function h(e,t){return new m(e,{beforeExpr:!0,binop:t})}var g={beforeExpr:!0},_={startsExpr:!0},ee={};function v(e,t){return t===void 0&&(t={}),t.keyword=e,ee[e]=new m(e,t)}var y={num:new m(`num`,_),regexp:new m(`regexp`,_),string:new m(`string`,_),name:new m(`name`,_),privateId:new m(`privateId`,_),eof:new m(`eof`),bracketL:new m(`[`,{beforeExpr:!0,startsExpr:!0}),bracketR:new m(`]`),braceL:new m(`{`,{beforeExpr:!0,startsExpr:!0}),braceR:new m(`}`),parenL:new m(`(`,{beforeExpr:!0,startsExpr:!0}),parenR:new m(`)`),comma:new m(`,`,g),semi:new m(`;`,g),colon:new m(`:`,g),dot:new m(`.`),question:new m(`?`,g),questionDot:new m(`?.`),arrow:new m(`=>`,g),template:new m(`template`),invalidTemplate:new m(`invalidTemplate`),ellipsis:new m(`...`,g),backQuote:new m("`",_),dollarBraceL:new m("${",{beforeExpr:!0,startsExpr:!0}),eq:new m(`=`,{beforeExpr:!0,isAssign:!0}),assign:new m(`_=`,{beforeExpr:!0,isAssign:!0}),incDec:new m(`++/--`,{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new m(`!/~`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:h(`||`,1),logicalAND:h(`&&`,2),bitwiseOR:h(`|`,3),bitwiseXOR:h(`^`,4),bitwiseAND:h(`&`,5),equality:h(`==/!=/===/!==`,6),relational:h(`</>/<=/>=`,7),bitShift:h(`<</>>/>>>`,8),plusMin:new m(`+/-`,{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:h(`%`,10),star:h(`*`,10),slash:h(`/`,10),starstar:new m(`**`,{beforeExpr:!0}),coalesce:h(`??`,1),_break:v(`break`),_case:v(`case`,g),_catch:v(`catch`),_continue:v(`continue`),_debugger:v(`debugger`),_default:v(`default`,g),_do:v(`do`,{isLoop:!0,beforeExpr:!0}),_else:v(`else`,g),_finally:v(`finally`),_for:v(`for`,{isLoop:!0}),_function:v(`function`,_),_if:v(`if`),_return:v(`return`,g),_switch:v(`switch`),_throw:v(`throw`,g),_try:v(`try`),_var:v(`var`),_const:v(`const`),_while:v(`while`,{isLoop:!0}),_with:v(`with`),_new:v(`new`,{beforeExpr:!0,startsExpr:!0}),_this:v(`this`,_),_super:v(`super`,_),_class:v(`class`,_),_extends:v(`extends`,g),_export:v(`export`),_import:v(`import`,_),_null:v(`null`,_),_true:v(`true`,_),_false:v(`false`,_),_in:v(`in`,{beforeExpr:!0,binop:7}),_instanceof:v(`instanceof`,{beforeExpr:!0,binop:7}),_typeof:v(`typeof`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:v(`void`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:v(`delete`,{beforeExpr:!0,prefix:!0,startsExpr:!0})},b=/\r\n?|\n|\u2028|\u2029/,te=new RegExp(b.source,`g`);function x(e){return e===10||e===13||e===8232||e===8233}function ne(e,t,n){n===void 0&&(n=e.length);for(var r=t;r<n;r++){var i=e.charCodeAt(r);if(x(i))return r<n-1&&i===13&&e.charCodeAt(r+1)===10?r+2:r+1}return-1}var re=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,S=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,ie=Object.prototype,ae=ie.hasOwnProperty,oe=ie.toString,C=Object.hasOwn||(function(e,t){return ae.call(e,t)}),se=Array.isArray||(function(e){return oe.call(e)===`[object Array]`}),ce=Object.create(null);function w(e){return ce[e]||(ce[e]=RegExp(`^(?:`+e.replace(/ /g,`|`)+`)$`))}function T(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}var le=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,E=function(e,t){this.line=e,this.column=t};E.prototype.offset=function(e){return new E(this.line,this.column+e)};var ue=function(e,t,n){this.start=t,this.end=n,e.sourceFile!==null&&(this.source=e.sourceFile)};function de(e,t){for(var n=1,r=0;;){var i=ne(e,r,t);if(i<0)return new E(n,t-r);++n,r=i}}var fe={ecmaVersion:null,sourceType:`script`,strict:!1,onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,startLocation:null,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},pe=!1;function me(e){var t={};for(var n in fe)t[n]=e&&C(e,n)?e[n]:fe[n];if(t.ecmaVersion===`latest`?t.ecmaVersion=1e8:t.ecmaVersion==null?(!pe&&typeof console==`object`&&console.warn&&(pe=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
2
|
+
Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),t.allowReserved??=t.ecmaVersion<5,e&&e.allowHashBang!=null||(t.allowHashBang=t.ecmaVersion>=14),se(t.onToken)){var r=t.onToken;t.onToken=function(e){return r.push(e)}}if(se(t.onComment)&&(t.onComment=he(t,t.onComment)),t.sourceType===`commonjs`&&t.allowAwaitOutsideFunction)throw Error(`Cannot use allowAwaitOutsideFunction with sourceType: commonjs`);return t}function he(e,t){return function(n,r,i,a,o,s){var c={type:n?`Block`:`Line`,value:r,start:i,end:a};e.locations&&(c.loc=new ue(this,o,s)),e.ranges&&(c.range=[i,a]),t.push(c)}}var D=1,O=2,ge=4,_e=8,ve=16,ye=32,k=64,be=128,A=256,j=512,xe=1024,M=D|O|A;function Se(e,t){return O|(e?ge:0)|(t?_e:0)}var N=0,Ce=1,P=2,we=3,Te=4,Ee=5,F=function(e,t,n){this.options=e=me(e),this.sourceFile=e.sourceFile,this.keywords=w(s[e.ecmaVersion>=6?6:e.sourceType===`module`?`5module`:5]);var r=``;e.allowReserved!==!0&&(r=a[e.ecmaVersion>=6?6:e.ecmaVersion===5?5:3],e.sourceType===`module`&&(r+=` await`)),this.reservedWords=w(r);var i=(r?r+` `:``)+a.strict;this.reservedWordsStrict=w(i),this.reservedWordsStrictBind=w(i+` `+a.strictBind),this.input=String(t),this.containsEsc=!1,this.pos=n||0,this.curLine=1,e.startLocation?(this.lineStart=this.pos-e.startLocation.column,this.curLine=e.startLocation.line):n?(this.lineStart=this.input.lastIndexOf(`
|
|
3
|
+
`,n-1)+1,this.options.locations&&(this.curLine=this.input.slice(0,this.lineStart).split(b).length)):this.lineStart=0,this.type=y.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=e.sourceType===`module`,this.strict=this.inModule||e.strict===!0||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&e.allowHashBang&&this.input.slice(0,2)===`#!`&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(this.options.sourceType===`commonjs`?O:D),this.regexpState=null,this.privateNameStack=[]},I={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowReturn:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},allowUsing:{configurable:!0},inClassStaticBlock:{configurable:!0}};F.prototype.parse=function(){var e=this,t=this.options.program||this.startNode();return this.nextToken(),this.catchStackOverflow(function(){return e.parseTopLevel(t)})},I.inFunction.get=function(){return(this.currentVarScope().flags&O)>0},I.inGenerator.get=function(){return(this.currentVarScope().flags&_e)>0},I.inAsync.get=function(){return(this.currentVarScope().flags&ge)>0},I.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(A|j))return!1;if(t&O)return(t&ge)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},I.allowReturn.get=function(){return!!(this.inFunction||this.options.allowReturnOutsideFunction&&this.currentVarScope().flags&D)},I.allowSuper.get=function(){return(this.currentThisScope().flags&k)>0||this.options.allowSuperOutsideMethod},I.allowDirectSuper.get=function(){return(this.currentThisScope().flags&be)>0},I.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},I.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(t&(A|j)||t&O&&!(t&ve))return!0}return!1},I.allowUsing.get=function(){var e=this.currentScope().flags;return!(e&xe||!this.inModule&&e&D)},I.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&A)>0},F.extend=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];for(var n=this,r=0;r<e.length;r++)n=e[r](n);return n},F.parse=function(e,t){return new this(t,e).parse()},F.parseExpressionAt=function(e,t,n){var r=new this(n,e,t);return r.nextToken(),r.parseExpression()},F.tokenizer=function(e,t){return new this(t,e)},Object.defineProperties(F.prototype,I);var L=F.prototype,De=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;L.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){S.lastIndex=e,e+=S.exec(this.input)[0].length;var t=De.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])===`use strict`){S.lastIndex=e+t[0].length;var n=S.exec(this.input),r=n.index+n[0].length,i=this.input.charAt(r);return i===`;`||i===`}`||b.test(n[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(i)||i===`!`&&this.input.charAt(r+1)===`=`||i===`i`&&Oe(this,r))}e+=t[0].length,S.lastIndex=e,e+=S.exec(this.input)[0].length,this.input[e]===`;`&&e++}};function Oe(e,t){for(var n=t+1,r=Math.min(e.input.length,t+11);n<r;){var i=e.fullCharCodeAt(n);if(!p(i,!0))break;n+=i<=65535?1:2}return n===t+2&&e.input.slice(t,n)===`in`||n===t+10&&e.input.slice(t,n)===`instanceof`}L.eat=function(e){return this.type===e&&(this.next(),!0)},L.isContextual=function(e){return this.type===y.name&&this.value===e&&!this.containsEsc},L.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1},L.catchStackOverflow=function(e){try{return e()}catch(e){if(e instanceof Error&&(/\bstack\b.*\b(exceeded|overflow)\b/i.test(e.message)||/\btoo much recursion\b/i.test(e.message)))this.raise(this.start,`Not enough stack space to parse input`);else throw e}},L.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},L.canInsertSemicolon=function(){return this.type===y.eof||this.type===y.braceR||b.test(this.input.slice(this.lastTokEnd,this.start))},L.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},L.semicolon=function(){!this.eat(y.semi)&&!this.insertSemicolon()&&this.unexpected()},L.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},L.expect=function(e){this.eat(e)||this.unexpected()},L.unexpected=function(e){this.raise(e??this.start,`Unexpected token`)};var R=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};L.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,`Comma is not permitted after the rest element`);var n=t?e.parenthesizedAssign:e.parenthesizedBind;n>-1&&this.raiseRecoverable(n,t?`Assigning to rvalue`:`Parenthesized pattern`)}},L.checkExpressionErrors=function(e,t){if(!e)return!1;var n=e.shorthandAssign,r=e.doubleProto;if(!t)return n>=0||r>=0;n>=0&&this.raise(n,`Shorthand property assignments are valid only in destructuring patterns`),r>=0&&this.raiseRecoverable(r,`Redefinition of __proto__ property`)},L.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,`Yield expression cannot be a default value`),this.awaitPos&&this.raise(this.awaitPos,`Await expression cannot be a default value`)},L.isSimpleAssignTarget=function(e){return e.type===`ParenthesizedExpression`?this.isSimpleAssignTarget(e.expression):e.type===`Identifier`||e.type===`MemberExpression`};var z=F.prototype;z.parseTopLevel=function(e){var t=Object.create(null);for(e.body||=[];this.type!==y.eof;){var n=this.parseStatement(null,!0,t);e.body.push(n)}if(this.inModule)for(var r=0,i=Object.keys(this.undefinedExports);r<i.length;r+=1){var a=i[r];this.raiseRecoverable(this.undefinedExports[a].start,`Export '`+a+`' is not defined`)}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType===`commonjs`?`script`:this.options.sourceType,this.finishNode(e,`Program`)};var ke={kind:`loop`},Ae={kind:`switch`};z.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual(`let`))return!1;S.lastIndex=this.pos;var t=S.exec(this.input),n=this.pos+t[0].length,r=this.fullCharCodeAt(n);if(r===91||r===92)return!0;if(e)return!1;if(r===123)return!0;if(f(r)){var i=n;do n+=r<=65535?1:2;while(p(r=this.fullCharCodeAt(n)));if(r===92)return!0;var a=this.input.slice(i,n);if(!c.test(a))return!0}return!1},z.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual(`async`))return!1;S.lastIndex=this.pos;var e=S.exec(this.input),t=this.pos+e[0].length,n;return!b.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)===`function`&&(t+8===this.input.length||!(p(n=this.fullCharCodeAt(t+8))||n===92))},z.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?`await`:`using`))return!1;S.lastIndex=this.pos;var n=S.exec(this.input),r=this.pos+n[0].length;if(b.test(this.input.slice(this.pos,r)))return!1;if(e){var i=r+5,a;if(this.input.slice(r,i)!==`using`||i===this.input.length||p(a=this.fullCharCodeAt(i))||a===92)return!1;S.lastIndex=i;var o=S.exec(this.input);if(r=i+o[0].length,o&&b.test(this.input.slice(i,r)))return!1}var s=this.fullCharCodeAt(r);if(!f(s)&&s!==92)return!1;var l=r;do r+=s<=65535?1:2;while(p(s=this.fullCharCodeAt(r)));if(s===92)return!0;var u=this.input.slice(l,r);if(c.test(u))return!1;if(t&&!e&&u===`of`){S.lastIndex=r;var d=S.exec(this.input);if(r+=d[0].length,this.input.charCodeAt(r)!==61||(s=this.input.charCodeAt(r+1))===61||s===62)return!1}return!0},z.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},z.isUsing=function(e){return this.isUsingKeyword(!1,e)},z.parseStatement=function(e,t,n){var r=this.type,i=this.startNode(),a;switch(this.isLet(e)&&(r=y._var,a=`let`),r){case y._break:case y._continue:return this.parseBreakContinueStatement(i,r.keyword);case y._debugger:return this.parseDebuggerStatement(i);case y._do:return this.parseDoStatement(i);case y._for:return this.parseForStatement(i);case y._function:return e&&(this.strict||e!==`if`&&e!==`label`)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(i,!1,!e);case y._class:return e&&this.unexpected(),this.parseClass(i,!0);case y._if:return this.parseIfStatement(i);case y._return:return this.parseReturnStatement(i);case y._switch:return this.parseSwitchStatement(i);case y._throw:return this.parseThrowStatement(i);case y._try:return this.parseTryStatement(i);case y._const:case y._var:return a||=this.value,e&&a!==`var`&&this.unexpected(),this.parseVarStatement(i,a);case y._while:return this.parseWhileStatement(i);case y._with:return this.parseWithStatement(i);case y.braceL:return this.parseBlock(!0,i);case y.semi:return this.parseEmptyStatement(i);case y._export:case y._import:if(this.options.ecmaVersion>10&&r===y._import){S.lastIndex=this.pos;var o=S.exec(this.input),s=this.pos+o[0].length,c=this.input.charCodeAt(s);if(c===40||c===46)return this.parseExpressionStatement(i,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,`'import' and 'export' may only appear at the top level`),this.inModule||this.raise(this.start,`'import' and 'export' may appear only with 'sourceType: module'`)),r===y._import?this.parseImport(i):this.parseExport(i,n);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(i,!0,!e);var l=this.isAwaitUsing(!1)?`await using`:this.isUsing(!1)?`using`:null;if(l)return this.allowUsing||this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement"),e&&this.raise(this.start,`Using declaration is not allowed in single-statement positions`),l===`await using`&&(this.canAwait||this.raise(this.start,`Await using cannot appear outside of async function`),this.next()),this.next(),this.parseVar(i,!1,l),this.semicolon(),this.finishNode(i,`VariableDeclaration`);var u=this.value,d=this.parseExpression();return r===y.name&&d.type===`Identifier`&&this.eat(y.colon)?this.parseLabeledStatement(i,u,d,e):this.parseExpressionStatement(i,d)}},z.parseBreakContinueStatement=function(e,t){var n=t===`break`;this.next(),this.eat(y.semi)||this.insertSemicolon()?e.label=null:this.type===y.name?(e.label=this.parseIdent(),this.semicolon()):this.unexpected();for(var r=0;r<this.labels.length;++r){var i=this.labels[r];if((e.label==null||i.name===e.label.name)&&(i.kind!=null&&(n||i.kind===`loop`)||e.label&&n))break}return r===this.labels.length&&this.raise(e.start,`Unsyntactic `+t),this.finishNode(e,n?`BreakStatement`:`ContinueStatement`)},z.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,`DebuggerStatement`)},z.parseDoStatement=function(e){return this.next(),this.labels.push(ke),e.body=this.parseStatement(`do`),this.labels.pop(),this.expect(y._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(y.semi):this.semicolon(),this.finishNode(e,`DoWhileStatement`)},z.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual(`await`)?this.lastTokStart:-1;if(this.labels.push(ke),this.enterScope(0),this.expect(y.parenL),this.type===y.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===y._var||this.type===y._const||n){var r=this.startNode(),i=n?`let`:this.value;return this.next(),this.parseVar(r,!0,i),this.finishNode(r,`VariableDeclaration`),this.parseForAfterInit(e,r,t)}var a=this.isContextual(`let`),o=!1,s=this.isUsing(!0)?`using`:this.isAwaitUsing(!0)?`await using`:null;if(s){var c=this.startNode();return this.next(),s===`await using`&&(this.canAwait||this.raise(this.start,`Await using cannot appear outside of async function`),this.next()),this.parseVar(c,!0,s),this.finishNode(c,`VariableDeclaration`),this.parseForAfterInit(e,c,t)}var l=this.containsEsc,u=new R,d=this.start,f=t>-1?this.parseExprSubscripts(u,`await`):this.parseExpression(!0,u);return this.type===y._in||(o=this.options.ecmaVersion>=6&&this.isContextual(`of`))?(t>-1?(this.type===y._in&&this.unexpected(t),e.await=!0):o&&this.options.ecmaVersion>=8&&(f.start===d&&!l&&f.type===`Identifier`&&f.name===`async`?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),a&&o&&this.raise(f.start,`The left-hand side of a for-of loop may not start with 'let'.`),this.toAssignable(f,!1,u),this.checkLValPattern(f),this.parseForIn(e,f)):(this.checkExpressionErrors(u,!0),t>-1&&this.unexpected(t),this.parseFor(e,f))},z.parseForAfterInit=function(e,t,n){return(this.type===y._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))&&t.declarations.length===1?(this.type===y._in?(t.kind!==`using`&&t.kind!==`await using`||t.declarations[0].init||this.raise(this.start,`Using declaration is not allowed in for-in loops`),this.options.ecmaVersion>=9&&n>-1&&this.unexpected(n)):this.options.ecmaVersion>=9&&(e.await=n>-1),this.parseForIn(e,t)):(n>-1&&this.unexpected(n),this.parseFor(e,t))},z.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,B|(n?0:Me),!1,t)},z.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement(`if`),e.alternate=this.eat(y._else)?this.parseStatement(`if`):null,this.finishNode(e,`IfStatement`)},z.parseReturnStatement=function(e){return this.allowReturn||this.raise(this.start,`'return' outside of function`),this.next(),this.eat(y.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,`ReturnStatement`)},z.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(y.braceL),this.labels.push(Ae),this.enterScope(xe);for(var t,n=!1;this.type!==y.braceR;)if(this.type===y._case||this.type===y._default){var r=this.type===y._case;t&&this.finishNode(t,`SwitchCase`),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),r?t.test=this.parseExpression():(n&&this.raiseRecoverable(this.lastTokStart,`Multiple default clauses`),n=!0,t.test=null),this.expect(y.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,`SwitchCase`),this.next(),this.labels.pop(),this.finishNode(e,`SwitchStatement`)},z.parseThrowStatement=function(e){return this.next(),b.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,`Illegal newline after throw`),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,`ThrowStatement`)};var je=[];z.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type===`Identifier`;return this.enterScope(t?ye:0),this.checkLValPattern(e,t?Te:P),this.expect(y.parenR),e},z.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===y._catch){var t=this.startNode();this.next(),this.eat(y.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,`CatchClause`)}return e.finalizer=this.eat(y._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,`Missing catch or finally clause`),this.finishNode(e,`TryStatement`)},z.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,`VariableDeclaration`)},z.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(ke),e.body=this.parseStatement(`while`),this.labels.pop(),this.finishNode(e,`WhileStatement`)},z.parseWithStatement=function(e){return this.strict&&this.raise(this.start,`'with' in strict mode`),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement(`with`),this.finishNode(e,`WithStatement`)},z.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,`EmptyStatement`)},z.parseLabeledStatement=function(e,t,n,r){for(var i=0,a=this.labels;i<a.length;i+=1)a[i].name===t&&this.raise(n.start,`Label '`+t+`' is already declared`);for(var o=this.type.isLoop?`loop`:this.type===y._switch?`switch`:null,s=this.labels.length-1;s>=0;s--){var c=this.labels[s];if(c.statementStart===e.start)c.statementStart=this.start,c.kind=o;else break}return this.labels.push({name:t,kind:o,statementStart:this.start}),e.body=this.parseStatement(r?r.indexOf(`label`)===-1?r+`label`:r:`label`),this.labels.pop(),e.label=n,this.finishNode(e,`LabeledStatement`)},z.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,`ExpressionStatement`)},z.parseBlock=function(e,t,n){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(y.braceL),e&&this.enterScope(0);this.type!==y.braceR;){var r=this.parseStatement(null);t.body.push(r)}return n&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,`BlockStatement`)},z.parseFor=function(e,t){return e.init=t,this.expect(y.semi),e.test=this.type===y.semi?null:this.parseExpression(),this.expect(y.semi),e.update=this.type===y.parenR?null:this.parseExpression(),this.expect(y.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,`ForStatement`)},z.parseForIn=function(e,t){var n=this.type===y._in;return this.next(),t.type===`VariableDeclaration`&&t.declarations[0].init!=null&&(!n||this.options.ecmaVersion<8||this.strict||t.kind!==`var`||t.declarations[0].id.type!==`Identifier`)&&this.raise(t.start,(n?`for-in`:`for-of`)+` loop variable declaration may not have an initializer`),e.left=t,e.right=n?this.parseExpression():this.parseMaybeAssign(),this.expect(y.parenR),e.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(e,n?`ForInStatement`:`ForOfStatement`)},z.parseVar=function(e,t,n,r){for(e.declarations=[],e.kind=n;;){var i=this.startNode();if(this.parseVarId(i,n),this.eat(y.eq)?i.init=this.parseMaybeAssign(t):!r&&n===`const`&&!(this.type===y._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))?this.unexpected():!r&&(n===`using`||n===`await using`)&&this.options.ecmaVersion>=17&&this.type!==y._in&&!this.isContextual(`of`)?this.raise(this.lastTokEnd,`Missing initializer in `+n+` declaration`):!r&&i.id.type!==`Identifier`&&(!t||this.type!==y._in&&!this.isContextual(`of`))?this.raise(this.lastTokEnd,`Complex binding patterns require an initialization value`):i.init=null,e.declarations.push(this.finishNode(i,`VariableDeclarator`)),!this.eat(y.comma))break}return e},z.parseVarId=function(e,t){e.id=t===`using`||t===`await using`?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t===`var`?Ce:P,!1)};var B=1,Me=2,Ne=4;z.parseFunction=function(e,t,n,r,i){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===y.star&&t&Me&&this.unexpected(),e.generator=this.eat(y.star)),this.options.ecmaVersion>=8&&(e.async=!!r),t&B&&(e.id=t&Ne&&this.type!==y.name?null:this.parseIdent(),e.id&&!(t&Me)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?Ce:P:we));var a=this.yieldPos,o=this.awaitPos,s=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Se(e.async,e.generator)),t&B||(e.id=this.type===y.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n,!1,i),this.yieldPos=a,this.awaitPos=o,this.awaitIdentPos=s,this.finishNode(e,t&B?`FunctionDeclaration`:`FunctionExpression`)},z.parseFunctionParams=function(e){this.expect(y.parenL),e.params=this.parseBindingList(y.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},z.parseClass=function(e,t){this.next();var n=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var r=this.enterClassBody(),i=this.startNode(),a=!1;for(i.body=[],this.expect(y.braceL);this.type!==y.braceR;){var o=this.parseClassElement(e.superClass!==null);o&&(i.body.push(o),o.type===`MethodDefinition`&&o.kind===`constructor`?(a&&this.raiseRecoverable(o.start,`Duplicate constructor in the same class`),a=!0):o.key&&o.key.type===`PrivateIdentifier`&&Pe(r,o)&&this.raiseRecoverable(o.key.start,`Identifier '#`+o.key.name+`' has already been declared`))}return this.strict=n,this.next(),e.body=this.finishNode(i,`ClassBody`),this.exitClassBody(),this.finishNode(e,t?`ClassDeclaration`:`ClassExpression`)},z.parseClassElement=function(e){if(this.eat(y.semi))return null;var t=this.options.ecmaVersion,n=this.startNode(),r=``,i=!1,a=!1,o=`method`,s=!1;if(this.eatContextual(`static`)){if(t>=13&&this.eat(y.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===y.star?s=!0:r=`static`}if(n.static=s,!r&&t>=8&&this.eatContextual(`async`)&&((this.isClassElementNameStart()||this.type===y.star)&&!this.canInsertSemicolon()?a=!0:r=`async`),!r&&(t>=9||!a)&&this.eat(y.star)&&(i=!0),!r&&!a&&!i){var c=this.value;(this.eatContextual(`get`)||this.eatContextual(`set`))&&(this.isClassElementNameStart()?o=c:r=c)}if(r?(n.computed=!1,n.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),n.key.name=r,this.finishNode(n.key,`Identifier`)):this.parseClassElementName(n),t<13||this.type===y.parenL||o!==`method`||i||a){var l=!n.static&&V(n,`constructor`),u=l&&e;l&&o!==`method`&&this.raise(n.key.start,`Constructor can't have get/set modifier`),n.kind=l?`constructor`:o,this.parseClassMethod(n,i,a,u)}else this.parseClassField(n);return n},z.isClassElementNameStart=function(){return this.type===y.name||this.type===y.privateId||this.type===y.num||this.type===y.string||this.type===y.bracketL||this.type.keyword},z.parseClassElementName=function(e){this.type===y.privateId?(this.value===`constructor`&&this.raise(this.start,`Classes can't have an element named '#constructor'`),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)},z.parseClassMethod=function(e,t,n,r){var i=e.key;e.kind===`constructor`?(t&&this.raise(i.start,`Constructor can't be a generator`),n&&this.raise(i.start,`Constructor can't be an async method`)):e.static&&V(e,`prototype`)&&this.raise(i.start,`Classes may not have a static property named prototype`);var a=e.value=this.parseMethod(t,n,r);return e.kind===`get`&&a.params.length!==0&&this.raiseRecoverable(a.start,`getter should have no params`),e.kind===`set`&&a.params.length!==1&&this.raiseRecoverable(a.start,`setter should have exactly one param`),e.kind===`set`&&a.params[0].type===`RestElement`&&this.raiseRecoverable(a.params[0].start,`Setter cannot use rest params`),this.finishNode(e,`MethodDefinition`)},z.parseClassField=function(e){return V(e,`constructor`)?this.raise(e.key.start,`Classes can't have a field named 'constructor'`):e.static&&V(e,`prototype`)&&this.raise(e.key.start,`Classes can't have a static field named 'prototype'`),this.eat(y.eq)?(this.enterScope(j|k),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,`PropertyDefinition`)},z.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(A|k);this.type!==y.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,`StaticBlock`)},z.parseClassId=function(e,t){this.type===y.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,P,!1)):(t===!0&&this.unexpected(),e.id=null)},z.parseClassSuper=function(e){e.superClass=this.eat(y._extends)?this.parseExprSubscripts(null,!1):null},z.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},z.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,n=e.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,i=r===0?null:this.privateNameStack[r-1],a=0;a<n.length;++a){var o=n[a];C(t,o.name)||(i?i.used.push(o):this.raiseRecoverable(o.start,`Private field '#`+o.name+`' must be declared in an enclosing class`))}};function Pe(e,t){var n=t.key.name,r=e[n],i=`true`;return t.type===`MethodDefinition`&&(t.kind===`get`||t.kind===`set`)&&(i=(t.static?`s`:`i`)+t.kind),r===`iget`&&i===`iset`||r===`iset`&&i===`iget`||r===`sget`&&i===`sset`||r===`sset`&&i===`sget`?(e[n]=`true`,!1):r?!0:(e[n]=i,!1)}function V(e,t){var n=e.computed,r=e.key;return!n&&(r.type===`Identifier`&&r.name===t||r.type===`Literal`&&r.value===t)}z.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual(`as`)?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual(`from`),this.type!==y.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ExportAllDeclaration`)},z.parseExport=function(e,t){if(this.next(),this.eat(y.star))return this.parseExportAllDeclaration(e,t);if(this.eat(y._default))return this.checkExport(t,`default`,this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,`ExportDefaultDeclaration`);if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),e.declaration.type===`VariableDeclaration`?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual(`from`))this.type!==y.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var n=0,r=e.specifiers;n<r.length;n+=1){var i=r[n];this.checkUnreserved(i.local),this.checkLocalExport(i.local),i.local.type===`Literal`&&this.raise(i.local.start,"A string literal cannot be used as an exported binding without `from`.")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,`ExportNamedDeclaration`)},z.parseExportDeclaration=function(e){return this.parseStatement(null)},z.parseExportDefaultDeclaration=function(){var e;if(this.type===y._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,B|Ne,!1,e)}if(this.type===y._class){var n=this.startNode();return this.parseClass(n,`nullableID`)}var r=this.parseMaybeAssign();return this.semicolon(),r},z.checkExport=function(e,t,n){e&&(typeof t!=`string`&&(t=t.type===`Identifier`?t.name:t.value),C(e,t)&&this.raiseRecoverable(n,`Duplicate export '`+t+`'`),e[t]=!0)},z.checkPatternExport=function(e,t){var n=t.type;if(n===`Identifier`)this.checkExport(e,t,t.start);else if(n===`ObjectPattern`)for(var r=0,i=t.properties;r<i.length;r+=1){var a=i[r];this.checkPatternExport(e,a)}else if(n===`ArrayPattern`)for(var o=0,s=t.elements;o<s.length;o+=1){var c=s[o];c&&this.checkPatternExport(e,c)}else n===`Property`?this.checkPatternExport(e,t.value):n===`AssignmentPattern`?this.checkPatternExport(e,t.left):n===`RestElement`&&this.checkPatternExport(e,t.argument)},z.checkVariableExport=function(e,t){if(e)for(var n=0,r=t;n<r.length;n+=1){var i=r[n];this.checkPatternExport(e,i.id)}},z.shouldParseExportStatement=function(){return this.type.keyword===`var`||this.type.keyword===`const`||this.type.keyword===`class`||this.type.keyword===`function`||this.isLet()||this.isAsyncFunction()},z.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual(`as`)?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,`ExportSpecifier`)},z.parseExportSpecifiers=function(e){var t=[],n=!0;for(this.expect(y.braceL);!this.eat(y.braceR);){if(n)n=!1;else if(this.expect(y.comma),this.afterTrailingComma(y.braceR))break;t.push(this.parseExportSpecifier(e))}return t},z.parseImport=function(e){return this.next(),this.type===y.string?(e.specifiers=je,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual(`from`),e.source=this.type===y.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,`ImportDeclaration`)},z.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual(`as`)?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,P),this.finishNode(e,`ImportSpecifier`)},z.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,P),this.finishNode(e,`ImportDefaultSpecifier`)},z.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual(`as`),e.local=this.parseIdent(),this.checkLValSimple(e.local,P),this.finishNode(e,`ImportNamespaceSpecifier`)},z.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===y.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(y.comma)))return e;if(this.type===y.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(y.braceL);!this.eat(y.braceR);){if(t)t=!1;else if(this.expect(y.comma),this.afterTrailingComma(y.braceR))break;e.push(this.parseImportSpecifier())}return e},z.parseWithClause=function(){var e=[];if(!this.eat(y._with))return e;this.expect(y.braceL);for(var t={},n=!0;!this.eat(y.braceR);){if(n)n=!1;else if(this.expect(y.comma),this.afterTrailingComma(y.braceR))break;var r=this.parseImportAttribute(),i=r.key.type===`Identifier`?r.key.name:r.key.value;C(t,i)&&this.raiseRecoverable(r.key.start,`Duplicate attribute key '`+i+`'`),t[i]=!0,e.push(r)}return e},z.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===y.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`),this.expect(y.colon),this.type!==y.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,`ImportAttribute`)},z.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===y.string){var e=this.parseLiteral(this.value);return le.test(e.value)&&this.raise(e.start,`An export name cannot include a lone surrogate.`),e}return this.parseIdent(!0)},z.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)},z.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&e.type===`ExpressionStatement`&&e.expression.type===`Literal`&&typeof e.expression.value==`string`&&(this.input[e.start]===`"`||this.input[e.start]===`'`)};var H=F.prototype;H.toAssignable=function(e,t,n){if(this.options.ecmaVersion>=6&&e)switch(e.type){case`Identifier`:this.inAsync&&e.name===`await`&&this.raise(e.start,`Cannot use 'await' as identifier inside an async function`);break;case`ObjectPattern`:case`ArrayPattern`:case`AssignmentPattern`:case`RestElement`:break;case`ObjectExpression`:e.type=`ObjectPattern`,n&&this.checkPatternErrors(n,!0);for(var r=0,i=e.properties;r<i.length;r+=1){var a=i[r];this.toAssignable(a,t),a.type===`RestElement`&&(a.argument.type===`ArrayPattern`||a.argument.type===`ObjectPattern`)&&this.raise(a.argument.start,`Unexpected token`)}break;case`Property`:e.kind!==`init`&&this.raise(e.key.start,`Object pattern can't contain getter or setter`),this.toAssignable(e.value,t);break;case`ArrayExpression`:e.type=`ArrayPattern`,n&&this.checkPatternErrors(n,!0),this.toAssignableList(e.elements,t);break;case`SpreadElement`:e.type=`RestElement`,this.toAssignable(e.argument,t),e.argument.type===`AssignmentPattern`&&this.raise(e.argument.start,`Rest elements cannot have a default value`);break;case`AssignmentExpression`:e.operator!==`=`&&this.raise(e.left.end,`Only '=' operator can be used for specifying default value.`),e.type=`AssignmentPattern`,delete e.operator,this.toAssignable(e.left,t);break;case`ParenthesizedExpression`:this.toAssignable(e.expression,t,n);break;case`ChainExpression`:this.raiseRecoverable(e.start,`Optional chaining cannot appear in left-hand side`);break;case`MemberExpression`:if(!t)break;default:this.raise(e.start,`Assigning to rvalue`)}else n&&this.checkPatternErrors(n,!0);return e},H.toAssignableList=function(e,t){for(var n=e.length,r=0;r<n;r++){var i=e[r];i&&this.toAssignable(i,t)}if(n){var a=e[n-1];this.options.ecmaVersion===6&&t&&a&&a.type===`RestElement`&&a.argument.type!==`Identifier`&&this.unexpected(a.argument.start)}return e},H.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,`SpreadElement`)},H.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==y.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,`RestElement`)},H.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case y.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(y.bracketR,!0,!0),this.finishNode(e,`ArrayPattern`);case y.braceL:return this.parseObj(!0)}return this.parseIdent()},H.parseBindingList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);)if(a?a=!1:this.expect(y.comma),t&&this.type===y.comma)i.push(null);else if(n&&this.afterTrailingComma(e))break;else if(this.type===y.ellipsis){var o=this.parseRestBinding();this.parseBindingListItem(o),i.push(o),this.type===y.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`),this.expect(e);break}else i.push(this.parseAssignableListItem(r));return i},H.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t},H.parseBindingListItem=function(e){return e},H.parseMaybeDefault=function(e,t,n){if(n||=this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(y.eq))return n;var r=this.startNodeAt(e,t);return r.left=n,r.right=this.parseMaybeAssign(),this.finishNode(r,`AssignmentPattern`)},H.checkLValSimple=function(e,t,n){t===void 0&&(t=N);var r=t!==N;switch(e.type){case`Identifier`:this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(r?`Binding `:`Assigning to `)+e.name+` in strict mode`),r&&(t===P&&e.name===`let`&&this.raiseRecoverable(e.start,`let is disallowed as a lexically bound name`),n&&(C(n,e.name)&&this.raiseRecoverable(e.start,`Argument name clash`),n[e.name]=!0),t!==Ee&&this.declareName(e.name,t,e.start));break;case`ChainExpression`:this.raiseRecoverable(e.start,`Optional chaining cannot appear in left-hand side`);break;case`MemberExpression`:r&&this.raiseRecoverable(e.start,`Binding member expression`);break;case`ParenthesizedExpression`:return r&&this.raiseRecoverable(e.start,`Binding parenthesized expression`),this.checkLValSimple(e.expression,t,n);default:this.raise(e.start,(r?`Binding`:`Assigning to`)+` rvalue`)}},H.checkLValPattern=function(e,t,n){switch(t===void 0&&(t=N),e.type){case`ObjectPattern`:for(var r=0,i=e.properties;r<i.length;r+=1){var a=i[r];this.checkLValInnerPattern(a,t,n)}break;case`ArrayPattern`:for(var o=0,s=e.elements;o<s.length;o+=1){var c=s[o];c&&this.checkLValInnerPattern(c,t,n)}break;default:this.checkLValSimple(e,t,n)}},H.checkLValInnerPattern=function(e,t,n){switch(t===void 0&&(t=N),e.type){case`Property`:this.checkLValInnerPattern(e.value,t,n);break;case`AssignmentPattern`:this.checkLValPattern(e.left,t,n);break;case`RestElement`:this.checkLValPattern(e.argument,t,n);break;default:this.checkLValPattern(e,t,n)}};var U=function(e,t,n,r,i){this.token=e,this.isExpr=!!t,this.preserveSpace=!!n,this.override=r,this.generator=!!i},W={b_stat:new U(`{`,!1),b_expr:new U(`{`,!0),b_tmpl:new U("${",!1),p_stat:new U(`(`,!1),p_expr:new U(`(`,!0),q_tmpl:new U("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new U(`function`,!1),f_expr:new U(`function`,!0),f_expr_gen:new U(`function`,!0,!1,null,!0),f_gen:new U(`function`,!1,!1,null,!0)},G=F.prototype;G.initialContext=function(){return[W.b_stat]},G.curContext=function(){return this.context[this.context.length-1]},G.braceIsBlock=function(e){var t=this.curContext();return t===W.f_expr||t===W.f_stat?!0:e===y.colon&&(t===W.b_stat||t===W.b_expr)?!t.isExpr:e===y._return||e===y.name&&this.exprAllowed?b.test(this.input.slice(this.lastTokEnd,this.start)):e===y._else||e===y.semi||e===y.eof||e===y.parenR||e===y.arrow?!0:e===y.braceL?t===W.b_stat:e===y._var||e===y._const||e===y.name?!1:!this.exprAllowed},G.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if(t.token===`function`)return t.generator}return!1},G.updateContext=function(e){var t,n=this.type;n.keyword&&e===y.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr},G.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},y.parenR.updateContext=y.braceR.updateContext=function(){if(this.context.length===1)this.exprAllowed=!0;else{var e=this.context.pop();e===W.b_stat&&this.curContext().token===`function`&&(e=this.context.pop()),this.exprAllowed=!e.isExpr}},y.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?W.b_stat:W.b_expr),this.exprAllowed=!0},y.dollarBraceL.updateContext=function(){this.context.push(W.b_tmpl),this.exprAllowed=!0},y.parenL.updateContext=function(e){var t=e===y._if||e===y._for||e===y._with||e===y._while;this.context.push(t?W.p_stat:W.p_expr),this.exprAllowed=!0},y.incDec.updateContext=function(){},y._function.updateContext=y._class.updateContext=function(e){e.beforeExpr&&e!==y._else&&(e!==y.semi||this.curContext()===W.p_stat)&&!(e===y._return&&b.test(this.input.slice(this.lastTokEnd,this.start)))&&(e!==y.colon&&e!==y.braceL||this.curContext()!==W.b_stat)?this.context.push(W.f_expr):this.context.push(W.f_stat),this.exprAllowed=!1},y.colon.updateContext=function(){this.curContext().token===`function`&&this.context.pop(),this.exprAllowed=!0},y.backQuote.updateContext=function(){this.curContext()===W.q_tmpl?this.context.pop():this.context.push(W.q_tmpl),this.exprAllowed=!1},y.star.updateContext=function(e){if(e===y._function){var t=this.context.length-1;this.context[t]===W.f_expr?this.context[t]=W.f_expr_gen:this.context[t]=W.f_gen}this.exprAllowed=!0},y.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==y.dot&&(this.value===`of`&&!this.exprAllowed||this.value===`yield`&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var K=F.prototype;K.checkPropClash=function(e,t,n){if(!(this.options.ecmaVersion>=9&&e.type===`SpreadElement`)&&!(this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var r=e.key,i;switch(r.type){case`Identifier`:i=r.name;break;case`Literal`:i=String(r.value);break;default:return}var a=e.kind;if(this.options.ecmaVersion>=6)i===`__proto__`&&a===`init`&&(t.proto&&(n?n.doubleProto<0&&(n.doubleProto=r.start):this.raiseRecoverable(r.start,`Redefinition of __proto__ property`)),t.proto=!0);else{i=`$`+i;var o=t[i];o?(a===`init`?this.strict&&o.init||o.get||o.set:o.init||o[a])&&this.raiseRecoverable(r.start,`Redefinition of property`):o=t[i]={init:!1,get:!1,set:!1},o[a]=!0}}},K.parseExpression=function(e,t){var n=this;return this.catchStackOverflow(function(){var r=n.start,i=n.startLoc,a=n.parseMaybeAssign(e,t);if(n.type===y.comma){var o=n.startNodeAt(r,i);for(o.expressions=[a];n.eat(y.comma);)o.expressions.push(n.parseMaybeAssign(e,t));return n.finishNode(o,`SequenceExpression`)}return a})},K.parseMaybeAssign=function(e,t,n){if(this.isContextual(`yield`)){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var r=!1,i=-1,a=-1,o=-1;t?(i=t.parenthesizedAssign,a=t.trailingComma,o=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new R,r=!0);var s=this.start,c=this.startLoc;(this.type===y.parenL||this.type===y.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e===`await`);var l=this.parseMaybeConditional(e,t);if(n&&(l=n.call(this,l,s,c)),this.type.isAssign){var u=this.startNodeAt(s,c);return u.operator=this.value,this.type===y.eq&&(l=this.toAssignable(l,!1,t)),r||(t.parenthesizedAssign=t.trailingComma=-1,t.shorthandAssign>=l.start&&(t.shorthandAssign=-1),t.doubleProto>=l.start&&(t.doubleProto=-1)),this.type===y.eq?this.checkLValPattern(l):this.checkLValSimple(l),u.left=l,this.next(),u.right=this.parseMaybeAssign(e),o>-1&&(t.doubleProto=o),this.finishNode(u,`AssignmentExpression`)}return r&&this.checkExpressionErrors(t,!0),i>-1&&(t.parenthesizedAssign=i),a>-1&&(t.trailingComma=a),l},K.parseMaybeConditional=function(e,t){var n=this.start,r=this.startLoc,i=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return i;if((i.type!==`ArrowFunctionExpression`||i.start!==n)&&this.eat(y.question)){var a=this.startNodeAt(n,r);return a.test=i,a.consequent=this.parseMaybeAssign(),this.expect(y.colon),a.alternate=this.parseMaybeAssign(e),this.finishNode(a,`ConditionalExpression`)}return i},K.parseExprOps=function(e,t){var n=this.start,r=this.startLoc,i=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||i.start===n&&i.type===`ArrowFunctionExpression`?i:this.parseExprOp(i,n,r,-1,e)},K.parseExprOp=function(e,t,n,r,i){var a=this.type.binop;if(a!=null&&(!i||this.type!==y._in)&&a>r){var o=this.type===y.logicalOR||this.type===y.logicalAND,s=this.type===y.coalesce;s&&(a=y.logicalAND.binop);var c=this.value;this.next();var l=this.start,u=this.startLoc,d=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,i),l,u,a,i),f=this.buildBinary(t,n,e,d,c,o||s);return(o&&this.type===y.coalesce||s&&(this.type===y.logicalOR||this.type===y.logicalAND))&&this.raiseRecoverable(this.start,`Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses`),this.parseExprOp(f,t,n,r,i)}return e},K.buildBinary=function(e,t,n,r,i,a){r.type===`PrivateIdentifier`&&this.raise(r.start,`Private identifier can only be left side of binary expression`);var o=this.startNodeAt(e,t);return o.left=n,o.operator=i,o.right=r,this.finishNode(o,a?`LogicalExpression`:`BinaryExpression`)},K.parseMaybeUnary=function(e,t,n,r){var i=this.start,a=this.startLoc,o;if(this.isContextual(`await`)&&this.canAwait)o=this.parseAwait(r),t=!0;else if(this.type.prefix){var s=this.startNode(),c=this.type===y.incDec;s.operator=this.value,s.prefix=!0,this.next(),s.argument=this.parseMaybeUnary(null,!0,c,r),this.checkExpressionErrors(e,!0),c?this.checkLValSimple(s.argument):this.strict&&s.operator===`delete`&&Fe(s.argument)?this.raiseRecoverable(s.start,`Deleting local variable in strict mode`):s.operator===`delete`&&Ie(s.argument)?this.raiseRecoverable(s.start,`Private fields can not be deleted`):t=!0,o=this.finishNode(s,c?`UpdateExpression`:`UnaryExpression`)}else if(!t&&this.type===y.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),o=this.parsePrivateIdent(),this.type!==y._in&&this.unexpected();else{if(o=this.parseExprSubscripts(e,r),this.checkExpressionErrors(e))return o;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(i,a);l.operator=this.value,l.prefix=!1,l.argument=o,this.checkLValSimple(o),this.next(),o=this.finishNode(l,`UpdateExpression`)}}if(!n&&(o.type!==`ArrowFunctionExpression`||o.start!==i)&&this.eat(y.starstar)){if(t)this.unexpected(this.lastTokStart);else return this.buildBinary(i,a,o,this.parseMaybeUnary(null,!1,!1,r),`**`,!1)}else return o};function Fe(e){return e.type===`Identifier`||e.type===`ParenthesizedExpression`&&Fe(e.expression)}function Ie(e){return e.type===`MemberExpression`&&e.property.type===`PrivateIdentifier`||e.type===`ChainExpression`&&Ie(e.expression)||e.type===`ParenthesizedExpression`&&Ie(e.expression)}K.parseExprSubscripts=function(e,t){var n=this.start,r=this.startLoc,i=-1,a=-1;e&&(i=e.doubleProto,a=e.shorthandAssign,e.doubleProto=e.shorthandAssign=-1);var o=this.parseExprAtom(e,t);if(o.type===`ArrowFunctionExpression`&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==`)`)return o;var s=this.parseSubscripts(o,n,r,!1,t);return e&&(s.end>o.end&&(this.checkExpressionErrors(e,!0),e.parenthesizedAssign>=s.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=s.start&&(e.parenthesizedBind=-1),e.trailingComma>=s.start&&(e.trailingComma=-1)),i>-1&&(e.doubleProto=i),a>-1&&(e.shorthandAssign=a)),s},K.parseSubscripts=function(e,t,n,r,i){for(var a=this.options.ecmaVersion>=8&&e.type===`Identifier`&&e.name===`async`&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start===5&&this.potentialArrowAt===e.start,o=!1;;){var s=this.parseSubscript(e,t,n,r,a,o,i);if(s.optional&&(o=!0),s.end===e.end||s.type===`ArrowFunctionExpression`){if(o){var c=this.startNodeAt(t,n);c.expression=s,s=this.finishNode(c,`ChainExpression`)}return s}e=s,a=!1}},K.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(y.arrow)},K.parseSubscriptAsyncArrow=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,r)},K.parseSubscript=function(e,t,n,r,i,a,o){var s=this.options.ecmaVersion>=11,c=s&&this.eat(y.questionDot);r&&c&&this.raise(this.lastTokStart,`Optional chaining cannot appear in the callee of new expressions`);var l=this.eat(y.bracketL);if(l||c&&this.type!==y.parenL&&this.type!==y.backQuote||this.eat(y.dot)){var u=this.startNodeAt(t,n);u.object=e,l?(u.property=this.parseExpression(),this.expect(y.bracketR)):u.property=this.type===y.privateId&&e.type!==`Super`?this.parsePrivateIdent():this.parseIdent(this.options.allowReserved!==`never`),u.computed=!!l,s&&(u.optional=c),e=this.finishNode(u,`MemberExpression`)}else if(!r&&this.eat(y.parenL)){var d=new R,f=this.yieldPos,p=this.awaitPos,m=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var h=this.parseExprList(y.parenR,this.options.ecmaVersion>=8,!1,d);if(i&&!c&&this.shouldParseAsyncArrow())return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,`Cannot use 'await' as identifier inside an async function`),this.yieldPos=f,this.awaitPos=p,this.awaitIdentPos=m,this.parseSubscriptAsyncArrow(t,n,h,o);this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=p||this.awaitPos,this.awaitIdentPos=m||this.awaitIdentPos;var g=this.startNodeAt(t,n);g.callee=e,g.arguments=h,s&&(g.optional=c),e=this.finishNode(g,`CallExpression`)}else if(this.type===y.backQuote){(c||a)&&this.raise(this.start,`Optional chaining cannot appear in the tag of tagged template expressions`);var _=this.startNodeAt(t,n);_.tag=e,_.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(_,`TaggedTemplateExpression`)}return e},K.parseExprAtom=function(e,t,n){this.type===y.slash&&this.readRegexp();var r,i=this.potentialArrowAt===this.start;switch(this.type){case y._super:return this.allowSuper||this.raise(this.start,`'super' keyword outside a method`),r=this.startNode(),this.next(),this.type===y.parenL&&!this.allowDirectSuper&&this.raise(r.start,`super() call outside constructor of a subclass`),this.type!==y.dot&&this.type!==y.bracketL&&this.type!==y.parenL&&this.unexpected(),this.finishNode(r,`Super`);case y._this:return r=this.startNode(),this.next(),this.finishNode(r,`ThisExpression`);case y.name:var a=this.start,o=this.startLoc,s=this.containsEsc,c=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!s&&c.name===`async`&&!this.canInsertSemicolon()&&this.eat(y._function))return this.overrideContext(W.f_expr),this.parseFunction(this.startNodeAt(a,o),0,!1,!0,t);if(i&&!this.canInsertSemicolon()){if(this.eat(y.arrow))return this.parseArrowExpression(this.startNodeAt(a,o),[c],!1,t);if(this.options.ecmaVersion>=8&&c.name===`async`&&this.type===y.name&&!s&&(!this.potentialArrowInForAwait||this.value!==`of`||this.containsEsc))return c=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(y.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(a,o),[c],!0,t)}return c;case y.regexp:var l=this.value;return r=this.parseLiteral(l.value),r.regex={pattern:l.pattern,flags:l.flags},r;case y.num:case y.string:return this.parseLiteral(this.value);case y._null:case y._true:case y._false:return r=this.startNode(),r.value=this.type===y._null?null:this.type===y._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,`Literal`);case y.parenL:var u=this.start,d=this.parseParenAndDistinguishExpression(i,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(d)&&(e.parenthesizedAssign=u),e.parenthesizedBind<0&&(e.parenthesizedBind=u)),d;case y.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(y.bracketR,!0,!0,e),this.finishNode(r,`ArrayExpression`);case y.braceL:return this.overrideContext(W.b_expr),this.parseObj(!1,e);case y._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case y._class:return this.parseClass(this.startNode(),!1);case y._new:return this.parseNew();case y.backQuote:return this.parseTemplate();case y._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}},K.parseExprAtomDefault=function(){this.unexpected()},K.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword import`),this.next(),this.type===y.parenL&&!e)return this.parseDynamicImport(t);if(this.type===y.dot){var n=this.startNodeAt(t.start,t.loc&&t.loc.start);return n.name=`import`,t.meta=this.finishNode(n,`Identifier`),this.parseImportMeta(t)}this.unexpected()},K.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(y.parenR)?e.options=null:(this.expect(y.comma),this.afterTrailingComma(y.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(y.parenR)||(this.expect(y.comma),this.afterTrailingComma(y.parenR)||this.unexpected())));else if(!this.eat(y.parenR)){var t=this.start;this.eat(y.comma)&&this.eat(y.parenR)?this.raiseRecoverable(t,`Trailing comma is not allowed in import()`):this.unexpected(t)}return this.finishNode(e,`ImportExpression`)},K.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!==`meta`&&this.raiseRecoverable(e.property.start,`The only valid meta property for import is 'import.meta'`),t&&this.raiseRecoverable(e.start,`'import.meta' must not contain escaped characters`),this.options.sourceType!==`module`&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,`Cannot use 'import.meta' outside a module`),this.finishNode(e,`MetaProperty`)},K.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),t.raw.charCodeAt(t.raw.length-1)===110&&(t.bigint=t.value==null?t.raw.slice(0,-1).replace(/_/g,``):t.value.toString()),this.next(),this.finishNode(t,`Literal`)},K.parseParenExpression=function(){this.expect(y.parenL);var e=this.parseExpression();return this.expect(y.parenR),e},K.shouldParseArrow=function(e){return!this.canInsertSemicolon()},K.parseParenAndDistinguishExpression=function(e,t){var n=this.start,r=this.startLoc,i,a=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var o=this.start,s=this.startLoc,c=[],l=!0,u=!1,d=new R,f=this.yieldPos,p=this.awaitPos,m;for(this.yieldPos=0,this.awaitPos=0;this.type!==y.parenR;){if(l?l=!1:this.expect(y.comma),a&&this.afterTrailingComma(y.parenR,!0)){u=!0;break}if(this.type===y.ellipsis){m=this.start,c.push(this.parseParenItem(this.parseRestBinding())),this.type===y.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`);break}c.push(this.parseMaybeAssign(!1,d,this.parseParenItem))}var h=this.lastTokEnd,g=this.lastTokEndLoc;if(this.expect(y.parenR),e&&this.shouldParseArrow(c)&&this.eat(y.arrow))return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=p,this.parseParenArrowList(n,r,c,t);(!c.length||u)&&this.unexpected(this.lastTokStart),m&&this.unexpected(m),this.checkExpressionErrors(d,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=p||this.awaitPos,c.length>1?(i=this.startNodeAt(o,s),i.expressions=c,this.finishNodeAt(i,`SequenceExpression`,h,g)):i=c[0]}else i=this.parseParenExpression();if(this.options.preserveParens){var _=this.startNodeAt(n,r);return _.expression=i,this.finishNode(_,`ParenthesizedExpression`)}return i},K.parseParenItem=function(e){return e},K.parseParenArrowList=function(e,t,n,r){return this.parseArrowExpression(this.startNodeAt(e,t),n,!1,r)};var Le=[];K.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword new`);var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===y.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name=`new`,e.meta=this.finishNode(t,`Identifier`),this.next();var n=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!==`target`&&this.raiseRecoverable(e.property.start,`The only valid meta property for new is 'new.target'`),n&&this.raiseRecoverable(e.start,`'new.target' must not contain escaped characters`),this.allowNewDotTarget||this.raiseRecoverable(e.start,`'new.target' can only be used in functions and class static block`),this.finishNode(e,`MetaProperty`)}var r=this.start,i=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,i,!0,!1),e.callee.type===`Super`&&this.raiseRecoverable(r,`Invalid use of 'super'`),e.arguments=this.eat(y.parenL)?this.parseExprList(y.parenR,this.options.ecmaVersion>=8,!1):Le,this.finishNode(e,`NewExpression`)},K.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===y.invalidTemplate?(t||this.raiseRecoverable(this.start,`Bad escape sequence in untagged template literal`),n.value={raw:this.value.replace(/\r\n?/g,`
|
|
4
|
+
`),cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
|
|
5
|
+
`),cooked:this.value},this.next(),n.tail=this.type===y.backQuote,this.finishNode(n,`TemplateElement`)},K.parseTemplate=function(e){e===void 0&&(e={});var t=e.isTagged;t===void 0&&(t=!1);var n=this.startNode();this.next(),n.expressions=[];var r=this.parseTemplateElement({isTagged:t});for(n.quasis=[r];!r.tail;)this.type===y.eof&&this.raise(this.pos,`Unterminated template literal`),this.expect(y.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(y.braceR),n.quasis.push(r=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(n,`TemplateLiteral`)},K.isAsyncProp=function(e){return!e.computed&&e.key.type===`Identifier`&&e.key.name===`async`&&(this.type===y.name||this.type===y.num||this.type===y.string||this.type===y.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===y.star)&&!b.test(this.input.slice(this.lastTokEnd,this.start))},K.parseObj=function(e,t){var n=this.startNode(),r=!0,i={};for(n.properties=[],this.next();!this.eat(y.braceR);){if(r)r=!1;else if(this.expect(y.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(y.braceR))break;var a=this.parseProperty(e,t);e||this.checkPropClash(a,i,t),n.properties.push(a)}return this.finishNode(n,e?`ObjectPattern`:`ObjectExpression`)},K.parseProperty=function(e,t){var n=this.startNode(),r,i,a,o;if(this.options.ecmaVersion>=9&&this.eat(y.ellipsis))return e?(n.argument=this.parseIdent(!1),this.type===y.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`),this.finishNode(n,`RestElement`)):(n.argument=this.parseMaybeAssign(!1,t),this.type===y.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(n,`SpreadElement`));this.options.ecmaVersion>=6&&(n.method=!1,n.shorthand=!1,(e||t)&&(a=this.start,o=this.startLoc),e||(r=this.eat(y.star)));var s=this.containsEsc;return this.parsePropertyName(n),!e&&!s&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(n)?(i=!0,r=this.options.ecmaVersion>=9&&this.eat(y.star),this.parsePropertyName(n)):i=!1,this.parsePropertyValue(n,e,r,i,a,o,t,s),this.finishNode(n,`Property`)},K.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var n=e.kind===`get`?0:1;if(e.value.params.length!==n){var r=e.value.start;e.kind===`get`?this.raiseRecoverable(r,`getter should have no params`):this.raiseRecoverable(r,`setter should have exactly one param`)}else e.kind===`set`&&e.value.params[0].type===`RestElement`&&this.raiseRecoverable(e.value.params[0].start,`Setter cannot use rest params`)},K.parsePropertyValue=function(e,t,n,r,i,a,o,s){(n||r)&&this.type===y.colon&&this.unexpected(),this.eat(y.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,o),e.kind=`init`):this.options.ecmaVersion>=6&&this.type===y.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(n,r),e.kind=`init`):!t&&!s&&this.options.ecmaVersion>=5&&!e.computed&&e.key.type===`Identifier`&&(e.key.name===`get`||e.key.name===`set`)&&this.type!==y.comma&&this.type!==y.braceR&&this.type!==y.eq?((n||r)&&this.unexpected(),this.parseGetterSetter(e)):this.options.ecmaVersion>=6&&!e.computed&&e.key.type===`Identifier`?((n||r)&&this.unexpected(),this.checkUnreserved(e.key),e.key.name===`await`&&!this.awaitIdentPos&&(this.awaitIdentPos=i),t?e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key)):this.type===y.eq&&o?(o.shorthandAssign<0&&(o.shorthandAssign=this.start),e.value=this.parseMaybeDefault(i,a,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind=`init`,e.shorthand=!0):this.unexpected()},K.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(y.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(y.bracketR),e.key;e.computed=!1}return e.key=this.type===y.num||this.type===y.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`)},K.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},K.parseMethod=function(e,t,n){var r=this.startNode(),i=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=e),this.options.ecmaVersion>=8&&(r.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Se(t,r.generator)|k|(n?be:0)),this.expect(y.parenL),r.params=this.parseBindingList(y.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(r,`FunctionExpression`)},K.parseArrowExpression=function(e,t,n,r){var i=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.enterScope(Se(n,!1)|ve),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!n),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,r),this.yieldPos=i,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(e,`ArrowFunctionExpression`)},K.parseFunctionBody=function(e,t,n,r){var i=t&&this.type!==y.braceL,a=this.strict,o=!1;if(i)e.body=this.parseMaybeAssign(r),e.expression=!0,this.checkParams(e,!1);else{var s=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!a||s)&&(o=this.strictDirective(this.end),o&&s&&this.raiseRecoverable(e.start,`Illegal 'use strict' directive in function with non-simple parameter list`));var c=this.labels;this.labels=[],o&&(this.strict=!0),this.checkParams(e,!a&&!o&&!t&&!n&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,Ee),e.body=this.parseBlock(!1,void 0,o&&!a),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=c}this.exitScope()},K.isSimpleParamList=function(e){for(var t=0,n=e;t<n.length;t+=1)if(n[t].type!==`Identifier`)return!1;return!0},K.checkParams=function(e,t){for(var n=Object.create(null),r=0,i=e.params;r<i.length;r+=1){var a=i[r];this.checkLValInnerPattern(a,Ce,t?null:n)}},K.parseExprList=function(e,t,n,r){for(var i=[],a=!0;!this.eat(e);){if(a)a=!1;else if(this.expect(y.comma),t&&this.afterTrailingComma(e))break;var o=void 0;n&&this.type===y.comma?o=null:this.type===y.ellipsis?(o=this.parseSpread(r),r&&this.type===y.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):o=this.parseMaybeAssign(!1,r),i.push(o)}return i},K.checkUnreserved=function(e){var t=e.start,n=e.end,r=e.name;this.inGenerator&&r===`yield`&&this.raiseRecoverable(t,`Cannot use 'yield' as identifier inside a generator`),this.inAsync&&r===`await`&&this.raiseRecoverable(t,`Cannot use 'await' as identifier inside an async function`),!(this.currentThisScope().flags&M)&&r===`arguments`&&this.raiseRecoverable(t,`Cannot use 'arguments' in class field initializer`),this.inClassStaticBlock&&(r===`arguments`||r===`await`)&&this.raise(t,`Cannot use `+r+` in class static initialization block`),this.keywords.test(r)&&this.raise(t,`Unexpected keyword '`+r+`'`),this.options.ecmaVersion<6&&this.input.slice(t,n).indexOf(`\\`)!==-1||(this.strict?this.reservedWordsStrict:this.reservedWords).test(r)&&(!this.inAsync&&r===`await`&&this.raiseRecoverable(t,`Cannot use keyword 'await' outside an async function`),this.raiseRecoverable(t,`The keyword '`+r+`' is reserved`))},K.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,`Identifier`),e||(this.checkUnreserved(t),t.name===`await`&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t},K.parseIdentNode=function(){var e=this.startNode();return this.type===y.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,e.name!==`class`&&e.name!==`function`||this.lastTokEnd===this.lastTokStart+1&&this.input.charCodeAt(this.lastTokStart)===46||this.context.pop(),this.type=y.name):this.unexpected(),e},K.parsePrivateIdent=function(){var e=this.startNode();return this.type===y.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,`PrivateIdentifier`),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(e.start,`Private field '#`+e.name+`' must be declared in an enclosing class`):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e},K.parseYield=function(e){this.yieldPos||=this.start;var t=this.startNode();return this.next(),this.type===y.semi||this.canInsertSemicolon()||this.type!==y.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(y.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,`YieldExpression`)},K.parseAwait=function(e){this.awaitPos||=this.start;var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,`AwaitExpression`)};var Re=F.prototype;Re.raise=function(e,t){var n=de(this.input,e);t+=` (`+n.line+`:`+n.column+`)`,this.sourceFile&&(t+=` in `+this.sourceFile);var r=SyntaxError(t);throw r.pos=e,r.loc=n,r.raisedAt=this.pos,r},Re.raiseRecoverable=Re.raise,Re.curPosition=function(){if(this.options.locations)return new E(this.curLine,this.pos-this.lineStart)};var q=F.prototype,ze=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};q.enterScope=function(e){this.scopeStack.push(new ze(e))},q.exitScope=function(){this.scopeStack.pop()},q.treatFunctionsAsVarInScope=function(e){return e.flags&O||!this.inModule&&e.flags&D},q.declareName=function(e,t,n){var r=!1;if(t===P){var i=this.currentScope();r=i.lexical.indexOf(e)>-1||i.functions.indexOf(e)>-1||i.var.indexOf(e)>-1,i.lexical.push(e),this.inModule&&i.flags&D&&delete this.undefinedExports[e]}else if(t===Te)this.currentScope().lexical.push(e);else if(t===we){var a=this.currentScope();r=this.treatFunctionsAsVar?a.lexical.indexOf(e)>-1:a.lexical.indexOf(e)>-1||a.var.indexOf(e)>-1,a.functions.push(e)}else for(var o=this.scopeStack.length-1;o>=0;--o){var s=this.scopeStack[o];if(s.lexical.indexOf(e)>-1&&!(s.flags&ye&&s.lexical[0]===e)||!this.treatFunctionsAsVarInScope(s)&&s.functions.indexOf(e)>-1){r=!0;break}if(s.var.push(e),this.inModule&&s.flags&D&&delete this.undefinedExports[e],s.flags&M)break}r&&this.raiseRecoverable(n,`Identifier '`+e+`' has already been declared`)},q.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)},q.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},q.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(M|j|A))return t}},q.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(M|j|A)&&!(t.flags&ve))return t}};var Be=function(e,t,n){this.type=``,this.start=t,this.end=0,e.options.locations&&(this.loc=new ue(e,n)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},J=F.prototype;J.startNode=function(){return new Be(this,this.start,this.startLoc)},J.startNodeAt=function(e,t){return new Be(this,e,t)};function Ve(e,t,n,r){return e.type=t,e.end=n,this.options.locations&&(e.loc.end=r),this.options.ranges&&(e.range[1]=n),e}J.finishNode=function(e,t){return Ve.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},J.finishNodeAt=function(e,t,n,r){return Ve.call(this,e,t,n,r)},J.copyNode=function(e){var t=new Be(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var He=`Berf Beria_Erfe Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sidetic Sidt Sunu Sunuwar Tai_Yo Tayo Todhri Todr Tolong_Siki Tols Tulu_Tigalari Tutg Unknown Zzzz`,Ue=`ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS`,We=Ue+` Extended_Pictographic`,Ge=We,Ke=Ge+` EBase EComp EMod EPres ExtPict`,qe=Ke,Je={9:Ue,10:We,11:Ge,12:Ke,13:qe,14:qe},Ye={9:``,10:``,11:``,12:``,13:``,14:`Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji`},Xe=`Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu`,Ze=`Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb`,Qe=Ze+` Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd`,$e=Qe+` Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho`,et=$e+` Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi`,tt=et+` Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith`,nt={9:Ze,10:Qe,11:$e,12:et,13:tt,14:tt+` `+He},rt={};function it(e){var t=rt[e]={binary:w(Je[e]+` `+Xe),binaryOfStrings:w(Ye[e]),nonBinary:{General_Category:w(Xe),Script:w(nt[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}for(var at=0,ot=[9,10,11,12,13,14];at<ot.length;at+=1){var st=ot[at];it(st)}var Y=F.prototype,ct=function(e,t){this.parent=e,this.base=t||this};ct.prototype.separatedFrom=function(e){for(var t=this;t;t=t.parent)for(var n=e;n;n=n.parent)if(t.base===n.base&&t!==n)return!0;return!1},ct.prototype.sibling=function(){return new ct(this.parent,this.base)};var X=function(e){this.parser=e,this.validFlags=`gim`+(e.options.ecmaVersion>=6?`uy`:``)+(e.options.ecmaVersion>=9?`s`:``)+(e.options.ecmaVersion>=13?`d`:``)+(e.options.ecmaVersion>=15?`v`:``),this.unicodeProperties=rt[e.options.ecmaVersion>=14?14:e.options.ecmaVersion],this.source=``,this.flags=``,this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue=``,this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};X.prototype.reset=function(e,t,n){var r=n.indexOf(`v`)!==-1,i=n.indexOf(`u`)!==-1;this.start=e|0,this.source=t+``,this.flags=n,r&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=i&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=i&&this.parser.options.ecmaVersion>=9)},X.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,`Invalid regular expression: /`+this.source+`/: `+e)},X.prototype.at=function(e,t){t===void 0&&(t=!1);var n=this.source,r=n.length;if(e>=r)return-1;var i=n.charCodeAt(e);if(!(t||this.switchU)||i<=55295||i>=57344||e+1>=r)return i;var a=n.charCodeAt(e+1);return a>=56320&&a<=57343?(i<<10)+a-56613888:i},X.prototype.nextIndex=function(e,t){t===void 0&&(t=!1);var n=this.source,r=n.length;if(e>=r)return r;var i=n.charCodeAt(e),a;return!(t||this.switchU)||i<=55295||i>=57344||e+1>=r||(a=n.charCodeAt(e+1))<56320||a>57343?e+1:e+2},X.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)},X.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)},X.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)},X.prototype.eat=function(e,t){return t===void 0&&(t=!1),this.current(t)===e&&(this.advance(t),!0)},X.prototype.eatChars=function(e,t){t===void 0&&(t=!1);for(var n=this.pos,r=0,i=e;r<i.length;r+=1){var a=i[r],o=this.at(n,t);if(o===-1||o!==a)return!1;n=this.nextIndex(n,t)}return this.pos=n,!0},Y.validateRegExpFlags=function(e){for(var t=e.validFlags,n=e.flags,r=!1,i=!1,a=0;a<n.length;a++){var o=n.charAt(a);t.indexOf(o)===-1&&this.raise(e.start,`Invalid regular expression flag`),n.indexOf(o,a+1)>-1&&this.raise(e.start,`Duplicate regular expression flag`),o===`u`&&(r=!0),o===`v`&&(i=!0)}this.options.ecmaVersion>=15&&r&&i&&this.raise(e.start,`Invalid regular expression flag`)};function lt(e){for(var t in e)return!0;return!1}Y.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&<(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))},Y.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue=``,e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise(`Unmatched ')'`),(e.eat(93)||e.eat(125))&&e.raise(`Lone quantifier brackets`)),e.maxBackReference>e.numCapturingParens&&e.raise(`Invalid escape`);for(var t=0,n=e.backReferenceNames;t<n.length;t+=1){var r=n[t];e.groupNames[r]||e.raise(`Invalid named capture referenced`)}},Y.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new ct(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise(`Nothing to repeat`),e.eat(123)&&e.raise(`Lone quantifier brackets`)},Y.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););},Y.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise(`Invalid quantifier`),!0):(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))?(this.regexp_eatQuantifier(e),!0):!1},Y.regexp_eatAssertion=function(e){var t=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=t}if(e.eat(40)&&e.eat(63)){var n=!1;if(this.options.ecmaVersion>=9&&(n=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise(`Unterminated group`),e.lastAssertionIsQuantifiable=!n,!0}return e.pos=t,!1},Y.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1},Y.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)},Y.regexp_eatBracedQuantifier=function(e,t){var n=e.pos;if(e.eat(123)){var r=0,i=-1;if(this.regexp_eatDecimalDigits(e)&&(r=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(i=e.lastIntValue),e.eat(125)))return i!==-1&&i<r&&!t&&e.raise(`numbers out of order in {} quantifier`),!0;e.switchU&&!t&&e.raise(`Incomplete quantifier`),e.pos=n}return!1},Y.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)},Y.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1},Y.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var n=this.regexp_eatModifiers(e),r=e.eat(45);if(n||r){for(var i=0;i<n.length;i++){var a=n.charAt(i);n.indexOf(a,i+1)>-1&&e.raise(`Duplicate regular expression modifiers`)}if(r){var o=this.regexp_eatModifiers(e);!n&&!o&&e.current()===58&&e.raise(`Invalid regular expression modifiers`);for(var s=0;s<o.length;s++){var c=o.charAt(s);(o.indexOf(c,s+1)>-1||n.indexOf(c)>-1)&&e.raise(`Duplicate regular expression modifiers`)}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise(`Unterminated group`)}}e.pos=t}return!1},Y.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):e.current()===63&&e.raise(`Invalid group`),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise(`Unterminated group`)}return!1},Y.regexp_eatModifiers=function(e){for(var t=``,n=0;(n=e.current())!==-1&&ut(n);)t+=T(n),e.advance();return t};function ut(e){return e===105||e===109||e===115}Y.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)},Y.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise(`Nothing to repeat`),!1},Y.regexp_eatSyntaxCharacter=function(e){var t=e.current();return dt(t)?(e.lastIntValue=t,e.advance(),!0):!1};function dt(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}Y.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;(n=e.current())!==-1&&!dt(n);)e.advance();return e.pos!==t},Y.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return t!==-1&&t!==36&&!(t>=40&&t<=43)&&t!==46&&t!==63&&t!==91&&t!==94&&t!==124&&(e.advance(),!0)},Y.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise(`Invalid group`);var t=this.options.ecmaVersion>=16,n=e.groupNames[e.lastStringValue];if(n){if(t)for(var r=0,i=n;r<i.length;r+=1)i[r].separatedFrom(e.branchID)||e.raise(`Duplicate capture group name`);else e.raise(`Duplicate capture group name`)}t?(n||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}},Y.regexp_eatGroupName=function(e){if(e.lastStringValue=``,e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise(`Invalid capture group name`)}return!1},Y.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue=``,this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=T(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=T(e.lastIntValue);return!0}return!1},Y.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),ft(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function ft(e){return f(e,!0)||e===36||e===95}Y.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,r=e.current(n);return e.advance(n),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(r=e.lastIntValue),pt(r)?(e.lastIntValue=r,!0):(e.pos=t,!1)};function pt(e){return p(e,!0)||e===36||e===95||e===8204||e===8205}Y.regexp_eatAtomEscape=function(e){return this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e)?!0:(e.switchU&&(e.current()===99&&e.raise(`Invalid unicode escape`),e.raise(`Invalid escape`)),!1)},Y.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var n=e.lastIntValue;if(e.switchU)return n>e.maxBackReference&&(e.maxBackReference=n),!0;if(n<=e.numCapturingParens)return!0;e.pos=t}return!1},Y.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise(`Invalid named reference`)}return!1},Y.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)},Y.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1},Y.regexp_eatZero=function(e){return e.current()===48&&!Ct(e.lookahead())&&(e.lastIntValue=0,e.advance(),!0)},Y.regexp_eatControlEscape=function(e){var t=e.current();return t===116?(e.lastIntValue=9,e.advance(),!0):t===110?(e.lastIntValue=10,e.advance(),!0):t===118?(e.lastIntValue=11,e.advance(),!0):t===102?(e.lastIntValue=12,e.advance(),!0):t===114&&(e.lastIntValue=13,e.advance(),!0)},Y.regexp_eatControlLetter=function(e){var t=e.current();return mt(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function mt(e){return e>=65&&e<=90||e>=97&&e<=122}Y.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){t===void 0&&(t=!1);var n=e.pos,r=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var i=e.lastIntValue;if(r&&i>=55296&&i<=56319){var a=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var o=e.lastIntValue;if(o>=56320&&o<=57343)return e.lastIntValue=(i-55296)*1024+(o-56320)+65536,!0}e.pos=a,e.lastIntValue=i}return!0}if(r&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&ht(e.lastIntValue))return!0;r&&e.raise(`Invalid unicode escape`),e.pos=n}return!1};function ht(e){return e>=0&&e<=1114111}Y.regexp_eatIdentityEscape=function(e){if(e.switchU)return this.regexp_eatSyntaxCharacter(e)?!0:e.eat(47)?(e.lastIntValue=47,!0):!1;var t=e.current();return t!==99&&(!e.switchN||t!==107)&&(e.lastIntValue=t,e.advance(),!0)},Y.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do e.lastIntValue=10*e.lastIntValue+(t-48),e.advance();while((t=e.current())>=48&&t<=57);return!0}return!1};var gt=0,Z=1,Q=2;Y.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(_t(t))return e.lastIntValue=-1,e.advance(),Z;var n=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((n=t===80)||t===112)){e.lastIntValue=-1,e.advance();var r;if(e.eat(123)&&(r=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return n&&r===Q&&e.raise(`Invalid property name`),r;e.raise(`Invalid property name`)}return gt};function _t(e){return e===100||e===68||e===115||e===83||e===119||e===87}Y.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var n=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var r=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,n,r),Z}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i)}return gt},Y.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){C(e.unicodeProperties.nonBinary,t)||e.raise(`Invalid property name`),e.unicodeProperties.nonBinary[t].test(n)||e.raise(`Invalid property value`)},Y.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return Z;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return Q;e.raise(`Invalid property name`)},Y.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue=``;vt(t=e.current());)e.lastStringValue+=T(t),e.advance();return e.lastStringValue!==``};function vt(e){return mt(e)||e===95}Y.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue=``;yt(t=e.current());)e.lastStringValue+=T(t),e.advance();return e.lastStringValue!==``};function yt(e){return vt(e)||Ct(e)}Y.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)},Y.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),n=this.regexp_classContents(e);return e.eat(93)||e.raise(`Unterminated character class`),t&&n===Q&&e.raise(`Negated character class may contain strings`),!0}return!1},Y.regexp_classContents=function(e){return e.current()===93?Z:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),Z)},Y.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var n=e.lastIntValue;e.switchU&&(t===-1||n===-1)&&e.raise(`Invalid character class`),t!==-1&&n!==-1&&t>n&&e.raise(`Range out of order in character class`)}}},Y.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var n=e.current();(n===99||Et(n))&&e.raise(`Invalid class escape`),e.raise(`Invalid escape`)}e.pos=t}var r=e.current();return r!==93&&(e.lastIntValue=r,e.advance(),!0)},Y.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)},Y.regexp_classSetExpression=function(e){var t=Z,n;if(!this.regexp_eatClassSetRange(e)){if(n=this.regexp_eatClassSetOperand(e)){n===Q&&(t=Q);for(var r=e.pos;e.eatChars([38,38]);)e.current()!==38&&(n=this.regexp_eatClassSetOperand(e))?n!==Q&&(t=Z):e.raise(`Invalid character in character class`);if(r!==e.pos)return t;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise(`Invalid character in character class`);if(r!==e.pos)return t}else e.raise(`Invalid character in character class`)}for(;;)if(!this.regexp_eatClassSetRange(e)){if(n=this.regexp_eatClassSetOperand(e),!n)return t;n===Q&&(t=Q)}},Y.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var n=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var r=e.lastIntValue;return n!==-1&&r!==-1&&n>r&&e.raise(`Range out of order in character class`),!0}e.pos=t}return!1},Y.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?Z:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)},Y.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var n=e.eat(94),r=this.regexp_classContents(e);if(e.eat(93))return n&&r===Q&&e.raise(`Negated character class may contain strings`),r;e.pos=t}if(e.eat(92)){var i=this.regexp_eatCharacterClassEscape(e);if(i)return i;e.pos=t}return null},Y.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var n=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return n}else e.raise(`Invalid escape`);e.pos=t}return null},Y.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===Q&&(t=Q);return t},Y.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?Z:Q},Y.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return this.regexp_eatCharacterEscape(e)||this.regexp_eatClassSetReservedPunctuator(e)?!0:e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1);var n=e.current();return n<0||n===e.lookahead()&&bt(n)||xt(n)?!1:(e.advance(),e.lastIntValue=n,!0)};function bt(e){return e===33||e>=35&&e<=38||e>=42&&e<=44||e===46||e>=58&&e<=64||e===94||e===96||e===126}function xt(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}Y.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return St(t)?(e.lastIntValue=t,e.advance(),!0):!1};function St(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}Y.regexp_eatClassControlLetter=function(e){var t=e.current();return Ct(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1},Y.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise(`Invalid escape`),e.pos=t}return!1},Y.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Ct(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t};function Ct(e){return e>=48&&e<=57}Y.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;wt(n=e.current());)e.lastIntValue=16*e.lastIntValue+Tt(n),e.advance();return e.pos!==t};function wt(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Tt(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}Y.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var n=e.lastIntValue;e.lastIntValue=t<=3&&this.regexp_eatOctalDigit(e)?t*64+n*8+e.lastIntValue:t*8+n}else e.lastIntValue=t;return!0}return!1},Y.regexp_eatOctalDigit=function(e){var t=e.current();return Et(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Et(e){return e>=48&&e<=55}Y.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var r=0;r<t;++r){var i=e.current();if(!wt(i))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+Tt(i),e.advance()}return!0};var Dt=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new ue(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},$=F.prototype;$.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword `+this.type.keyword),this.options.onToken&&this.options.onToken(new Dt(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},$.getToken=function(){return this.next(),new Dt(this)},typeof Symbol<`u`&&($[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===y.eof,value:t}}}}),$.nextToken=function(){var e=this.curContext();if(e&&e.preserveSpace||this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(y.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())},$.readToken=function(e){return f(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)},$.fullCharCodeAt=function(e){var t=this.input.charCodeAt(e);if(t<=55295||t>=56320)return t;var n=this.input.charCodeAt(e+1);return n<=56319||n>=57344?t:(t<<10)+n-56613888},$.fullCharCodeAtPos=function(){return this.fullCharCodeAt(this.pos)},$.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,n=this.input.indexOf(`*/`,this.pos+=2);if(n===-1&&this.raise(this.pos-2,`Unterminated comment`),this.pos=n+2,this.options.locations)for(var r=void 0,i=t;(r=ne(this.input,i,this.pos))>-1;)++this.curLine,i=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,n),t,this.pos,e,this.curPosition())},$.skipLineComment=function(e){for(var t=this.pos,n=this.options.onComment&&this.curPosition(),r=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!x(r);)r=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,n,this.curPosition())},$.skipSpace=function(){loop:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break loop}break;default:if(e>8&&e<14||e>=5760&&re.test(String.fromCharCode(e)))++this.pos;else break loop}}},$.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=t,this.updateContext(n)},$.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&t===46?(this.pos+=3,this.finishToken(y.ellipsis)):(++this.pos,this.finishToken(y.dot))},$.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(y.assign,2):this.finishOp(y.slash,1)},$.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,r=e===42?y.star:y.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++n,r=y.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(y.assign,n+1):this.finishOp(r,n)},$.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?this.options.ecmaVersion>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(y.assign,3):this.finishOp(e===124?y.logicalOR:y.logicalAND,2):t===61?this.finishOp(y.assign,2):this.finishOp(e===124?y.bitwiseOR:y.bitwiseAND,1)},$.readToken_caret=function(){return this.input.charCodeAt(this.pos+1)===61?this.finishOp(y.assign,2):this.finishOp(y.bitwiseXOR,1)},$.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?t===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||b.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(y.incDec,2):t===61?this.finishOp(y.assign,2):this.finishOp(y.plusMin,1)},$.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),n=1;return t===e?(n=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+n)===61?this.finishOp(y.assign,n+1):this.finishOp(y.bitShift,n)):t===33&&e===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(t===61&&(n=2),this.finishOp(y.relational,n))},$.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(y.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(y.arrow)):this.finishOp(e===61?y.eq:y.prefix,1)},$.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(t===46){var n=this.input.charCodeAt(this.pos+2);if(n<48||n>57)return this.finishOp(y.questionDot,2)}if(t===63)return e>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(y.assign,3):this.finishOp(y.coalesce,2)}return this.finishOp(y.question,1)},$.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),f(t,!0)||t===92))return this.finishToken(y.privateId,this.readWord1());this.raise(this.pos,`Unexpected character '`+T(t)+`'`)},$.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(y.parenL);case 41:return++this.pos,this.finishToken(y.parenR);case 59:return++this.pos,this.finishToken(y.semi);case 44:return++this.pos,this.finishToken(y.comma);case 91:return++this.pos,this.finishToken(y.bracketL);case 93:return++this.pos,this.finishToken(y.bracketR);case 123:return++this.pos,this.finishToken(y.braceL);case 125:return++this.pos,this.finishToken(y.braceR);case 58:return++this.pos,this.finishToken(y.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(y.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(t===120||t===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(t===111||t===79)return this.readRadixNumber(8);if(t===98||t===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(y.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,`Unexpected character '`+T(e)+`'`)},$.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)},$.readRegexp=function(){for(var e,t,n=this.pos;;){this.pos>=this.input.length&&this.raise(n,`Unterminated regular expression`);var r=this.input.charAt(this.pos);if(b.test(r)&&this.raise(n,`Unterminated regular expression`),e)e=!1;else{if(r===`[`)t=!0;else if(r===`]`&&t)t=!1;else if(r===`/`&&!t)break;e=r===`\\`}++this.pos}var i=this.input.slice(n,this.pos);++this.pos;var a=this.pos,o=this.readWord1();this.containsEsc&&this.unexpected(a);var s=this.regexpState||=new X(this);s.reset(n,i,o),this.validateRegExpFlags(s),this.validateRegExpPattern(s);var c=null;try{c=new RegExp(i,o)}catch{}return this.finishToken(y.regexp,{pattern:i,flags:o,value:c})},$.readInt=function(e,t,n){for(var r=this.options.ecmaVersion>=12&&t===void 0,i=n&&this.input.charCodeAt(this.pos)===48,a=this.pos,o=0,s=0,c=0,l=t??1/0;c<l;++c,++this.pos){var u=this.input.charCodeAt(this.pos),d=void 0;if(r&&u===95)i&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed in legacy octal numeric literals`),s===95&&this.raiseRecoverable(this.pos,`Numeric separator must be exactly one underscore`),c===0&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed at the first of digits`),s=u;else{if(d=u>=97?u-97+10:u>=65?u-65+10:u>=48&&u<=57?u-48:1/0,d>=e)break;s=u,o=o*e+d}}return r&&s===95&&this.raiseRecoverable(this.pos-1,`Numeric separator is not allowed at the last of digits`),this.pos===a||t!=null&&this.pos-a!==t?null:o};function Ot(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,``))}function kt(e){return typeof BigInt==`function`?BigInt(e.replace(/_/g,``)):null}$.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var n=this.readInt(e);return n??this.raise(this.start+2,`Expected number in radix `+e),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(n=kt(this.input.slice(t,this.pos)),++this.pos):f(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(y.num,n)},$.readNumber=function(e){var t=this.pos;!e&&this.readInt(10,void 0,!0)===null&&this.raise(t,`Invalid number`);var n=this.pos-t>=2&&this.input.charCodeAt(t)===48;n&&this.strict&&this.raise(t,`Invalid number`);var r=this.input.charCodeAt(this.pos);if(!n&&!e&&this.options.ecmaVersion>=11&&r===110){var i=kt(this.input.slice(t,this.pos));return++this.pos,f(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(y.num,i)}n&&/[89]/.test(this.input.slice(t,this.pos))&&(n=!1),r===46&&!n&&(++this.pos,this.readInt(10),r=this.input.charCodeAt(this.pos)),r!==69&&r!==101||n||(r=this.input.charCodeAt(++this.pos),(r===43||r===45)&&++this.pos,this.readInt(10)===null&&this.raise(t,`Invalid number`)),f(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`);var a=Ot(this.input.slice(t,this.pos),n);return this.finishToken(y.num,a)},$.readCodePoint=function(){var e=this.input.charCodeAt(this.pos),t;if(e===123){this.options.ecmaVersion<6&&this.unexpected();var n=++this.pos;t=this.readHexChar(this.input.indexOf(`}`,this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(n,`Code point out of bounds`)}else t=this.readHexChar(4);return t},$.readString=function(e){for(var t=``,n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated string constant`);var r=this.input.charCodeAt(this.pos);if(r===e)break;r===92?(t+=this.input.slice(n,this.pos),t+=this.readEscapedChar(!1),n=this.pos):r===8232||r===8233?(this.options.ecmaVersion<10&&this.raise(this.start,`Unterminated string constant`),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(x(r)&&this.raise(this.start,`Unterminated string constant`),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(y.string,t)};var At={};$.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===At)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1},$.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw At;this.raise(e,t)},$.readTmplToken=function(){for(var e=``,t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated template`);var n=this.input.charCodeAt(this.pos);if(n===96||n===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===y.template||this.type===y.invalidTemplate)?n===36?(this.pos+=2,this.finishToken(y.dollarBraceL)):(++this.pos,this.finishToken(y.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(y.template,e));if(n===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(x(n)){switch(e+=this.input.slice(t,this.pos),++this.pos,n){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:e+=`
|
|
6
|
+
`;break;default:e+=String.fromCharCode(n)}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}},$.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case`\\`:++this.pos;break;case`$`:if(this.input[this.pos+1]!==`{`)break;case"`":return this.finishToken(y.invalidTemplate,this.input.slice(this.start,this.pos));case`\r`:this.input[this.pos+1]===`
|
|
7
|
+
`&&++this.pos;case`
|
|
8
|
+
`:case`\u2028`:case`\u2029`:++this.curLine,this.lineStart=this.pos+1}this.raise(this.start,`Unterminated template`)},$.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`
|
|
9
|
+
`;case 114:return`\r`;case 120:return String.fromCharCode(this.readHexChar(2));case 117:return T(this.readCodePoint());case 116:return` `;case 98:return`\b`;case 118:return`\v`;case 102:return`\f`;case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),``;case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,`Invalid escape sequence`),e){var n=this.pos-1;this.invalidStringToken(n,`Invalid escape sequence in template string`)}default:if(t>=48&&t<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(r,8);return i>255&&(r=r.slice(0,-1),i=parseInt(r,8)),this.pos+=r.length-1,t=this.input.charCodeAt(this.pos),(r!==`0`||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-r.length,e?`Octal literal in template string`:`Octal literal in strict mode`),String.fromCharCode(i)}return x(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),``):String.fromCharCode(t)}},$.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,`Bad character escape sequence`),n},$.readWord1=function(){this.containsEsc=!1;for(var e=``,t=!0,n=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(p(i,r))this.pos+=i<=65535?1:2;else if(i===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var a=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,`Expecting Unicode escape sequence \\uXXXX`),++this.pos;var o=this.readCodePoint();(t?f:p)(o,r)||this.invalidStringToken(a,`Invalid Unicode escape`),e+=T(o),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},$.readWord=function(){var e=this.readWord1(),t=y.name;return this.keywords.test(e)&&(t=ee[e]),this.finishToken(t,e)},F.acorn={Parser:F,version:`8.19.0`,defaultOptions:fe,Position:E,SourceLocation:ue,getLineInfo:de,Node:Be,TokenType:m,tokTypes:y,keywordTypes:ee,TokContext:U,tokContexts:W,isIdentifierChar:p,isIdentifierStart:f,Token:Dt,isNewLine:x,lineBreak:b,lineBreakG:te,nonASCIIwhitespace:re};function jt(e,t){return F.parse(e,t)}function Mt(e,t=!1){if(e===``)return[``];let n=t?e.split(/(?<=\n)|(?<=\r)(?!\n)|(?<=[\u2028\u2029])/):e.split(/\r\n|[\r\n\u2028\u2029]/);return n.at(-1)===``&&n.pop(),n}function Nt(e,t={}){let n=Mt(e),r=[];try{jt(e,{ecmaVersion:`latest`,sourceType:`module`,allowHashBang:!0,...t,locations:!0,onToken(t){let i=t.loc.start,a=t.loc.end,o=Array.from(n[i.line-1].slice(0,i.column)).length,s=Array.from(n[a.line-1].slice(0,a.column)).length;r.push({type:t.type.label,string:e.slice(t.start,t.end),start:{lineno:i.line,col_offset:o},end:{lineno:a.line,col_offset:s},src_lines:n.slice(i.line-1,a.line)})},onComment(t,i,a,o,s,c){let l=Array.from(n[s.line-1].slice(0,s.column)).length,u=Array.from(n[c.line-1].slice(0,c.column)).length,d=e.slice(a,o);r.push({type:t?`commentBlock`:a===0&&d.startsWith(`#!`)?`shebang`:`commentLine`,string:d,start:{lineno:s.line,col_offset:l},end:{lineno:c.line,col_offset:u},src_lines:n.slice(s.line-1,c.line)})},onInsertedSemicolon(e,t){let i=Array.from(n[t.line-1].slice(0,t.column)).length;r.push({type:`newline`,string:``,start:{lineno:t.line,col_offset:i},end:{lineno:t.line,col_offset:i},src_lines:n.slice(t.line-1,t.line)})}})}catch(e){if(!(e instanceof SyntaxError)){let t=e;return process.stderr.write(JSON.stringify({name:t.name,message:t.message})),process.exitCode=1,[]}let t=e;process.stderr.write(JSON.stringify({name:t.name,message:t.message,pos:t.pos,loc:t.loc,raisedAt:t.raisedAt})),process.exitCode=1}return r.sort((e,t)=>{let n=[`newline`];return e.start.lineno-t.start.lineno||e.start.col_offset-t.start.col_offset||e.end.lineno-t.end.lineno||e.end.col_offset-t.end.col_offset||Number(n.includes(t.type))-Number(n.includes(e.type))})}const Pt=e(0,`utf8`);for(let e of Nt(Pt))process.stdout.write(JSON.stringify(e)+`
|
|
10
|
+
`);export{};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"""new tok types for javascript"""
|
|
2
|
+
|
|
3
|
+
# imports
|
|
4
|
+
|
|
5
|
+
# local imports
|
|
6
|
+
from phy_js_base_tokenizer._compat import NamespacedTokType
|
|
7
|
+
from phy_js_base_tokenizer._meta import FOREIGN_JS_NAMESPACE
|
|
8
|
+
|
|
9
|
+
# `private_id` token type, which used in js for private member of class
|
|
10
|
+
PRIVATE_ID = NamespacedTokType(namespace=FOREIGN_JS_NAMESPACE, name='PRIVATE_ID')
|
|
11
|
+
|
|
12
|
+
SHEBANG = NamespacedTokType(namespace=FOREIGN_JS_NAMESPACE, name='SHEBANG')
|
|
13
|
+
REGEXP = NamespacedTokType(namespace=FOREIGN_JS_NAMESPACE, name='REGEXP', _is_string_lit=True)
|
|
14
|
+
TEMPLATE = NamespacedTokType(
|
|
15
|
+
namespace=FOREIGN_JS_NAMESPACE, name='TEMPLATE', _is_string_lit=True
|
|
16
|
+
)
|
|
17
|
+
INVALID_TEMPLATE = NamespacedTokType(
|
|
18
|
+
namespace=FOREIGN_JS_NAMESPACE, name='INVALID_TEMPLATE', _is_string_lit=True
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# These are token type literals generated by `acornjs`.
|
|
23
|
+
# REMINDER: there includes union operator literals like '++/--'.
|
|
24
|
+
OP_LITERALS = [
|
|
25
|
+
'[',
|
|
26
|
+
']',
|
|
27
|
+
'{',
|
|
28
|
+
'}',
|
|
29
|
+
'(',
|
|
30
|
+
')',
|
|
31
|
+
',',
|
|
32
|
+
';',
|
|
33
|
+
':',
|
|
34
|
+
'.',
|
|
35
|
+
'?',
|
|
36
|
+
'?.',
|
|
37
|
+
'=>',
|
|
38
|
+
'...',
|
|
39
|
+
'`',
|
|
40
|
+
'${',
|
|
41
|
+
'=',
|
|
42
|
+
'_=',
|
|
43
|
+
'++/--',
|
|
44
|
+
'!/~',
|
|
45
|
+
'||',
|
|
46
|
+
'&&',
|
|
47
|
+
'|',
|
|
48
|
+
'^',
|
|
49
|
+
'&',
|
|
50
|
+
'==/!=/===/!==',
|
|
51
|
+
'</>/<=/>=',
|
|
52
|
+
'<</>>/>>>',
|
|
53
|
+
'+/-',
|
|
54
|
+
'%',
|
|
55
|
+
'*',
|
|
56
|
+
'/',
|
|
57
|
+
'**',
|
|
58
|
+
'??',
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
KEYWORD_LITERALS = [
|
|
62
|
+
'break',
|
|
63
|
+
'case',
|
|
64
|
+
'catch',
|
|
65
|
+
'continue',
|
|
66
|
+
'debugger',
|
|
67
|
+
'default',
|
|
68
|
+
'do',
|
|
69
|
+
'else',
|
|
70
|
+
'finally',
|
|
71
|
+
'for',
|
|
72
|
+
'function',
|
|
73
|
+
'if',
|
|
74
|
+
'return',
|
|
75
|
+
'switch',
|
|
76
|
+
'throw',
|
|
77
|
+
'try',
|
|
78
|
+
'var',
|
|
79
|
+
'const',
|
|
80
|
+
'while',
|
|
81
|
+
'with',
|
|
82
|
+
'new',
|
|
83
|
+
'this',
|
|
84
|
+
'super',
|
|
85
|
+
'class',
|
|
86
|
+
'extends',
|
|
87
|
+
'export',
|
|
88
|
+
'import',
|
|
89
|
+
'null',
|
|
90
|
+
'true',
|
|
91
|
+
'false',
|
|
92
|
+
'in',
|
|
93
|
+
'instanceof',
|
|
94
|
+
'typeof',
|
|
95
|
+
'void',
|
|
96
|
+
'delete',
|
|
97
|
+
]
|