Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsExtglobType ¶
IsExtglobType reports whether c is a valid extglob type character.
TypeScript: types = new Set(['!', '?', '+', '*', '@']); isExtglobType(c)
Types ¶
type ExtglobType ¶
type ExtglobType byte
ExtglobType is a TypeScript ExtglobType: '!' | '?' | '+' | '*' | '@'.
const ( ExtglobNegate ExtglobType = '!' // !(...) ExtglobOptional ExtglobType = '?' // ?(...) ExtglobPlus ExtglobType = '+' // +(...) ExtglobStar ExtglobType = '*' // *(...) ExtglobOne ExtglobType = '@' // @(...) )
Extglob type characters recognized by isExtglobType in ast.ts.
type Token ¶
Token is one lexical unit of a path-segment pattern.
Start and End are byte offsets into the original segment string such that segment[Start:End] is the raw lexeme (except that TokenExtglobOpen.Text is only the type character, while Start:End still spans type + '(').
func Scan ¶
Scan tokenizes a single path-segment pattern string.
This is the lexical counterpart of TypeScript AST.#parseAST: it walks the string character-by-character, tracks escape state and character-class regions, and recognizes extglob structure. It does not build an AST, does not expand braces, does not split on '/', and does not match paths.
The segment is typically one slash-separated piece of a full pattern (TypeScript parses each piece after slashSplit). Passing a string that contains '/' is allowed; '/' is ordinary TokenText (no path splitting).
Options that affect scanning:
- NoExt: never emit TokenExtglobOpen; "*(" etc. stay in TokenText
- MaxExtglobRecursion: depth at which nested extglobs stop being recognized (default DefaultMaxExtglobRecursion), matching maxExtglobRecursion ?? 2 and the adoption-aware depth rule from #parseAST / #canAdoptType
Other Options fields are ignored by Scan.
Unfinished extglobs (opening "*(" without a closing ")") produce an open without a matching TokenExtglobClose. TypeScript demotes those to literal text when building the AST; demotion is not applied here. Scan tokenizes a path-segment pattern. noExt disables extglobs; maxDepth is maxExtglobRecursion (use 2 for default).
type TokenKind ¶
type TokenKind int
TokenKind is the kind of a lexical token produced by Scan.
These kinds correspond to what TypeScript AST.#parseAST recognizes while walking a path-segment string. They are structural / lexical only: leaf glob magic such as standalone "*" or "?" stays inside TokenText and is not re-tokenized here (that happens later, in the equivalent of #parseGlob).
const ( // TokenText is a run of characters that are not extglob structure. // // In TypeScript #parseAST this is the "acc" string: escapes, character // classes, "*", "?", ordinary letters, and even "|" or ")" when not // inside an extglob are all accumulated as text. // // Text holds the raw substring, including backslashes and "["..."]" // class spans kept opaque (the class is not parsed into ranges here). TokenText TokenKind = iota // TokenExtglobOpen is an extglob introducer: one of ! ? + * @ followed // immediately by '('. // // TypeScript: isExtglobType(c) && str.charAt(i) === '(' with noext off // and depth limits allowing recursion. // // Text is the single type character ("!", "?", "+", "*", or "@"). // The token span covers both the type character and the '('. TokenExtglobOpen // TokenPipe is "|" separating extglob alternatives. // // TypeScript: only recognized while parsing inside an extglob // (ast.type !== null). At root level, "|" is TokenText. TokenPipe // TokenExtglobClose is ")" closing the current extglob. // // TypeScript: only recognized inside an extglob. At root level, ")" is // TokenText. TokenExtglobClose )