diff options
author | Russ Cox <rsc@golang.org> | 2020-03-07 09:35:12 -0500 |
---|---|---|
committer | Emmanuel Odeke <emm.odeke@gmail.com> | 2020-04-17 22:12:02 +0000 |
commit | 4d9ecde30a77f4a4197b585b42cc2117607a8c40 (patch) | |
tree | 1d425aee67871deb85740ab0df7245a2ad931e8a /src/regexp | |
parent | 670cb9c37769f07fd8c2aac6270a9f2342d2b970 (diff) | |
download | go-4d9ecde30a77f4a4197b585b42cc2117607a8c40.tar.gz go-4d9ecde30a77f4a4197b585b42cc2117607a8c40.zip |
regexp/syntax: fix comment on p.literal and simplify
p.literal's doc comment said it returned a value but it doesn't.
While we're here, p.newLiteral is only called from p.literal,
so simplify the code by merging the two.
Change-Id: Ia357937a99f4e7473f0f1ec837113a39eaeb83d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/222659
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/regexp')
-rw-r--r-- | src/regexp/syntax/parse.go | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/regexp/syntax/parse.go b/src/regexp/syntax/parse.go index 8c6d43a706..7b4030935a 100644 --- a/src/regexp/syntax/parse.go +++ b/src/regexp/syntax/parse.go @@ -177,16 +177,16 @@ func (p *parser) maybeConcat(r rune, flags Flags) bool { return false // did not push r } -// newLiteral returns a new OpLiteral Regexp with the given flags -func (p *parser) newLiteral(r rune, flags Flags) *Regexp { +// literal pushes a literal regexp for the rune r on the stack. +func (p *parser) literal(r rune) { re := p.newRegexp(OpLiteral) - re.Flags = flags - if flags&FoldCase != 0 { + re.Flags = p.flags + if p.flags&FoldCase != 0 { r = minFoldRune(r) } re.Rune0[0] = r re.Rune = re.Rune0[:1] - return re + p.push(re) } // minFoldRune returns the minimum rune fold-equivalent to r. @@ -204,12 +204,6 @@ func minFoldRune(r rune) rune { return min } -// literal pushes a literal regexp for the rune r on the stack -// and returns that regexp. -func (p *parser) literal(r rune) { - p.push(p.newLiteral(r, p.flags)) -} - // op pushes a regexp with the given op onto the stack // and returns that regexp. func (p *parser) op(op Op) *Regexp { |