From e882f41400e21b67cb973bf28d45bd4e6ddf8df4 Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Wed, 20 Nov 2024 09:41:32 -0500 Subject: [PATCH] Added fields to denote all the characters that an 'allChars' postfixNode _shouldn't_ represent (useful for inverting character classes) --- postfixNode.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/postfixNode.go b/postfixNode.go index 3aea8b8..78fbc5b 100644 --- a/postfixNode.go +++ b/postfixNode.go @@ -26,7 +26,8 @@ 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 + allChars bool // Whether or not the current node represents all characters (eg. dot metacharacter) + except []rune // For inverted character classes, we match every unicode character _except_ a few. In this case, allChars is true and the exceptions are placed here. } // Creates a new escaped node - the given character is assumed to have been preceded by a backslash @@ -115,7 +116,7 @@ func newPostfixDotNode() postfixNode { toReturn.startReps = 1 toReturn.endReps = 1 toReturn.nodetype = CHARACTER - toReturn.isDot = true + toReturn.allChars = true toReturn.contents = []rune{ANY_CHAR} return toReturn }