예제 #1
0
    /*
     * This static call constructs a RegexTree from a regular expression
     * pattern string and an option string.
     *
     * The method creates, drives, and drops a parser instance.
     */
    internal static RegexTree Parse(string re, RegexOptions op)
    {
        var culture = op.HasAnyFlags(RegexOptions.CultureInvariant)
            ? CultureInfo.InvariantCulture
            : CultureInfo.CurrentCulture;
        var p = new RegexParser(culture)
        {
            _options = op
        };

        p.SetPattern(re);
        p.Reset(op);
        var root = p.ScanRegex();

        return(new RegexTree(root, op));
    }