Compare commits
2 Commits
ccb82f781b
...
435588274c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
435588274c | ||
|
|
a347ebacc4 |
@@ -82,6 +82,7 @@ func shuntingYard(re string, flags ...ReFlag) ([]postfixNode, error) {
|
||||
// Also check for non-capturing groups. The LPAREN of a non-capturing group looks like this: '(?:'
|
||||
// I take this out, and put in a special character - NONCAPLPAREN_CHAR.
|
||||
//
|
||||
// Another check is made for unescaped brackets - opening brackets are replaced with LBRACKET and closing brackets are replaced with RBRACKET.
|
||||
// Finally, check for escaped backslashes. Replace these with the BACKSLASH metacharacter. Later, in thompson(),
|
||||
// these will be converted back. This avoids confusiuon in detecting whether a character is escaped eg. detecting
|
||||
// whether '\\[a]' has an escaped opening bracket (it doesn't).
|
||||
@@ -122,6 +123,9 @@ func shuntingYard(re string, flags ...ReFlag) ([]postfixNode, error) {
|
||||
} else if c == '\\' && i < len(re_runes_orig)-1 && re_runes_orig[i+1] == '\\' { // Escaped backslash
|
||||
re_runes = append(re_runes, ESC_BACKSLASH)
|
||||
i++
|
||||
} else if c == '[' && (i == 0 || re_runes_orig[i-1] != '\\')
|
||||
|
||||
|
||||
} else {
|
||||
re_runes = append(re_runes, c)
|
||||
}
|
||||
|
||||
@@ -236,6 +236,7 @@ var reTests = []struct {
|
||||
{`abc)`, nil, `-`, nil},
|
||||
{`(abc`, nil, `-`, nil},
|
||||
{`a]`, nil, `a]`, []Group{{0, 2}}},
|
||||
{`a[]]b`, nil, `a]b`, []Group{{0, 3}}},
|
||||
|
||||
// Todo - add numeric range tests
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user