MCPcopy Index your code
hub / github.com/codeaashu/claude-code / parseBareWord

Function parseBareWord

src/utils/bash/bashParser.ts:2163–2213  ·  view source on GitHub ↗
(P: ParseState)

Source from the content-addressed store, hash-verified

2161}
2162
2163function parseBareWord(P: ParseState): TsNode | null {
2164 const start = P.L.b
2165 const startI = P.L.i
2166 while (P.L.i < P.L.len) {
2167 const c = peek(P.L)
2168 if (c === '\\') {
2169 if (P.L.i + 1 >= P.L.len) {
2170 // Trailing unpaired `\` at true EOF — tree-sitter emits word WITHOUT
2171 // the `\` plus a sibling ERROR node. Stop here; caller emits ERROR.
2172 break
2173 }
2174 const nx = P.L.src[P.L.i + 1]
2175 if (nx === '\n' || (nx === '\r' && P.L.src[P.L.i + 2] === '\n')) {
2176 // Line continuation BREAKS the word (tree-sitter quirk) — handles \r?\n
2177 break
2178 }
2179 advance(P.L)
2180 advance(P.L)
2181 continue
2182 }
2183 if (
2184 c === ' ' ||
2185 c === '\t' ||
2186 c === '\n' ||
2187 c === '\r' ||
2188 c === '' ||
2189 c === '|' ||
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 ) {
2205 break
2206 }
2207 advance(P.L)
2208 }
2209 if (P.L.b === start) return null
2210 const text = P.src.slice(startI, P.L.i)
2211 const type = /^-?\d+$/.test(text) ? 'number' : 'word'
2212 return mk(P, type, start, P.L.b, [])
2213}
2214
2215function tryParseBraceExpr(P: ParseState): TsNode | null {
2216 // {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