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

Method lookahead

Tools/peg_generator/pegen/grammar_parser.py:414–444  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

412
413 @memoize
414 def lookahead(self) -> Optional[LookaheadOrCut]:
415 # lookahead: '&' ~ atom | '!' ~ atom | '~'
416 mark = self._mark()
417 cut = False
418 if (
419 (literal := self.expect('&'))
420 and
421 (cut := True)
422 and
423 (atom := self.atom())
424 ):
425 return PositiveLookahead ( atom )
426 self._reset(mark)
427 if cut: return None
428 cut = False
429 if (
430 (literal := self.expect('!'))
431 and
432 (cut := True)
433 and
434 (atom := self.atom())
435 ):
436 return NegativeLookahead ( atom )
437 self._reset(mark)
438 if cut: return None
439 if (
440 (literal := self.expect('~'))
441 ):
442 return Cut ( )
443 self._reset(mark)
444 return None
445
446 @memoize
447 def item(self) -> Optional[Item]:

Callers 1

named_itemMethod · 0.95

Calls 6

atomMethod · 0.95
PositiveLookaheadClass · 0.90
NegativeLookaheadClass · 0.90
CutClass · 0.90
expectMethod · 0.45
_resetMethod · 0.45

Tested by

no test coverage detected