예제 #1
0
        /// <summary>Stores the supplied arguments and capture information, returning the parsed expression.</summary>
        private RegexTree Init(string pattern, RegexOptions options, TimeSpan matchTimeout, [NotNull] ref CultureInfo?culture)
        {
            this.pattern         = pattern;
            roptions             = options;
            internalMatchTimeout = matchTimeout;
            culture ??= RegexParser.GetTargetCulture(options);

            // Parse the pattern.
            RegexTree tree = RegexParser.Parse(pattern, options, culture);

            // Store the relevant information, constructing the appropriate factory.
            capnames = tree.CaptureNameToNumberMapping;
            capslist = tree.CaptureNames;
            caps     = tree.CaptureNumberSparseMapping;
            capsize  = tree.CaptureCount;

            return(tree);
        }
예제 #2
0
파일: Regex.cs 프로젝트: wilfriedb/runtime
        internal Regex(string pattern, RegexOptions options, TimeSpan matchTimeout, CultureInfo?culture)
        {
            culture ??= RegexParser.GetTargetCulture(options);
            Init(pattern, options, matchTimeout, culture);

            if ((options & RegexOptions.NonBacktracking) != 0)
            {
                // If we're in non-backtracking mode, create the appropriate factory.
                factory = new SymbolicRegexRunnerFactory(_code, options, matchTimeout, culture);
                _code   = null;
            }
            else if (RuntimeFeature.IsDynamicCodeCompiled && UseOptionC())
            {
                // If the compile option is set and compilation is supported, then compile the code.
                factory = Compile(pattern, _code, options, matchTimeout != InfiniteMatchTimeout);
                _code   = null;
            }
        }
예제 #3
0
 protected internal override RegexRunner CreateInstance() =>
 // Create a new interpreter instance.
 new RegexInterpreter(_code, RegexParser.GetTargetCulture(_code.Options));