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

static void java_cup::emit::do_reduce_table ( PrintWriter  out,
parse_reduce_table  red_tab 
) [inline, static, protected]

Emit the reduce-goto table.

Parameters:
out stream to produce output on.
red_tab the internal representation of the reduce-goto table.

Definition at line 639 of file emit.java.

References goto_table_time, java_cup::lalr_state::index(), java_cup::parse_reduce_table::num_states(), java_cup::parse_reduce_row::size(), java_cup::parse_reduce_row::under_non_term, and java_cup::parse_reduce_table::under_state.

Referenced by parser().

    {
      lalr_state       goto_st;
      parse_action     act;

      long start_time = System.currentTimeMillis();

      /* collect values for reduce-goto table */
      short[][] reduce_goto_table = new short[red_tab.num_states()][];
      /* do each row of the reduce-goto table */
      for (int i=0; i<red_tab.num_states(); i++)
      {
        /* make temporary table for the row. */
        short[] temp_table = new short[2*red_tab.under_state[i].size()];
        int nentries = 0;
        /* do each entry in the row */
        for (int j=0; j<red_tab.under_state[i].size(); j++)
          {
            /* get the entry */
            goto_st = red_tab.under_state[i].under_non_term[j];

            /* if we have none, skip it */
            if (goto_st != null)
            {
              /* make entries for the index and the value */
              temp_table[nentries++] = (short) j;
              temp_table[nentries++] = (short) goto_st.index();
            }
          }
        /* now we know how big to make the row. */
        reduce_goto_table[i] = new short[nentries+2];
        System.arraycopy(temp_table, 0, reduce_goto_table[i], 0, nentries);

        /* end row with default value */
        reduce_goto_table[i][nentries++] = -1;
        reduce_goto_table[i][nentries++] = -1;
      }

      /* emit the table. */
      out.println();
      out.println("  /** <code>reduce_goto</code> table. */");
      out.println("  protected static final short[][] _reduce_table = "); 
      out.print  ("    unpackFromStrings(");
      do_table_as_string(out, reduce_goto_table);
      out.println(");");

      /* do the public accessor method */
      out.println();
      out.println("  /** Access to <code>reduce_goto</code> table. */");
      out.println("  public short[][] reduce_table() {return _reduce_table;}");
      out.println();

      goto_table_time = System.currentTimeMillis() - start_time;
    }


Generated by  Doxygen 1.6.0   Back to index