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

Method target_atom

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

Source from the content-addressed store, hash-verified

586
587 @memoize
588 def target_atom(self) -> Optional[str]:
589 # target_atom: "{" ~ target_atoms? "}" | "[" ~ target_atoms? "]" | NAME "*" | NAME | NUMBER | STRING | FSTRING_START | FSTRING_MIDDLE | FSTRING_END | "?" | ":" | !"}" !"]" OP
590 mark = self._mark()
591 cut = False
592 if (
593 (literal := self.expect("{"))
594 and
595 (cut := True)
596 and
597 (atoms := self.target_atoms(),)
598 and
599 (literal_1 := self.expect("}"))
600 ):
601 return "{" + ( atoms or "" ) + "}"
602 self._reset(mark)
603 if cut: return None
604 cut = False
605 if (
606 (literal := self.expect("["))
607 and
608 (cut := True)
609 and
610 (atoms := self.target_atoms(),)
611 and
612 (literal_1 := self.expect("]"))
613 ):
614 return "[" + ( atoms or "" ) + "]"
615 self._reset(mark)
616 if cut: return None
617 if (
618 (name := self.name())
619 and
620 (literal := self.expect("*"))
621 ):
622 return name . string + "*"
623 self._reset(mark)
624 if (
625 (name := self.name())
626 ):
627 return name . string
628 self._reset(mark)
629 if (
630 (number := self.number())
631 ):
632 return number . string
633 self._reset(mark)
634 if (
635 (string := self.string())
636 ):
637 return string . string
638 self._reset(mark)
639 if (
640 (fstring_start := self.fstring_start())
641 ):
642 return fstring_start . string
643 self._reset(mark)
644 if (
645 (fstring_middle := self.fstring_middle())

Callers 1

target_atomsMethod · 0.95

Calls 11

target_atomsMethod · 0.95
numberMethod · 0.80
stringMethod · 0.80
fstring_startMethod · 0.80
fstring_middleMethod · 0.80
fstring_endMethod · 0.80
negative_lookaheadMethod · 0.80
expectMethod · 0.45
_resetMethod · 0.45
nameMethod · 0.45
opMethod · 0.45

Tested by

no test coverage detected