MCPcopy Create free account
hub / github.com/claude-code-best/claude-code / scanArithOp

Function scanArithOp

src/utils/bash/bashParser.ts:4187–4225  ·  view source on GitHub ↗

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

(P: ParseState)

Source from the content-addressed store, hash-verified

4185
4186/** Scan next arithmetic binary operator; returns [text, length] or null. */
4187function scanArithOp(P: ParseState): [string, number] | null {
4188 const c = peek(P.L)
4189 const c1 = peek(P.L, 1)
4190 const c2 = peek(P.L, 2)
4191 // 3-char: <<= >>=
4192 if (c === '<' && c1 === '<' && c2 === '=') return ['<<=', 3]
4193 if (c === '>' && c1 === '>' && c2 === '=') return ['>>=', 3]
4194 // 2-char
4195 if (c === '*' && c1 === '*') return ['**', 2]
4196 if (c === '<' && c1 === '<') return ['<<', 2]
4197 if (c === '>' && c1 === '>') return ['>>', 2]
4198 if (c === '=' && c1 === '=') return ['==', 2]
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 // 1-char — but NOT ++ -- (those are pre/postfix)
4213 if (c === '+' && c1 !== '+') return ['+', 1]
4214 if (c === '-' && c1 !== '-') return ['-', 1]
4215 if (c === '*') return ['*', 1]
4216 if (c === '/') return ['/', 1]
4217 if (c === '%') return ['%', 1]
4218 if (c === '<') 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 return null
4225}
4226
4227/** Precedence-climbing binary expression parser. */
4228function parseArithBinary(

Callers 1

parseArithBinaryFunction · 0.85

Calls 1

peekFunction · 0.70

Tested by

no test coverage detected