From 9a073aa514b108f4059f6e9d6bd77f49bba6510d Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Thu, 7 Nov 2024 15:55:37 -0500 Subject: [PATCH] Added node types for left and right parentheses --- postfixNode.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/postfixNode.go b/postfixNode.go index ca45271..24645bb 100644 --- a/postfixNode.go +++ b/postfixNode.go @@ -1,6 +1,8 @@ package main -import "slices" +import ( + "slices" +) type NodeType int @@ -13,6 +15,8 @@ const ( QUESTION PLUS ASSERTION + LPAREN + RPAREN ) var INFINITE_REPS int = -1 // Represents infinite reps eg. the end range in {5,} @@ -20,8 +24,8 @@ var INFINITE_REPS int = -1 // Represents infinite reps eg. the end range in {5,} 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 // How many times the node should be repeated - used with numeric specifiers - endReps int + 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 } // Creates a new escaped node - the given character is assumed to have been preceded by a backslash @@ -89,6 +93,10 @@ func newPostfixNode(contents ...rune) postfixNode { to_return.nodetype = CONCATENATE case '^', '$': to_return.nodetype = ASSERTION + case '(': + to_return.nodetype = LPAREN + case ')': + to_return.nodetype = RPAREN default: to_return.nodetype = CHARACTER }