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

Method expect

Tools/peg_generator/pegen/parser.py:261–273  ·  view source on GitHub ↗
(self, type: str)

Source from the content-addressed store, hash-verified

259
260 @memoize
261 def expect(self, type: str) -> tokenize.TokenInfo | None:
262 tok = self._tokenizer.peek()
263 if tok.string == type:
264 return self._tokenizer.getnext()
265 if type in exact_token_types:
266 if tok.type == exact_token_types[type]:
267 return self._tokenizer.getnext()
268 if type in token.__dict__:
269 if tok.type == token.__dict__[type]:
270 return self._tokenizer.getnext()
271 if tok.type == token.OP and tok.string == type:
272 return self._tokenizer.getnext()
273 return None
274
275 def expect_forced(self, res: Any, expectation: str) -> tokenize.TokenInfo | None:
276 if res is None:

Callers 15

label_defMethod · 0.95
inst_headerMethod · 0.95
io_effectMethod · 0.95
inputsMethod · 0.95
outputsMethod · 0.95
cache_effectMethod · 0.95
stack_effectMethod · 0.95
opMethod · 0.95
macro_defMethod · 0.95
uopsMethod · 0.95
uopMethod · 0.95
family_defMethod · 0.95

Calls 2

getnextMethod · 0.80
peekMethod · 0.45

Tested by

no test coverage detected