private void Init(string pattern, RegexOptions options, TimeSpan matchTimeout, CultureInfo culture)
{
ValidatePattern(pattern);
ValidateOptions(options);
ValidateMatchTimeout(matchTimeout);
this.pattern = pattern;
internalMatchTimeout = matchTimeout;
roptions = options;
// Parse the input
RegexTree tree = RegexParser.Parse(pattern, roptions, culture);
// Generate the RegexCode from the node tree. This is required for interpreting,
// and is used as input into RegexOptions.Compiled and RegexOptions.NonBacktracking.
_code = RegexWriter.Write(tree, culture);
if ((options & RegexOptions.NonBacktracking) != 0)
{
// NonBacktracking doesn't support captures (other than the implicit top-level capture).
capnames = null;
capslist = null;
caps = null;
capsize = 1;
}
else
{
capnames = tree.CapNames;
capslist = tree.CapsList;
caps = _code.Caps;
capsize = _code.CapSize;
}
}