MCPcopy Create free account
hub / github.com/dlclark/regexp2 / scanPythonNamedBackref

Method scanPythonNamedBackref

syntax/parser.go:947–972  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

945}
946
947func (p *parser) scanPythonNamedBackref() (*RegexNode, error) {
948 p.moveRight(3)
949 if p.charsRight() == 0 {
950 return nil, p.getErr(ErrMalformedNameRef)
951 }
952
953 ch := p.rightChar(0)
954 if !p.isGroupNameStartChar(ch) {
955 return nil, p.getErr(ErrInvalidGroupName)
956 }
957
958 capname, err := p.scanCapname()
959 if err != nil {
960 return nil, err
961 }
962
963 if capname == "" || p.charsRight() == 0 || p.moveRightGetChar() != ')' {
964 return nil, p.getErr(ErrMalformedNameRef)
965 }
966
967 if !p.isCaptureName(capname) {
968 return nil, p.getErr(ErrUndefinedNameRef, capname)
969 }
970
971 return newRegexNodeM(NtRef, p.options, p.captureSlotFromName(capname)), nil
972}
973
974// scanGroupOpen scans chars following a '(' (not counting the '('), and returns
975// a RegexNode for the type of group scanned, or nil if the group

Callers 1

scanRegexMethod · 0.95

Calls 10

moveRightMethod · 0.95
charsRightMethod · 0.95
getErrMethod · 0.95
rightCharMethod · 0.95
isGroupNameStartCharMethod · 0.95
scanCapnameMethod · 0.95
moveRightGetCharMethod · 0.95
isCaptureNameMethod · 0.95
captureSlotFromNameMethod · 0.95
newRegexNodeMFunction · 0.85

Tested by

no test coverage detected