MCPcopy Create free account
hub / github.com/scriptscat/scriptcat / parseCharClass

Function parseCharClass

src/pkg/utils/regex_to_glob.ts:226–242  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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 {

Callers 1

parseUnitFunction · 0.85

Calls 2

peekFunction · 0.85
nextFunction · 0.85

Tested by

no test coverage detected