|
|
|
@ -831,10 +831,10 @@ func thompson(re []postfixNode) (Reg, error) {
|
|
|
|
|
// For each postfixNode in node.except, extract the contents of the postfixNode. Concatenate them all,
|
|
|
|
|
// and them to the state's _content_. As mentioned above, if the exception has exceptions, then we can match
|
|
|
|
|
// those.
|
|
|
|
|
nodeExceptChars := slices.Concat(Map(node.except, func(node postfixNode) []rune {
|
|
|
|
|
nodeExceptChars := slices.Concat(funcMap(node.except, func(node postfixNode) []rune {
|
|
|
|
|
nodeContents := node.contents
|
|
|
|
|
if caseInsensitive {
|
|
|
|
|
nodeContents = slices.Concat(Map(nodeContents, func(r rune) []rune {
|
|
|
|
|
nodeContents = slices.Concat(funcMap(nodeContents, func(r rune) []rune {
|
|
|
|
|
return allCases(r, caseInsensitive)
|
|
|
|
|
})...)
|
|
|
|
|
}
|
|
|
|
@ -844,7 +844,7 @@ func thompson(re []postfixNode) (Reg, error) {
|
|
|
|
|
} else {
|
|
|
|
|
charsToAdd := node.contents
|
|
|
|
|
if caseInsensitive {
|
|
|
|
|
charsToAdd = slices.Concat(Map(charsToAdd, func(r rune) []rune {
|
|
|
|
|
charsToAdd = slices.Concat(funcMap(charsToAdd, func(r rune) []rune {
|
|
|
|
|
return allCases(r, caseInsensitive)
|
|
|
|
|
})...)
|
|
|
|
|
}
|
|
|
|
@ -857,7 +857,7 @@ func thompson(re []postfixNode) (Reg, error) {
|
|
|
|
|
// convert back to stateContents.
|
|
|
|
|
runesToAdd := c.contents
|
|
|
|
|
if caseInsensitive {
|
|
|
|
|
runesToAdd = slices.Concat(Map(runesToAdd, func(r rune) []rune {
|
|
|
|
|
runesToAdd = slices.Concat(funcMap(runesToAdd, func(r rune) []rune {
|
|
|
|
|
return allCases(r, caseInsensitive)
|
|
|
|
|
})...)
|
|
|
|
|
}
|
|
|
|
@ -971,18 +971,18 @@ func thompson(re []postfixNode) (Reg, error) {
|
|
|
|
|
}
|
|
|
|
|
if c.nodetype == CHARCLASS { // A Character class consists of all the nodes in it, alternated
|
|
|
|
|
// Map the list of nodes to a list of states, each state containing the contents of a specific node
|
|
|
|
|
states := Map(c.nodeContents, func(node postfixNode) *State {
|
|
|
|
|
states := funcMap(c.nodeContents, func(node postfixNode) *State {
|
|
|
|
|
s := newState()
|
|
|
|
|
nodeContents := node.contents
|
|
|
|
|
if caseInsensitive {
|
|
|
|
|
nodeContents = slices.Concat(Map(nodeContents, func(r rune) []rune {
|
|
|
|
|
nodeContents = slices.Concat(funcMap(nodeContents, func(r rune) []rune {
|
|
|
|
|
return allCases(r, caseInsensitive)
|
|
|
|
|
})...)
|
|
|
|
|
}
|
|
|
|
|
s.content = rune2Contents(nodeContents)
|
|
|
|
|
if len(node.except) > 0 {
|
|
|
|
|
s.allChars = true
|
|
|
|
|
s.except = slices.Concat(Map(node.except, func(n postfixNode) []rune {
|
|
|
|
|
s.except = slices.Concat(funcMap(node.except, func(n postfixNode) []rune {
|
|
|
|
|
return n.contents
|
|
|
|
|
})...)
|
|
|
|
|
}
|
|
|
|
|