MCPcopy Index your code
hub / github.com/python/cpython / expression

Method expression

Tools/cases_generator/parsing.py:479–493  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

477
478 @contextual
479 def expression(self) -> Expression | None:
480 tokens: list[lx.Token] = []
481 level = 1
482 while tkn := self.peek():
483 if tkn.kind in (lx.LBRACKET, lx.LPAREN):
484 level += 1
485 elif tkn.kind in (lx.RBRACKET, lx.RPAREN):
486 level -= 1
487 if level == 0:
488 break
489 tokens.append(tkn)
490 self.next()
491 if not tokens:
492 return None
493 return Expression(lx.to_text(tokens).strip())
494
495 # def ops(self) -> list[OpName] | None:
496 # if op := self.op():

Callers 1

stack_effectMethod · 0.95

Calls 6

ExpressionClass · 0.85
to_textMethod · 0.80
peekMethod · 0.45
appendMethod · 0.45
nextMethod · 0.45
stripMethod · 0.45

Tested by

no test coverage detected