1
0
mirror of https://github.com/golang/go synced 2024-11-15 11:40:35 -07:00

[release-branch.go1] regexp/syntax: unexport ErrUnexpectedParen

««« backport b4cdcec897fb
regexp/syntax: unexport ErrUnexpectedParen

This new error is the only API change in the current draft of
Go 1.0.2 CLs. I'd like to include the CL that introduced it,
because it replaces a mysterious 'internal error' with a
useful error message, but I don't want any API changes,
so unexport the error constant for now. It can be
re-exported for Go 1.1.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6294055

»»»
This commit is contained in:
Russ Cox 2012-06-13 16:24:55 -04:00
parent ef902f8c8e
commit e819613d08

View File

@ -46,9 +46,11 @@ const (
ErrMissingParen ErrorCode = "missing closing )" ErrMissingParen ErrorCode = "missing closing )"
ErrMissingRepeatArgument ErrorCode = "missing argument to repetition operator" ErrMissingRepeatArgument ErrorCode = "missing argument to repetition operator"
ErrTrailingBackslash ErrorCode = "trailing backslash at end of expression" ErrTrailingBackslash ErrorCode = "trailing backslash at end of expression"
ErrUnexpectedParen ErrorCode = "unexpected )"
) )
// TODO: Export for Go 1.1.
const errUnexpectedParen ErrorCode = "unexpected )"
func (e ErrorCode) String() string { func (e ErrorCode) String() string {
return string(e) return string(e)
} }
@ -1169,13 +1171,13 @@ func (p *parser) parseRightParen() error {
n := len(p.stack) n := len(p.stack)
if n < 2 { if n < 2 {
return &Error{ErrUnexpectedParen, p.wholeRegexp} return &Error{errUnexpectedParen, p.wholeRegexp}
} }
re1 := p.stack[n-1] re1 := p.stack[n-1]
re2 := p.stack[n-2] re2 := p.stack[n-2]
p.stack = p.stack[:n-2] p.stack = p.stack[:n-2]
if re2.Op != opLeftParen { if re2.Op != opLeftParen {
return &Error{ErrUnexpectedParen, p.wholeRegexp} return &Error{errUnexpectedParen, p.wholeRegexp}
} }
// Restore flags at time of paren. // Restore flags at time of paren.
p.flags = re2.Flags p.flags = re2.Flags