Exemple #1
0
        /*-----------------------------------------------------------*/
        /*--- General Methods ---------------------------------------*/
        /*-----------------------------------------------------------*/

        /// <summary>Convert to a string.
        /// </summary>
        public override string ToString()
        {
            System.String result;

            result  = "transition on " + on_symbol().name_Renamed_Method() + " to state [";
            result += _to_state.index();
            result += "]";

            return(result);
        }
Exemple #2
0
        /*-----------------------------------------------------------*/
        /*--- Static Methods ----------------------------------------*/
        /*-----------------------------------------------------------*/

        /// <summary>Helper routine for debugging -- produces a dump of the given state
        /// onto System.out.
        /// </summary>
        protected internal static void  dump_state(lalr_state st)
        {
            lalr_item_set   itms;
            lalr_item       itm;
            production_part part;

            if (st == null)
            {
                System.Console.Out.WriteLine("NULL lalr_state");
                return;
            }

            System.Console.Out.WriteLine("lalr_state [" + st.index() + "] {");
            itms = st.items();
            //UPGRADE_TODO: method 'java.util.Enumeration.hasMoreElements' was converted to ' ' which has a different behavior. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1073_javautilEnumerationhasMoreElements"'
            for (System.Collections.IEnumerator e = itms.all(); e.MoveNext();)
            {
                //UPGRADE_TODO: method 'java.util.Enumeration.nextElement' was converted to ' ' which has a different behavior. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1073_javautilEnumerationnextElement"'
                itm = (lalr_item)e.Current;
                System.Console.Out.Write("  [");
                System.Console.Out.Write(itm.the_production().lhs().the_symbol().name_Renamed_Method());
                System.Console.Out.Write(" ::= ");
                for (int i = 0; i < itm.the_production().rhs_length(); i++)
                {
                    if (i == itm.dot_pos())
                    {
                        System.Console.Out.Write("(*) ");
                    }
                    part = itm.the_production().rhs(i);
                    if (part.is_action())
                    {
                        System.Console.Out.Write("{action} ");
                    }
                    else
                    {
                        System.Console.Out.Write(((symbol_part)part).the_symbol().name_Renamed_Method() + " ");
                    }
                }
                if (itm.dot_at_end())
                {
                    System.Console.Out.Write("(*) ");
                }
                System.Console.Out.WriteLine("]");
            }
            System.Console.Out.WriteLine("}");
        }
Exemple #3
0
        /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/

        /// <summary>Produce a (semi-) human readable dump of the complete viable prefix
        /// recognition state machine.
        /// </summary>
        public static void  dump_machine()
        {
            lalr_state[] ordered = new lalr_state[lalr_state.number()];

            /* put the states in sorted order for a nicer display */
            //UPGRADE_TODO: method 'java.util.Enumeration.hasMoreElements' was converted to ' ' which has a different behavior. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1073_javautilEnumerationhasMoreElements"'
            for (System.Collections.IEnumerator s = lalr_state.all(); s.MoveNext();)
            {
                //UPGRADE_TODO: method 'java.util.Enumeration.nextElement' was converted to ' ' which has a different behavior. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1073_javautilEnumerationnextElement"'
                lalr_state st = (lalr_state)s.Current;
                ordered[st.index()] = st;
            }

            System.Console.Error.WriteLine("===== Viable Prefix Recognizer =====");
            for (int i = 0; i < lalr_state.number(); i++)
            {
                if (ordered[i] == start_state)
                {
                    System.Console.Error.Write("START ");
                }
                System.Console.Error.WriteLine(ordered[i]);
                System.Console.Error.WriteLine("-------------------");
            }
        }
Exemple #4
0
        /*-----------------------------------------------------------*/
        /*--- Static Methods ----------------------------------------*/
        /*-----------------------------------------------------------*/
        /// <summary>Helper routine for debugging -- produces a dump of the given state
        /// onto System.out.
        /// </summary>
        protected internal static void dump_state(lalr_state st)
        {
            lalr_item_set itms;
            lalr_item itm;
            production_part part;

            if (st == null)
            {
                System.Console.Out.WriteLine("NULL lalr_state");
                return ;
            }

            System.Console.Out.WriteLine("lalr_state [" + st.index() + "] {");
            itms = st.items();
            //UPGRADE_TODO: method 'java.util.Enumeration.hasMoreElements' was converted to ' ' which has a different behavior. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1073_javautilEnumerationhasMoreElements"'
             for (System.Collections.IEnumerator e = itms.all(); e.MoveNext(); )
            {
                //UPGRADE_TODO: method 'java.util.Enumeration.nextElement' was converted to ' ' which has a different behavior. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1073_javautilEnumerationnextElement"'
                itm = (lalr_item) e.Current;
                System.Console.Out.Write("  [");
                System.Console.Out.Write(itm.the_production().lhs().the_symbol().name_Renamed_Method());
                System.Console.Out.Write(" ::= ");
                 for (int i = 0; i < itm.the_production().rhs_length(); i++)
                {
                    if (i == itm.dot_pos())
                        System.Console.Out.Write("(*) ");
                    part = itm.the_production().rhs(i);
                    if (part.is_action())
                        System.Console.Out.Write("{action} ");
                    else
                        System.Console.Out.Write(((symbol_part) part).the_symbol().name_Renamed_Method() + " ");
                }
                if (itm.dot_at_end())
                    System.Console.Out.Write("(*) ");
                System.Console.Out.WriteLine("]");
            }
            System.Console.Out.WriteLine("}");
        }
Exemple #5
0
        /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/

        /// <summary>Call the emit routines necessary to write out the generated parser.
        /// </summary>
        protected internal static void  emit_parser()
        {
            emit.symbols(symbol_class_file, include_non_terms, sym_interface);
            emit.parser(parser_class_file, action_table, reduce_table, start_state.index(), emit.start_production, opt_compact_red, suppress_scanner);
        }