RegexCodeFromRegexTree() private method

The top level RegexCode generator. It does a depth-first walk through the tree and calls EmitFragment to emits code before and after each child of an interior node, and at each leaf. It runs two passes, first to count the size of the generated code, and second to generate the code. We should time it against the alternative, which is to just generate the code and grow the array as we go.
private RegexCodeFromRegexTree ( RegexTree tree ) : RegexCode
tree RegexTree
return RegexCode
Example #1
0
        // This is the only function that should be called from outside.
        // It takes a RegexTree and creates a corresponding RegexCode.
        internal static RegexCode Write(RegexTree t) {
            RegexWriter w = new RegexWriter();
            RegexCode retval = w.RegexCodeFromRegexTree(t);
#if DBG
            if (t.Debug) {
                retval.Dump();
            }
#endif
            return retval;
        }
Example #2
0
        /*
         * This is the only function that should be called from outside.
         * It takes a RegexTree and creates a corresponding RegexCode.
         */
        internal static RegexCode Write(RegexTree t)
        {
            RegexWriter w      = new RegexWriter();
            RegexCode   retval = w.RegexCodeFromRegexTree(t);

#if DBG
            if (t.Debug)
            {
                retval.Dump();
            }
#endif
            return(retval);
        }
Example #3
0
        /// <summary>
        /// This is the only function that should be called from outside.
        /// It takes a RegexTree and creates a corresponding RegexCode.
        /// </summary>
        internal static RegexCode Write(RegexTree t)
        {
            Span <int> emittedSpan  = stackalloc int[EmittedSize];
            Span <int> intStackSpan = stackalloc int[IntStackSize];
            var        w            = new RegexWriter(emittedSpan, intStackSpan);

            RegexCode retval = w.RegexCodeFromRegexTree(t);

#if DEBUG
            if (t.Debug)
            {
                t.Dump();
                retval.Dump();
            }
#endif
            return(retval);
        }
Example #4
0
        /// <summary>
        /// This is the only function that should be called from outside.
        /// It takes a RegexTree and creates a corresponding RegexCode.
        /// </summary>
        public static RegexCode Write(RegexTree tree)
        {
            Span <int> emittedSpan  = stackalloc int[EmittedSize];
            Span <int> intStackSpan = stackalloc int[IntStackSize];

            var       writer = new RegexWriter(emittedSpan, intStackSpan);
            RegexCode code   = writer.RegexCodeFromRegexTree(tree);

            writer.Dispose();

#if DEBUG
            if (tree.Debug)
            {
                tree.Dump();
                code.Dump();
            }
#endif

            return(code);
        }
Example #5
0
        internal static RegexCode Write(RegexTree t)
        {
            RegexWriter writer = new RegexWriter();

            return(writer.RegexCodeFromRegexTree(t));
        }
Example #6
0
 internal static RegexCode Write(RegexTree t)
 {
     RegexWriter writer = new RegexWriter();
     return writer.RegexCodeFromRegexTree(t);
 }