libgo: Update to weekly.2012-01-20.
From-SVN: r183540
This commit is contained in:
parent
df1304ee03
commit
af92e38566
198 changed files with 5123 additions and 1951 deletions
|
@ -1,3 +1,4 @@
|
|||
// Copyright 2009 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.
|
||||
|
||||
|
@ -85,6 +86,7 @@ type Regexp struct {
|
|||
prefixRune rune // first rune in prefix
|
||||
cond syntax.EmptyOp // empty-width conditions required at start of match
|
||||
numSubexp int
|
||||
subexpNames []string
|
||||
longest bool
|
||||
|
||||
// cache of machines for running regexp
|
||||
|
@ -140,17 +142,20 @@ func compile(expr string, mode syntax.Flags, longest bool) (*Regexp, error) {
|
|||
return nil, err
|
||||
}
|
||||
maxCap := re.MaxCap()
|
||||
capNames := re.CapNames()
|
||||
|
||||
re = re.Simplify()
|
||||
prog, err := syntax.Compile(re)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
regexp := &Regexp{
|
||||
expr: expr,
|
||||
prog: prog,
|
||||
numSubexp: maxCap,
|
||||
cond: prog.StartCond(),
|
||||
longest: longest,
|
||||
expr: expr,
|
||||
prog: prog,
|
||||
numSubexp: maxCap,
|
||||
subexpNames: capNames,
|
||||
cond: prog.StartCond(),
|
||||
longest: longest,
|
||||
}
|
||||
regexp.prefix, regexp.prefixComplete = prog.Prefix()
|
||||
if regexp.prefix != "" {
|
||||
|
@ -223,6 +228,15 @@ func (re *Regexp) NumSubexp() int {
|
|||
return re.numSubexp
|
||||
}
|
||||
|
||||
// SubexpNames returns the names of the parenthesized subexpressions
|
||||
// in this Regexp. The name for the first sub-expression is names[1],
|
||||
// so that if m is a match slice, the name for m[i] is SubexpNames()[i].
|
||||
// Since the Regexp as a whole cannot be named, names[0] is always
|
||||
// the empty string. The slice should not be modified.
|
||||
func (re *Regexp) SubexpNames() []string {
|
||||
return re.subexpNames
|
||||
}
|
||||
|
||||
const endOfText rune = -1
|
||||
|
||||
// input abstracts different representations of the input text. It provides
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue