diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-01-25 21:54:22 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-01-25 21:54:22 +0000 |
commit | 476d22b59304cb6f5820c2644763a2ce43874a41 (patch) | |
tree | c8e8990a2197e33f6fe50a28a16714aafe982102 /libgo/go/regexp/syntax/regexp.go | |
parent | 422eaae5fe0038ad189b8fd28cfd6a7094d67ae1 (diff) | |
download | gcc-476d22b59304cb6f5820c2644763a2ce43874a41.tar.gz |
libgo: Update to weekly.2012-01-20.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@183540 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/regexp/syntax/regexp.go')
-rw-r--r-- | libgo/go/regexp/syntax/regexp.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libgo/go/regexp/syntax/regexp.go b/libgo/go/regexp/syntax/regexp.go index adcfe294495..668a07764a1 100644 --- a/libgo/go/regexp/syntax/regexp.go +++ b/libgo/go/regexp/syntax/regexp.go @@ -303,3 +303,19 @@ func (re *Regexp) MaxCap() int { } return m } + +// CapNames walks the regexp to find the names of capturing groups. +func (re *Regexp) CapNames() []string { + names := make([]string, re.MaxCap()+1) + re.capNames(names) + return names +} + +func (re *Regexp) capNames(names []string) { + if re.Op == OpCapture { + names[re.Cap] = re.Name + } + for _, sub := range re.Sub { + sub.capNames(names) + } +} |