| 191 | } |
| 192 | |
| 193 | const identifier = () => { |
| 194 | const start = i |
| 195 | let code = text.charCodeAt(i) |
| 196 | if (isAsciiIdPart(code) && !isDigit(code)) { |
| 197 | do code = text.charCodeAt(++i) |
| 198 | while (isAsciiIdPart(code)) |
| 199 | // Past an ASCII name, only an escape or a non-ASCII character can continue it. |
| 200 | if (code !== 0x5c && !(code >= 0x80)) return text.slice(start, i) |
| 201 | i = start |
| 202 | } |
| 203 | run(idName) |
| 204 | let name = text.slice(start, i) |
| 205 | if (name !== "" && text.charAt(i) !== "\\") return name |
| 206 | // Escapes are validated one code point at a time. |
| 207 | for (;;) { |
| 208 | const at = i |
| 209 | const valid = name === "" ? idStart : idPart |
| 210 | let c = String.fromCodePoint(text.codePointAt(i) ?? 0) |
| 211 | if (c === "\\") { |
| 212 | if (text.charAt(i + 1) !== "u") fail(i + 1) |
| 213 | i += 2 |
| 214 | c = hex(4) |
| 215 | if (!valid.test(c)) fail(at) |
| 216 | } else if (i < text.length && valid.test(c)) i += c.length |
| 217 | else if (name === "") fail(i) |
| 218 | else return name |
| 219 | name += c |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | const stack: Array<Frame> = [] |
| 224 | |