Logo Search packages:      
Sourcecode: jasmin-sable version File versions  Download package

static void java_cup::Main::build_parser (  )  throws internal_error [inline, static, protected]

Build the (internal) parser from the previously parsed specification. This includes:

  • Computing nullability of non-terminals.
  • Computing first sets of non-terminals and productions.
  • Building the viable prefix recognizer machine.
  • Filling in the (internal) parse tables.
  • Checking for unreduced productions.

Definition at line 523 of file Main.java.

References action_table, java_cup::lalr_state::build_machine(), java_cup::lalr_state::build_table_entries(), java_cup::parse_action_table::check_reductions(), expect_conflicts, first_end, machine_end, nullability_end, opt_do_debug, print_progress, reduce_check_end, reduce_table, start_state, and table_end.

Referenced by main().

    {
      /* compute nullability of all non terminals */
      if (opt_do_debug || print_progress) 
      System.err.println("  Computing non-terminal nullability...");
      non_terminal.compute_nullability();

      nullability_end = System.currentTimeMillis();

      /* compute first sets of all non terminals */
      if (opt_do_debug || print_progress) 
      System.err.println("  Computing first sets...");
      non_terminal.compute_first_sets();

      first_end = System.currentTimeMillis();

      /* build the LR viable prefix recognition machine */
      if (opt_do_debug || print_progress) 
      System.err.println("  Building state machine...");
      start_state = lalr_state.build_machine(emit.start_production);

      machine_end = System.currentTimeMillis();

      /* build the LR parser action and reduce-goto tables */
      if (opt_do_debug || print_progress) 
      System.err.println("  Filling in tables...");
      action_table = new parse_action_table();
      reduce_table = new parse_reduce_table();
      for (Enumeration st = lalr_state.all(); st.hasMoreElements(); )
      {
        lalr_state lst = (lalr_state)st.nextElement();
        lst.build_table_entries(
                                        action_table, reduce_table);
      }

      table_end = System.currentTimeMillis();

      /* check and warn for non-reduced productions */
      if (opt_do_debug || print_progress) 
      System.err.println("  Checking for non-reduced productions...");
      action_table.check_reductions();

      reduce_check_end = System.currentTimeMillis();

      /* if we have more conflicts than we expected issue a message and die */
      if (emit.num_conflicts > expect_conflicts)
      {
        System.err.println("*** More conflicts encountered than expected " +
                       "-- parser generation aborted");
        lexer.error_count++; // indicate the problem.
        // we'll die on return, after clean up.
      }
    }


Generated by  Doxygen 1.6.0   Back to index