Beispiel #1
0
        /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/

        /** Produce a warning message for one reduce/reduce conflict.
         *
         * @param itm1 first item in conflict.
         * @param itm2 second item in conflict.
         */
        protected 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());
                }
            }
            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++;
        }
        /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
        /** Produce a warning message for one reduce/reduce conflict.
           *
           * @param itm1 first item in conflict.
           * @param itm2 second item in conflict.
           */
        protected 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());
            }
            }
              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++;
        }