From 21b2d5a2a92da2b78e9e95db34cf26c82d3aee16 Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Fri, 22 Nov 2024 00:12:22 -0500 Subject: [PATCH] Added lookaround-related fields to postfixNode struct --- postfixNode.go | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/postfixNode.go b/postfixNode.go index 2a54bc9..561b7a6 100644 --- a/postfixNode.go +++ b/postfixNode.go @@ -15,15 +15,23 @@ const ( RPAREN ) +// Helper constants for lookarounds +const POSITIVE = 1 +const NEGATIVE = -1 +const LOOKAHEAD = 1 +const LOOKBEHIND = -1 + var INFINITE_REPS int = -1 // Represents infinite reps eg. the end range in {5,} // This represents a node in the postfix representation of the expression type postfixNode struct { - nodetype NodeType - 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 - 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. + nodetype NodeType + contents []rune // Contents of the node + 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 + 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. + lookaroundSign int // ONLY USED WHEN nodetype == ASSERTION. Whether we have a positive or negative lookaround. + lookaroundDir int // Lookbehind or lookahead } // Creates a new escaped node - the given character is assumed to have been preceded by a backslash