diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-01-25 21:54:22 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-01-25 21:54:22 +0000 |
commit | af92e385667da3fc91ac7f9f0867a56c111110b8 (patch) | |
tree | c8e8990a2197e33f6fe50a28a16714aafe982102 /libgo/go/regexp/syntax | |
parent | df1304ee03f41aed179545d1e8b4684cfd22bbdf (diff) | |
download | gcc-af92e385667da3fc91ac7f9f0867a56c111110b8.zip gcc-af92e385667da3fc91ac7f9f0867a56c111110b8.tar.gz gcc-af92e385667da3fc91ac7f9f0867a56c111110b8.tar.bz2 |
libgo: Update to weekly.2012-01-20.
From-SVN: r183540
Diffstat (limited to 'libgo/go/regexp/syntax')
-rw-r--r-- | libgo/go/regexp/syntax/compile.go | 4 | ||||
-rw-r--r-- | libgo/go/regexp/syntax/prog.go | 4 | ||||
-rw-r--r-- | libgo/go/regexp/syntax/prog_test.go | 4 | ||||
-rw-r--r-- | libgo/go/regexp/syntax/regexp.go | 16 |
4 files changed, 28 insertions, 0 deletions
diff --git a/libgo/go/regexp/syntax/compile.go b/libgo/go/regexp/syntax/compile.go index 21c6565..41955bf 100644 --- a/libgo/go/regexp/syntax/compile.go +++ b/libgo/go/regexp/syntax/compile.go @@ -1,3 +1,7 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package syntax import "unicode" diff --git a/libgo/go/regexp/syntax/prog.go b/libgo/go/regexp/syntax/prog.go index 84ebb83..902d3b3 100644 --- a/libgo/go/regexp/syntax/prog.go +++ b/libgo/go/regexp/syntax/prog.go @@ -1,3 +1,7 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package syntax import ( diff --git a/libgo/go/regexp/syntax/prog_test.go b/libgo/go/regexp/syntax/prog_test.go index 70959f6..0d96507 100644 --- a/libgo/go/regexp/syntax/prog_test.go +++ b/libgo/go/regexp/syntax/prog_test.go @@ -1,3 +1,7 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package syntax_test import ( diff --git a/libgo/go/regexp/syntax/regexp.go b/libgo/go/regexp/syntax/regexp.go index adcfe29..668a077 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) + } +} |