Added field to Reg, denoting if we prefer longest match (POSIX style) or not (perl style)
This commit is contained in:
@@ -14,9 +14,10 @@ var notDotChars []rune
|
||||
// the startState of the NFA representation of the regex, and the number of capturing
|
||||
// groups in the regex. It also contains the expression string.
|
||||
type Reg struct {
|
||||
start *nfaState
|
||||
numGroups int
|
||||
str string
|
||||
start *nfaState
|
||||
numGroups int
|
||||
str string
|
||||
preferLongest bool
|
||||
}
|
||||
|
||||
// NumSubexp returns the number of sub-expressions in the given [Reg]. This is equivalent
|
||||
@@ -30,6 +31,10 @@ func (r Reg) String() string {
|
||||
return r.str
|
||||
}
|
||||
|
||||
func (r Reg) Longest() {
|
||||
r.preferLongest = true
|
||||
}
|
||||
|
||||
const concatRune rune = 0xF0001
|
||||
|
||||
// Flags for shuntingYard - control its behavior
|
||||
@@ -1135,7 +1140,7 @@ func thompson(re []postfixNode) (Reg, error) {
|
||||
concatenate(nfa[0], &lastState)
|
||||
|
||||
// The string is empty here, because we add it in Compile()
|
||||
return Reg{nfa[0], numGroups, ""}, nil
|
||||
return Reg{nfa[0], numGroups, "", false}, nil
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user