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

Function scanArithOp

src/utils/bash/bashParser.ts:4191–4229  ·  view source on GitHub ↗

Scan next arithmetic binary operator; returns [text, length] or null.

(P: ParseState)

Source from the content-addressed store, hash-verified

4189
4190/** Scan next arithmetic binary operator; returns [text, length] or null. */
4191function scanArithOp(P: ParseState): [string, number] | null {
4192 const c = peek(P.L)
4193 const c1 = peek(P.L, 1)
4194 const c2 = peek(P.L, 2)
4195 // 3-char: <<= >>=
4196 if (c === '<' && c1 === '<' && c2 === '=') return ['<<=', 3]
4197 if (c === '>' && c1 === '>' && c2 === '=') return ['>>=', 3]
4198 // 2-char
4199 if (c === '*' && c1 === '*') return ['**', 2]
4200 if (c === '<' && c1 === '<') return ['<<', 2]
4201 if (c === '>' && c1 === '>') return ['>>', 2]
4202 if (c === '=' && c1 === '=') return ['==', 2]
4203 if (c === '!' && c1 === '=') return ['!=', 2]
4204 if (c === '<' && c1 === '=') return ['<=', 2]
4205 if (c === '>' && c1 === '=') return ['>=', 2]
4206 if (c === '&' && c1 === '&') return ['&&', 2]
4207 if (c === '|' && c1 === '|') return ['||', 2]
4208 if (c === '+' && c1 === '=') return ['+=', 2]
4209 if (c === '-' && c1 === '=') return ['-=', 2]
4210 if (c === '*' && c1 === '=') return ['*=', 2]
4211 if (c === '/' && c1 === '=') return ['/=', 2]
4212 if (c === '%' && c1 === '=') return ['%=', 2]
4213 if (c === '&' && c1 === '=') return ['&=', 2]
4214 if (c === '^' && c1 === '=') return ['^=', 2]
4215 if (c === '|' && c1 === '=') return ['|=', 2]
4216 // 1-char — but NOT ++ -- (those are pre/postfix)
4217 if (c === '+' && c1 !== '+') return ['+', 1]
4218 if (c === '-' && c1 !== '-') return ['-', 1]
4219 if (c === '*') return ['*', 1]
4220 if (c === '/') return ['/', 1]
4221 if (c === '%') return ['%', 1]
4222 if (c === '<') return ['<', 1]
4223 if (c === '>') return ['>', 1]
4224 if (c === '&') return ['&', 1]
4225 if (c === '|') return ['|', 1]
4226 if (c === '^') return ['^', 1]
4227 if (c === '=') return ['=', 1]
4228 return null
4229}
4230
4231/** Precedence-climbing binary expression parser. */
4232function parseArithBinary(

Callers 1

parseArithBinaryFunction · 0.85

Calls 1

peekFunction · 0.70

Tested by

no test coverage detected