Added a new class 'CHARCLASS', which represents a character class with some other postfixNodes in it. The 'except' field now contains a list of postfixNodes rather than runes
// This is a slice containing all escapable characters that have special meaning.
// Eg. \b is word boundary, \w is word character etc.
varescapedChars[]rune=[]rune("wWdDbBnaftrvsS0")
// This is a list of the possible node types
const(
CHARACTERNodeType=iota
CHARCLASS
PIPE
CONCATENATE
KLEENE
@ -25,13 +30,35 @@ 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
typepostfixNodestruct{
nodetypeNodeType
contents[]rune// Contents of the node
startRepsint// Minimum number of times the node should be repeated - used with numeric specifiers
endRepsint// Maximum number of times the node should be repeated - used with numeric specifiers
allCharsbool// 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.
lookaroundSignint// ONLY USED WHEN nodetype == ASSERTION. Whether we have a positive or negative lookaround.
lookaroundDirint// Lookbehind or lookahead
contents[]rune// Contents of the node
startRepsint// Minimum number of times the node should be repeated - used with numeric specifiers
endRepsint// Maximum number of times the node should be repeated - used with numeric specifiers
allCharsbool// Whether or not the current node represents all characters (eg. dot metacharacter)
except[]postfixNode// For inverted character classes, we match every unicode character _except_ a few. In this case, allChars is true and the exceptions are placed here.
lookaroundSignint// ONLY USED WHEN nodetype == ASSERTION. Whether we have a positive or negative lookaround.
lookaroundDirint// Lookbehind or lookahead
nodeContents[]postfixNode// ONLY USED WHEN nodetype == CHARCLASS. Holds all the nodes inside the given CHARCLASS node.
}
// Converts the given list of postfixNodes to one node of type CHARCLASS.
// Used to convert eg. 'a', 'b' and 'c' to '[abc]'.
// If the character class is negated, it returns a postfixNode of type CHARACTER.
// This node will behave like the dot metacharacter, but it has a longer list of runes that