|
|
|
@ -116,6 +116,13 @@ func newEscapedNode(c rune, inCharClass bool) (postfixNode, error) {
|
|
|
|
|
case 'v': // Vertical tab
|
|
|
|
|
toReturn.nodetype = CHARACTER
|
|
|
|
|
toReturn.contents = append(toReturn.contents, rune(11))
|
|
|
|
|
case '-': // Literal hyphen - only in character class
|
|
|
|
|
if inCharClass {
|
|
|
|
|
toReturn.nodetype = CHARACTER
|
|
|
|
|
toReturn.contents = append(toReturn.contents, '-')
|
|
|
|
|
} else {
|
|
|
|
|
return postfixNode{}, fmt.Errorf("Invalid escape character.")
|
|
|
|
|
}
|
|
|
|
|
default: // None of the above - append it as a regular character
|
|
|
|
|
if isNormalChar(c) { // Normal characters cannot be escaped
|
|
|
|
|
return postfixNode{}, fmt.Errorf("Invalid escape character.")
|
|
|
|
|