ifi<len(re_runes)&&re_runes[i]=='('&&(i==0||re_runes[i-1]!='\\')&&(i<len(re_runes)-1&&re_runes[i+1]=='?'){// Unescaped open parentheses followed by question mark = lokaround. Don't mess with it.
re_postfix=append(re_postfix,NONCAPLPAREN_CHAR)
i+=3
}
ifi<len(re_runes)&&re_runes[i]=='('&&(i==0||re_runes[i-1]!='\\')&&(i<len(re_runes)-2&&re_runes[i+1]=='?'&&slices.Contains([]rune{'=','!','<'},re_runes[i+2])){// Unescaped open parentheses followed by question mark then '<', '!' or '=' => lokaround. Don't mess with it.
ifi<len(re_runes)&&(re_runes[i]!='('&&re_runes[i]!=NONCAPLPAREN_CHAR&&re_runes[i]!='|'&&re_runes[i]!='\\')||(i>0&&re_runes[i-1]=='\\'){// Every character should be concatenated if it is escaped
ifi<len(re_runes)&&(re_runes[i]!='('&&re_runes[i]!='|'&&re_runes[i]!='\\')||(i>0&&re_runes[i-1]=='\\'){// Every character should be concatenated if it is escaped
transitionsmap[int][]*State// Transitions to different states (maps a character (int representation) to a _list of states. This is useful if one character can lead multiple states eg. ab|aa)
transitionsmap[int][]*State// Transitions to different states (maps a character (int representation) to a _list of states. This is useful if one character can lead multiple states eg. ab|aa)
isKleenebool// Identifies whether current node is a 0-state representing Kleene star
isKleenebool// Identifies whether current node is a 0-state representing Kleene star
assertassertType// Type of assertion of current node - NONE means that the node doesn't assert anything
assertassertType// Type of assertion of current node - NONE means that the node doesn't assert anything
zeroMatchFoundbool// Whether or not the state has been used for a zero-length match - only relevant for zero states
allCharsbool// Whether or not the state represents all characters (eg. a 'dot' metacharacter). A 'dot' node doesn't store any contents directly, as it would take up too much space
allCharsbool// Whether or not the state represents all characters (eg. a 'dot' metacharacter). A 'dot' node doesn't store any contents directly, as it would take up too much space
except[]rune// Only valid if allChars is true - match all characters _except_ the ones in this block. Useful for inverting character classes.
except[]rune// Only valid if allChars is true - match all characters _except_ the ones in this block. Useful for inverting character classes.
lookaroundRegexstring// Only for lookaround states - Contents of the regex that the lookaround state holds
lookaroundRegexstring// Only for lookaround states - Contents of the regex that the lookaround state holds
@ -36,9 +37,7 @@ type State struct {
groupBeginbool// Whether or not the node starts a capturing group
groupBeginbool// Whether or not the node starts a capturing group
groupEndbool// Whether or not the node ends a capturing group
groupEndbool// Whether or not the node ends a capturing group
groupNumint// Which capturing group the node starts / ends
groupNumint// Which capturing group the node starts / ends
// The following properties depend on the current match - I should think about resetting them for every match.
threadGroups[]Group// Assuming that a state is part of a 'thread' in the matching process, this array stores the indices of capturing groups in the current thread. As matches are found for this state, its groups will be copied over.
zeroMatchFoundbool// Whether or not the state has been used for a zero-length match - only relevant for zero states
threadGroups[]Group// Assuming that a state is part of a 'thread' in the matching process, this array stores the indices of capturing groups in the current thread. As matches are found for this state, its groups will be copied over.
ifs.assert==PLA||s.assert==NLA{// Lookahead - return true (or false) if at least one match starts at 0. Zero is used because the test-string _starts_ from idx.
ifs.assert==PLA||s.assert==NLA{// Lookahead - return true (or false) if at least one match starts at the current index