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

Method consume_to

Tools/cases_generator/plexer.py:72–84  ·  view source on GitHub ↗
(self, end: str)

Source from the content-addressed store, hash-verified

70 )
71
72 def consume_to(self, end: str) -> list[Token]:
73 res: list[Token] = []
74 parens = 0
75 while tkn := self.next(raw=True):
76 res.append(tkn)
77 if tkn.kind == end and parens == 0:
78 return res
79 if tkn.kind == "LPAREN":
80 parens += 1
81 if tkn.kind == "RPAREN":
82 parens -= 1
83 raise self.make_syntax_error(
84 f"Expected {end!r} but reached EOF", tkn)
85
86 def extract_line(self, lineno: int) -> str:
87 # Return source line `lineno` (1-based)

Callers 4

stmtMethod · 0.80
if_stmtMethod · 0.80
for_stmtMethod · 0.80
while_stmtMethod · 0.80

Calls 3

nextMethod · 0.95
make_syntax_errorMethod · 0.95
appendMethod · 0.45

Tested by

no test coverage detected