| 224 | |
| 225 | // ----- Character class ----- 字符类解析 ----- |
| 226 | function parseCharClass(): Unit | null { |
| 227 | if (peek() === "^") next(); // 可选取反 |
| 228 | let closed = false, |
| 229 | first = true; |
| 230 | while (i < n) { |
| 231 | const ch = next(); |
| 232 | if (ch === "\\" && i < n) { |
| 233 | if (!next()) return null; |
| 234 | } else if (ch === "]" && !first) { |
| 235 | closed = true; |
| 236 | break; |
| 237 | } |
| 238 | first = false; |
| 239 | } |
| 240 | if (!closed) return null; |
| 241 | return { glob: "?", baseGlob: "?", canRepeat: true, min: 1, isLiteral: false, varLen: false }; |
| 242 | } |
| 243 | |
| 244 | // ----- Literal utils ----- 字面量辅助 ----- |
| 245 | function fixedLiteralLength(s: string): number { |