ifre_runes[i]=='['&&(i==0||re_runes[i-1]!='\\'){// We do not touch things inside brackets, unless they are escaped
ifre_runes[i]=='['&&(i==0||re_runes[i-1]!='\\'){// We do not touch things inside brackets, unless they are escaped. Inside this block, the only task is to expand character ranges into their constituent characters.
re_postfix[len(re_postfix)-1]=LBRACKET// Replace the '[' character with LBRACKET. This allows for easier parsing of all characters (including opening and closing brackets) within the character class
invertMatch:=false
toAppend:=make([]rune,0)// Holds all the runes in the current character class
ifi<len(re_runes)-1&&re_runes[i+1]=='^'{// Inverting class - match everything NOT in brackets
// Replace the last character (which should have been ']', with RBRACKET
toAppend[len(toAppend)-1]=RBRACKET
ifinvertMatch{
toAppend=setDifference(dotChars(),toAppend)// Take the inverse of the set by getting the difference between it and all dot characters
toAppend=append(toAppend,RBRACKET)// Since RBRACKET doesn't exist in dotChars, it wouldn't have been return in setDifference. We manually append it here.
}
re_postfix=append(re_postfix,toAppend...)
}
if re_runes[i]=='{'&&(i>0&&re_runes[i-1]!='\\'){// We don't touch things inside braces, either
ifi<len(re_runes)&&re_runes[i]=='{'&&(i>0&&re_runes[i-1]!='\\'){// We don't touch things inside braces, either
if(re_runes[i]!='('&&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