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

Method scanPythonNamedBackref

syntax/parser.go:1090–1115  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1088}
1089
1090func (p *parser) scanPythonNamedBackref() (*RegexNode, error) {
1091 p.moveRight(3)
1092 if p.charsRight() == 0 {
1093 return nil, p.getErr(ErrMalformedNameRef)
1094 }
1095
1096 ch := p.rightChar(0)
1097 if !p.isGroupNameStartChar(ch) {
1098 return nil, p.getErr(ErrInvalidGroupName)
1099 }
1100
1101 capname, err := p.scanCapname()
1102 if err != nil {
1103 return nil, err
1104 }
1105
1106 if capname == "" || p.charsRight() == 0 || p.moveRightGetChar() != ')' {
1107 return nil, p.getErr(ErrMalformedNameRef)
1108 }
1109
1110 if !p.isCaptureName(capname) {
1111 return nil, p.getErr(ErrUndefinedNameRef, capname)
1112 }
1113
1114 return p.namedReference(capname), nil
1115}
1116
1117// scanGroupOpen scans chars following a '(' (not counting the '('), and returns
1118// a RegexNode for the type of group scanned, or nil if the group

Callers 1

scanRegexMethod · 0.95

Calls 9

moveRightMethod · 0.95
charsRightMethod · 0.95
getErrMethod · 0.95
rightCharMethod · 0.95
isGroupNameStartCharMethod · 0.95
scanCapnameMethod · 0.95
moveRightGetCharMethod · 0.95
isCaptureNameMethod · 0.95
namedReferenceMethod · 0.95

Tested by

no test coverage detected