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

Method scanPythonNamedBackref

syntax/parser.go:941–966  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

939}
940
941func (p *parser) scanPythonNamedBackref() (*RegexNode, error) {
942 p.moveRight(3)
943 if p.charsRight() == 0 {
944 return nil, p.getErr(ErrMalformedNameRef)
945 }
946
947 ch := p.rightChar(0)
948 if !p.isGroupNameStartChar(ch) {
949 return nil, p.getErr(ErrInvalidGroupName)
950 }
951
952 capname, err := p.scanCapname()
953 if err != nil {
954 return nil, err
955 }
956
957 if capname == "" || p.charsRight() == 0 || p.moveRightGetChar() != ')' {
958 return nil, p.getErr(ErrMalformedNameRef)
959 }
960
961 if !p.isCaptureName(capname) {
962 return nil, p.getErr(ErrUndefinedNameRef, capname)
963 }
964
965 return newRegexNodeM(NtRef, p.options, p.captureSlotFromName(capname)), nil
966}
967
968// scanGroupOpen scans chars following a '(' (not counting the '('), and returns
969// 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