Пример #1
0
        /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/

        /// <summary>Produce a warning message for one reduce/reduce conflict.
        /// *
        /// </summary>
        /// <param name="itm1">first item in conflict.
        /// </param>
        /// <param name="itm2">second item in conflict.
        ///
        /// </param>
        protected internal virtual void  report_reduce_reduce(lalr_item itm1, lalr_item itm2)
        {
            bool comma_flag = false;

            System.Console.Error.WriteLine("*** Reduce/Reduce conflict found in state #" + index());
            System.Console.Error.Write("  between ");
            System.Console.Error.WriteLine(itm1.to_simple_string());
            System.Console.Error.Write("  and     ");
            System.Console.Error.WriteLine(itm2.to_simple_string());
            System.Console.Error.Write("  under symbols: {");
            for (int t = 0; t < terminal.number(); t++)
            {
                if (itm1.lookahead().contains(t) && itm2.lookahead().contains(t))
                {
                    if (comma_flag)
                    {
                        System.Console.Error.Write(", ");
                    }
                    else
                    {
                        comma_flag = true;
                    }
                    System.Console.Error.Write(terminal.find(t).name_Renamed_Method());
                }
            }
            System.Console.Error.WriteLine("}");
            System.Console.Error.Write("  Resolved in favor of ");
            if (itm1.the_production().index() < itm2.the_production().index())
            {
                System.Console.Error.WriteLine("the first production.\n");
            }
            else
            {
                System.Console.Error.WriteLine("the second production.\n");
            }

            /* count the conflict */
            emit.num_conflicts++;
            lexer.warning_count++;
        }
Пример #2
0
        /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/

        /// <summary>Produce a warning message for one shift/reduce conflict.
        /// *
        /// </summary>
        /// <param name="red_itm">     the item with the reduce.
        /// </param>
        /// <param name="conflict_sym">the index of the symbol conflict occurs under.
        ///
        /// </param>
        protected internal virtual void  report_shift_reduce(lalr_item red_itm, int conflict_sym)
        {
            lalr_item itm;
            symbol    shift_sym;

            /* emit top part of message including the reduce item */
            System.Console.Error.WriteLine("*** Shift/Reduce conflict found in state #" + index());
            System.Console.Error.Write("  between ");
            System.Console.Error.WriteLine(red_itm.to_simple_string());

            /* find and report on all items that shift under our conflict symbol */
            //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 itms = items().all(); itms.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)itms.Current;

                /* only look if its not the same item and not a reduce */
                if (itm != red_itm && !itm.dot_at_end())
                {
                    /* is it a shift on our conflicting terminal */
                    shift_sym = itm.symbol_after_dot();
                    if (!shift_sym.is_non_term() && shift_sym.index() == conflict_sym)
                    {
                        /* yes, report on it */
                        System.Console.Error.WriteLine("  and     " + itm.to_simple_string());
                    }
                }
            }
            System.Console.Error.WriteLine("  under symbol " + terminal.find(conflict_sym).name_Renamed_Method());
            System.Console.Error.WriteLine("  Resolved in favor of shifting.\n");

            /* count the conflict */
            emit.num_conflicts++;
            lexer.warning_count++;
        }
Пример #3
0
        /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
        /// <summary>Produce a warning message for one shift/reduce conflict.
        /// *
        /// </summary>
        /// <param name="red_itm">     the item with the reduce.
        /// </param>
        /// <param name="conflict_sym">the index of the symbol conflict occurs under.
        /// 
        /// </param>
        protected internal virtual void report_shift_reduce(lalr_item red_itm, int conflict_sym)
        {
            lalr_item itm;
            symbol shift_sym;

            /* emit top part of message including the reduce item */
            System.Console.Error.WriteLine("*** Shift/Reduce conflict found in state #" + index());
            System.Console.Error.Write("  between ");
            System.Console.Error.WriteLine(red_itm.to_simple_string());

            /* find and report on all items that shift under our conflict symbol */
            //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 itms = items().all(); itms.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) itms.Current;

                /* only look if its not the same item and not a reduce */
                if (itm != red_itm && !itm.dot_at_end())
                {
                    /* is it a shift on our conflicting terminal */
                    shift_sym = itm.symbol_after_dot();
                    if (!shift_sym.is_non_term() && shift_sym.index() == conflict_sym)
                    {
                        /* yes, report on it */
                        System.Console.Error.WriteLine("  and     " + itm.to_simple_string());
                    }
                }
            }
            System.Console.Error.WriteLine("  under symbol " + terminal.find(conflict_sym).name_Renamed_Method());
            System.Console.Error.WriteLine("  Resolved in favor of shifting.\n");

            /* count the conflict */
            emit.num_conflicts++;
            lexer.warning_count++;
        }
Пример #4
0
        /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
        /// <summary>Produce a warning message for one reduce/reduce conflict. 
        /// *
        /// </summary>
        /// <param name="itm1">first item in conflict.
        /// </param>
        /// <param name="itm2">second item in conflict.
        /// 
        /// </param>
        protected internal virtual void report_reduce_reduce(lalr_item itm1, lalr_item itm2)
        {
            bool comma_flag = false;

            System.Console.Error.WriteLine("*** Reduce/Reduce conflict found in state #" + index());
            System.Console.Error.Write("  between ");
            System.Console.Error.WriteLine(itm1.to_simple_string());
            System.Console.Error.Write("  and     ");
            System.Console.Error.WriteLine(itm2.to_simple_string());
            System.Console.Error.Write("  under symbols: {");
             for (int t = 0; t < terminal.number(); t++)
            {
                if (itm1.lookahead().contains(t) && itm2.lookahead().contains(t))
                {
                    if (comma_flag)
                        System.Console.Error.Write(", ");
                    else
                        comma_flag = true;
                    System.Console.Error.Write(terminal.find(t).name_Renamed_Method());
                }
            }
            System.Console.Error.WriteLine("}");
            System.Console.Error.Write("  Resolved in favor of ");
            if (itm1.the_production().index() < itm2.the_production().index())
                System.Console.Error.WriteLine("the first production.\n");
            else
                System.Console.Error.WriteLine("the second production.\n");

            /* count the conflict */
            emit.num_conflicts++;
            lexer.warning_count++;
        }