MCPcopy Create free account
hub / github.com/sourcebot-dev/sourcebot / isInsideParenExpr

Function isInsideParenExpr

packages/queryLanguage/src/tokens.ts:424–433  ·  view source on GitHub ↗

* Checks if the parser stack indicates we're currently inside a ParenExpr.

(input: InputStream, stack: Stack)

Source from the content-addressed store, hash-verified

422 * Checks if the parser stack indicates we're currently inside a ParenExpr.
423 */
424function isInsideParenExpr(input: InputStream, stack: Stack): boolean {
425 // First try the standard parser state check
426 if (stack.canShift(closeParen)) {
427 return true;
428 }
429
430 // If that fails, use a heuristic: look backwards for unmatched '('
431 // This handles cases where the parser needs to reduce before shifting closeParen
432 return hasUnmatchedOpenParen(input);
433}
434
435/**
436 * External tokenizer for '(' - emits openParen only if there's a balanced ')'.

Callers 1

tokens.tsFile · 0.85

Calls 1

hasUnmatchedOpenParenFunction · 0.85

Tested by

no test coverage detected