Added unicode support to dot metacharacter - it now matches _any_ unicode character (almost)

This commit is contained in:
2024-11-18 16:44:43 -05:00
parent 8a1f1dc621
commit c56d81a335
4 changed files with 35 additions and 5 deletions

View File

@@ -26,6 +26,7 @@ type postfixNode struct {
contents []rune // Contents of the node - the length of this would only be >1 if the node represents a character class
startReps int // Minimum number of times the node should be repeated - used with numeric specifiers
endReps int // Maximum number of times the node should be repeated - used with numeric specifiers
isDot bool // Whether or not the current node represents a 'dot' metacharacter
}
// Creates a new escaped node - the given character is assumed to have been preceded by a backslash
@@ -105,9 +106,22 @@ func newPostfixNode(contents ...rune) postfixNode {
return to_return
}
// Creates and returns a postfixNode representing the 'dot' metacharacter.
func newPostfixDotNode() postfixNode {
toReturn := postfixNode{}
toReturn.startReps = 1
toReturn.endReps = 1
toReturn.nodetype = CHARACTER
toReturn.isDot = true
toReturn.contents = []rune{ANY_CHAR}
return toReturn
}
// Creates a character node, regardless of the contents
func newPostfixCharNode(contents ...rune) postfixNode {
toReturn := postfixNode{}
toReturn.startReps = 1
toReturn.endReps = 1
toReturn.nodetype = CHARACTER
toReturn.contents = append(toReturn.contents, contents...)
return toReturn