MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / parseBareWord

Function parseBareWord

source code/utils/bash/bashParser.ts:2165–2215  ·  view source on GitHub ↗
(P: ParseState)

Source from the content-addressed store, hash-verified

2163}
2164
2165function parseBareWord(P: ParseState): TsNode | null {
2166 const start = P.L.b
2167 const startI = P.L.i
2168 while (P.L.i < P.L.len) {
2169 const c = peek(P.L)
2170 if (c === '\\') {
2171 if (P.L.i + 1 >= P.L.len) {
2172 // Trailing unpaired `\` at true EOF — tree-sitter emits word WITHOUT
2173 // the `\` plus a sibling ERROR node. Stop here; caller emits ERROR.
2174 break
2175 }
2176 const nx = P.L.src[P.L.i + 1]
2177 if (nx === '\n' || (nx === '\r' && P.L.src[P.L.i + 2] === '\n')) {
2178 // Line continuation BREAKS the word (tree-sitter quirk) — handles \r?\n
2179 break
2180 }
2181 advance(P.L)
2182 advance(P.L)
2183 continue
2184 }
2185 if (
2186 c === ' ' ||
2187 c === '\t' ||
2188 c === '\n' ||
2189 c === '\r' ||
2190 c === '' ||
2191 c === '|' ||
2192 c === '&' ||
2193 c === ';' ||
2194 c === '(' ||
2195 c === ')' ||
2196 c === '<' ||
2197 c === '>' ||
2198 c === '"' ||
2199 c === "'" ||
2200 c === '$' ||
2201 c === '`' ||
2202 c === '{' ||
2203 c === '}' ||
2204 c === '[' ||
2205 c === ']'
2206 ) {
2207 break
2208 }
2209 advance(P.L)
2210 }
2211 if (P.L.b === start) return null
2212 const text = P.src.slice(startI, P.L.i)
2213 const type = /^-?\d+$/.test(text) ? 'number' : 'word'
2214 return mk(P, type, start, P.L.b, [])
2215}
2216
2217function tryParseBraceExpr(P: ParseState): TsNode | null {
2218 // {N..M} where N, M are numbers or single chars

Callers 1

parseWordFunction · 0.85

Calls 3

advanceFunction · 0.85
mkFunction · 0.85
peekFunction · 0.70

Tested by

no test coverage detected