|
|
@ -156,7 +156,7 @@ func shuntingYard(re string) []postfixNode {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
c := re_postfix[i]
|
|
|
|
c := re_postfix[i]
|
|
|
|
if isNormalChar(c) {
|
|
|
|
if isNormalChar(c) {
|
|
|
|
if *caseInsensitiveFlag {
|
|
|
|
if caseInsensitiveFlag != nil && *caseInsensitiveFlag {
|
|
|
|
outQueue = append(outQueue, newPostfixNode(allCases(c)...))
|
|
|
|
outQueue = append(outQueue, newPostfixNode(allCases(c)...))
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
outQueue = append(outQueue, newPostfixNode(c))
|
|
|
|
outQueue = append(outQueue, newPostfixNode(c))
|
|
|
@ -204,9 +204,6 @@ func shuntingYard(re string) []postfixNode {
|
|
|
|
regex += string(re_postfix[i])
|
|
|
|
regex += string(re_postfix[i])
|
|
|
|
i++
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if regex[len(regex)-1] == ')' { // The closing paren would have also been added. Let's remove that.
|
|
|
|
|
|
|
|
regex = regex[:len(regex)-1]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(regex) <= 1 { // Nothing in regex - panic
|
|
|
|
if len(regex) <= 1 { // Nothing in regex - panic
|
|
|
|
panic("Invalid lookaround. (too short?)")
|
|
|
|
panic("Invalid lookaround. (too short?)")
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -574,13 +571,16 @@ func main() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Assuming err != nil
|
|
|
|
// Assuming err != nil
|
|
|
|
if err == io.EOF {
|
|
|
|
if err == io.EOF {
|
|
|
|
|
|
|
|
if len(temp) > 0 {
|
|
|
|
|
|
|
|
test_str += temp // Add the last line (if it is non-empty)
|
|
|
|
|
|
|
|
}
|
|
|
|
linesRead = true
|
|
|
|
linesRead = true
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
panic(err)
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
test_runes = []rune(test_str)
|
|
|
|
test_runes = []rune(test_str)
|
|
|
|
matchIndices := findAllMatches(startState, []rune(test_runes))
|
|
|
|
matchIndices := findAllMatches(startState, test_runes)
|
|
|
|
if *printMatchesFlag {
|
|
|
|
if *printMatchesFlag {
|
|
|
|
for _, idx := range matchIndices {
|
|
|
|
for _, idx := range matchIndices {
|
|
|
|
fmt.Printf("%s\n", idx.toString())
|
|
|
|
fmt.Printf("%s\n", idx.toString())
|
|
|
|