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

Method atom

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

Source from the content-addressed store, hash-verified

501
502 @memoize
503 def atom(self) -> Optional[Plain]:
504 # atom: '(' ~ alts ')' | NAME | STRING
505 mark = self._mark()
506 cut = False
507 if (
508 (literal := self.expect('('))
509 and
510 (cut := True)
511 and
512 (alts := self.alts())
513 and
514 (literal_1 := self.expect(')'))
515 ):
516 return Group ( alts )
517 self._reset(mark)
518 if cut: return None
519 if (
520 (name := self.name())
521 ):
522 return NameLeaf ( name . string )
523 self._reset(mark)
524 if (
525 (string := self.string())
526 ):
527 return StringLeaf ( string . string )
528 self._reset(mark)
529 return None
530
531 @memoize
532 def action(self) -> Optional[str]:

Callers 3

forced_atomMethod · 0.95
lookaheadMethod · 0.95
itemMethod · 0.95

Calls 8

altsMethod · 0.95
GroupClass · 0.90
NameLeafClass · 0.90
StringLeafClass · 0.90
stringMethod · 0.80
expectMethod · 0.45
_resetMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected