Updated more constants, so that they aren't exported
This commit is contained in:
@@ -452,19 +452,19 @@ func shuntingYard(re string, flags ...ReFlag) ([]postfixNode, error) {
|
||||
// Now we should filter that out.
|
||||
toAppend := postfixNode{nodetype: assertionNode, startReps: 1, endReps: 1}
|
||||
if regex[0] == '<' { // Lookbehind
|
||||
toAppend.lookaroundDir = LOOKBEHIND
|
||||
toAppend.lookaroundDir = lookbehind
|
||||
regex = regex[1:]
|
||||
} else if regex[0] == '=' || regex[0] == '!' {
|
||||
toAppend.lookaroundDir = LOOKAHEAD
|
||||
toAppend.lookaroundDir = lookahead
|
||||
} else {
|
||||
return nil, fmt.Errorf("invalid lookaround")
|
||||
}
|
||||
// Positive or negative
|
||||
if regex[0] == '=' { // Positive
|
||||
toAppend.lookaroundSign = POSITIVE
|
||||
toAppend.lookaroundSign = positive
|
||||
toAppend.contents = []rune(regex[1:])
|
||||
} else if regex[0] == '!' { // Negative
|
||||
toAppend.lookaroundSign = NEGATIVE
|
||||
toAppend.lookaroundSign = negative
|
||||
toAppend.contents = []rune(regex[1:])
|
||||
} else {
|
||||
return nil, fmt.Errorf("invalid lookaround")
|
||||
@@ -739,7 +739,7 @@ func shuntingYard(re string, flags ...ReFlag) ([]postfixNode, error) {
|
||||
return nil, fmt.Errorf("invalid start range for numeric specifier")
|
||||
}
|
||||
if len(endRange) == 0 { // Case 3 above
|
||||
endRangeNum = INFINITE_REPS
|
||||
endRangeNum = infinite_reps
|
||||
} else { // Case 2 above
|
||||
var err error
|
||||
endRangeNum, err = strconv.Atoi(string(endRange))
|
||||
@@ -881,19 +881,19 @@ func thompson(re []postfixNode) (Reg, error) {
|
||||
}
|
||||
} else { // Lookaround
|
||||
state.lookaroundRegex = string(c.contents)
|
||||
if c.lookaroundDir == LOOKAHEAD {
|
||||
if c.lookaroundSign == POSITIVE {
|
||||
if c.lookaroundDir == lookahead {
|
||||
if c.lookaroundSign == positive {
|
||||
state.assert = PLA
|
||||
}
|
||||
if c.lookaroundSign == NEGATIVE {
|
||||
if c.lookaroundSign == negative {
|
||||
state.assert = NLA
|
||||
}
|
||||
}
|
||||
if c.lookaroundDir == LOOKBEHIND {
|
||||
if c.lookaroundSign == POSITIVE {
|
||||
if c.lookaroundDir == lookbehind {
|
||||
if c.lookaroundSign == positive {
|
||||
state.assert = PLB
|
||||
}
|
||||
if c.lookaroundSign == NEGATIVE {
|
||||
if c.lookaroundSign == negative {
|
||||
state.assert = NLB
|
||||
}
|
||||
}
|
||||
@@ -1082,7 +1082,7 @@ func thompson(re []postfixNode) (Reg, error) {
|
||||
for i := 0; i < c.startReps; i++ { // Case 1
|
||||
stateToAdd = concatenate(stateToAdd, cloneState(state))
|
||||
}
|
||||
if c.endReps == INFINITE_REPS { // Case 3
|
||||
if c.endReps == infinite_reps { // Case 3
|
||||
s2, err := kleene(*state)
|
||||
if err != nil {
|
||||
return Reg{}, err
|
||||
|
@@ -23,12 +23,12 @@ const (
|
||||
)
|
||||
|
||||
// Helper constants for lookarounds
|
||||
const POSITIVE = 1
|
||||
const NEGATIVE = -1
|
||||
const LOOKAHEAD = 1
|
||||
const LOOKBEHIND = -1
|
||||
const positive = 1
|
||||
const negative = -1
|
||||
const lookahead = 1
|
||||
const lookbehind = -1
|
||||
|
||||
var INFINITE_REPS int = -1 // Represents infinite reps eg. the end range in {5,}
|
||||
var infinite_reps int = -1 // Represents infinite reps eg. the end range in {5,}
|
||||
// This represents a node in the postfix representation of the expression
|
||||
type postfixNode struct {
|
||||
nodetype NodeType
|
||||
|
Reference in New Issue
Block a user