You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by jo...@apache.org on 2004/02/15 22:35:32 UTC

cvs commit: ws-jaxme/src/js/org/apache/ws/jaxme/js/cup Parser.java Emit.java LalrState.java Data.java Production.java ParseActionTable.java Main.java

jochen      2004/02/15 13:35:32

  Modified:    src/js/org/apache/ws/jaxme/js/cup Tag: UsingCup Parser.java
                        Emit.java LalrState.java Data.java Production.java
                        ParseActionTable.java Main.java
  Log:
  Reduced number of static variables.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.2   +16 -18    ws-jaxme/src/js/org/apache/ws/jaxme/js/cup/Attic/Parser.java
  
  Index: Parser.java
  ===================================================================
  RCS file: /home/cvs/ws-jaxme/src/js/org/apache/ws/jaxme/js/cup/Attic/Parser.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- Parser.java	14 Feb 2004 21:12:59 -0000	1.1.2.1
  +++ Parser.java	15 Feb 2004 21:35:32 -0000	1.1.2.2
  @@ -70,6 +70,8 @@
   
   import java.util.Hashtable;
   
  +import org.apache.ws.jaxme.js.JavaQNameImpl;
  +
   /** CUP v0.10k generated parser.
     * @version Sun Jul 25 13:35:26 EDT 1999
     */
  @@ -1048,8 +1050,7 @@
   	          add_rhs_part(add_lab(new SymbolPart(start_nt),"start_val"));
   	          add_rhs_part(new SymbolPart(Data.getData().getEOFTerminal()));
   		  add_rhs_part(new ActionPart("RESULT = start_val;"));
  -	          Emit.start_production = 
  -		     new Production(Data.getData(), Data.getData().getStartNonTerminal(), rhs_parts, rhs_pos);
  +		  Data.getData().setStartProduction(new Production(Data.getData(), Data.getData().getStartNonTerminal(), rhs_parts, rhs_pos));
   
   	          new_rhs();
   		}
  @@ -1103,13 +1104,11 @@
   	          add_rhs_part(new SymbolPart(Data.getData().getEOFTerminal()));
   		  add_rhs_part(new ActionPart("RESULT = start_val;"));
   		  if ((sym!=null) && (sym instanceof Terminal)) {
  -		    Emit.start_production = 
  -		      new Production(Data.getData(), Data.getData().getStartNonTerminal(), rhs_parts, 
  -				     rhs_pos, ((Terminal)sym).precedence_num(),
  -				     ((Terminal)sym).precedence_side());
  +		      Data.getData().setStartProduction(new Production(Data.getData(), Data.getData().getStartNonTerminal(), rhs_parts, 
  +		              										   rhs_pos, ((Terminal)sym).precedence_num(),
  +		              										   ((Terminal)sym).precedence_side()));
   		  } else {
  -		    Emit.start_production = 
  -		      new Production(Data.getData(), Data.getData().getStartNonTerminal(), rhs_parts, rhs_pos);
  +		      Data.getData().setStartProduction(new Production(Data.getData(), Data.getData().getStartNonTerminal(), rhs_parts, rhs_pos));
   		  }
   	          new_rhs();
   		}
  @@ -1271,8 +1270,7 @@
   	      add_rhs_part(add_lab(new SymbolPart(start_nt), "start_val"));
   	      add_rhs_part(new SymbolPart(Data.getData().getEOFTerminal()));
   	      add_rhs_part(new ActionPart("RESULT = start_val;"));
  -	      Emit.start_production = 
  -		     new Production(Data.getData(), Data.getData().getStartNonTerminal(), rhs_parts, rhs_pos);
  +	      Data.getData().setStartProduction(new Production(Data.getData(), Data.getData().getStartNonTerminal(), rhs_parts, rhs_pos));
   	      new_rhs();
   	    }
   	
  @@ -1627,10 +1625,10 @@
                 Object RESULT = null;
   		String user_code = (String)((org.apache.ws.jaxme.js.cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
   		 
  -	  if (Emit.scan_code!=null)
  +	  if (Data.getData().getScanCode() != null)
   	    Lexer.getLexer().emit_error("Redundant scan code (skipping)");
   	  else /* save the user code */
  -	    Emit.scan_code = user_code;
  +	    Data.getData().setScanCode(user_code);
   	
                 CUP$parser$result = new org.apache.ws.jaxme.js.cup.runtime.Symbol(17/*scan_code*/, ((org.apache.ws.jaxme.js.cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left, ((org.apache.ws.jaxme.js.cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
               }
  @@ -1642,10 +1640,10 @@
                 Object RESULT = null;
   		String user_code = (String)((org.apache.ws.jaxme.js.cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
   		 
  -	  if (Emit.init_code!=null)
  +	  if (Data.getData().getInitCode() != null)
   	    Lexer.getLexer().emit_error("Redundant init code (skipping)");
   	  else /* save the user code */
  -	    Emit.init_code = user_code;
  +	      Data.getData().setInitCode(user_code);
   	
                 CUP$parser$result = new org.apache.ws.jaxme.js.cup.runtime.Symbol(16/*init_code*/, ((org.apache.ws.jaxme.js.cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left, ((org.apache.ws.jaxme.js.cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
               }
  @@ -1657,10 +1655,10 @@
                 Object RESULT = null;
   		String user_code = (String)((org.apache.ws.jaxme.js.cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value;
   		
  -	  if (Emit.parser_code!=null)
  +	  if (Data.getData().getParserCode() != null)
   	    Lexer.getLexer().emit_error("Redundant parser code (skipping)");
   	  else /* save the user included code string */
  -	    Emit.parser_code = user_code;
  +	    Data.getData().setParserCode(user_code);
   	
                 CUP$parser$result = new org.apache.ws.jaxme.js.cup.runtime.Symbol(9/*parser_code_part*/, ((org.apache.ws.jaxme.js.cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left, ((org.apache.ws.jaxme.js.cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT);
               }
  @@ -1753,7 +1751,7 @@
                 Object RESULT = null;
    
   	  /* save this import on the imports list */
  -	  Emit.import_list.push(multipart_name);
  +	  Data.getData().addImport(JavaQNameImpl.getInstance(multipart_name));
   
   	  /* reset the accumulated multipart name */
   	  multipart_name = new String();
  @@ -1807,7 +1805,7 @@
                 Object RESULT = null;
   
   	  /* save the package name */
  -	  Emit.package_name = multipart_name;
  +	  Data.getData().setPackageName(multipart_name);
   
   	  /* reset the accumulated multipart name */
   	  multipart_name = new String();
  
  
  
  1.1.2.2   +65 -228   ws-jaxme/src/js/org/apache/ws/jaxme/js/cup/Attic/Emit.java
  
  Index: Emit.java
  ===================================================================
  RCS file: /home/cvs/ws-jaxme/src/js/org/apache/ws/jaxme/js/cup/Attic/Emit.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- Emit.java	14 Feb 2004 21:12:59 -0000	1.1.2.1
  +++ Emit.java	15 Feb 2004 21:35:32 -0000	1.1.2.2
  @@ -69,223 +69,56 @@
   package org.apache.ws.jaxme.js.cup;
   
   import java.io.PrintWriter;
  -import java.util.Stack;
   
  +import org.apache.ws.jaxme.js.JavaQName;
   
  -/** 
  - * This class handles emitting generated code for the resulting parser.
  - * The various parse tables must be constructed, etc. before calling any 
  - * routines in this class.<p>  
  - *
  - * Three classes are produced by this code:
  - *   <dl>
  - *   <dt> symbol constant class
  - *   <dd>   this contains constant declarations for each terminal (and 
  - *          optionally each non-terminal).
  - *   <dt> action class
  - *   <dd>   this non-public class contains code to invoke all the user actions 
  - *          that were embedded in the parser specification.
  - *   <dt> parser class
  - *   <dd>   the specialized parser class consisting primarily of some user 
  - *          supplied general and initialization code, and the parse tables.
  - *   </dl><p>
  - *
  - *  Three parse tables are created as part of the parser class:
  - *    <dl>
  - *    <dt> production table
  - *    <dd>   lists the LHS non terminal number, and the length of the RHS of 
  - *           each production.
  - *    <dt> action table
  - *    <dd>   for each state of the parse machine, gives the action to be taken
  - *           (shift, reduce, or error) under each lookahead symbol.<br>
  - *    <dt> reduce-goto table
  - *    <dd>   when a reduce on a given production is taken, the parse stack is 
  - *           popped back a number of elements corresponding to the RHS of the 
  - *           production.  This reveals a prior state, which we transition out 
  - *           of under the LHS non terminal symbol for the production (as if we
  - *           had seen the LHS symbol rather than all the symbols matching the 
  - *           RHS).  This table is indexed by non terminal numbers and indicates 
  - *           how to make these transitions. 
  - *    </dl><p>
  - * 
  - * In addition to the method interface, this class maintains a series of 
  - * public global variables and flags indicating how misc. parts of the code 
  - * and other output is to be produced, and counting things such as number of 
  - * conflicts detected (see the source code and public variables below for
  - * more details).<p> 
  - *
  - * This class is "static" (contains only static data and methods).<p> 
  +
  +/** <p>This class is actually generating source. It creates the parser
  + * class, including
  + * <dl>
  + *   <dt>production table</dt>
  + *   <dd>lists the LHS non terminal number, and the length of the RHS of 
  + *     each production.</dd>
  + *   <dt>action table</dt>
  + *   <dd>for each state of the parse machine, gives the action to be taken
  + *     (shift, reduce, or error) under each lookahead symbol.</dd>
  + *   <dt>reduce-goto table</dt>
  + *   <dd>when a reduce on a given production is taken, the parse stack is 
  + *     popped back a number of elements corresponding to the RHS of the 
  + *     production.  This reveals a prior state, which we transition out 
  + *     of under the LHS non terminal symbol for the production (as if we
  + *     had seen the LHS symbol rather than all the symbols matching the 
  + *     RHS).  This table is indexed by non terminal numbers and indicates 
  + *     how to make these transitions.</dd>
  + * </dl>
    *
  - * @see java_cup.main
  - * @version last update: 11/25/95
  - * @author Scott Hudson
  + * @author <a href="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
    */
  -
  -/* Major externally callable routines here include:
  -     symbols               - emit the symbol constant class 
  -     parser                - emit the parser class
  -
  -   In addition the following major internal routines are provided:
  -     emit_package          - emit a package declaration
  -     emit_action_code      - emit the class containing the user's actions 
  -     emit_production_table - emit declaration and init for the production table
  -     do_action_table       - emit declaration and init for the action table
  -     do_reduce_table       - emit declaration and init for the reduce-goto table
  -
  -   Finally, this class uses a number of public instance variables to communicate
  -   optional parameters and flags used to control how code is generated,
  -   as well as to report counts of various things (such as number of conflicts
  -   detected).  These include:
  -
  -   prefix                  - a prefix string used to prefix names that would 
  -			     otherwise "pollute" someone else's name space.
  -   package_name            - name of the package emitted code is placed in 
  -			     (or null for an unnamed package.
  -   symbol_const_class_name - name of the class containing symbol constants.
  -   parser_class_name       - name of the class for the resulting parser.
  -   action_code             - user supplied declarations and other code to be 
  -			     placed in action class.
  -   parser_code             - user supplied declarations and other code to be 
  -			     placed in parser class.
  -   init_code               - user supplied code to be executed as the parser 
  -			     is being initialized.
  -   scan_code               - user supplied code to get the next Symbol.
  -   start_production        - the start production for the grammar.
  -   import_list             - list of imports for use with action class.
  -   num_conflicts           - number of conflicts detected. 
  -   nowarn                  - true if we are not to issue warning messages.
  -   not_reduced             - count of number of productions that never reduce.
  -   unused_term             - count of unused terminal symbols.
  -   unused_non_term         - count of unused non terminal symbols.
  -   *_time                  - a series of symbols indicating how long various
  -			     sub-parts of code generation took (used to produce
  -			     optional time reports in main).
  -*/
  -
   public class Emit {
  +    /** <p>Calculates the parsers class name.</p>
  +     */
  +    public static String getClassName(Data pData) {
  +        String result = pData.getClassName();
  +        return (result == null  ||  "".equals(result)) ? "parser" : result;
  +    }
  +    
  +    /** Only constructor is private so no instances can be created. */
  +    private Emit() { }
   
  -  /*-----------------------------------------------------------*/
  -  /*--- Constructor(s) ----------------------------------------*/
  -  /*-----------------------------------------------------------*/
  -
  -  /** Only constructor is private so no instances can be created. */
  -  private Emit() { }
  -
  -  /*-----------------------------------------------------------*/
  -  /*--- Static (Class) Variables ------------------------------*/
  -  /*-----------------------------------------------------------*/
  -
  -  /** The prefix placed on names that pollute someone else's name space. */
  -  public static String prefix = "CUP$";
  -
  -  /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  -
  -  /** Package that the resulting code goes into (null is used for unnamed). */
  -  public static String package_name = null;
  -
  -  /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  -
  -  /** Name of the generated class for symbol constants. */
  -  public static String symbol_const_class_name = "sym";
  -
  -  /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  -
  -  /** Name of the generated parser class. */
  -  public static String parser_class_name = "parser";
  -
  -  /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  -
  -  /** User declarations for direct inclusion in user action class. */
  -  public static String action_code = null;
  -
  -  /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  -
  -  /** User declarations for direct inclusion in parser class. */
  -  public static String parser_code = null;
  -
  -  /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  -
  -  /** User code for user_init() which is called during parser initialization. */
  -  public static String init_code = null;
  -
  -  /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  -
  -  /** User code for scan() which is called to get the next Symbol. */
  -  public static String scan_code = null;
  -
  -  /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  -
  -  /** The start production of the grammar. */
  -  public static Production start_production = null;
  -
  -  /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  -
  -  /** List of imports (Strings containing class names) to go with actions. */
  -  public static Stack import_list = new Stack();
  -
  -  /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  -
  -  /** Number of conflict found while building tables. */
  -  public static int num_conflicts = 0;
  -
  -  /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  -
  -  /** Do we skip warnings? */
  -  public static boolean nowarn = false;
  -
  -  /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  -
  -  /** Count of the number on non-reduced productions found. */
  -  public static int not_reduced = 0;
  -
  -  /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  -
  -  /** Count of unused terminals. */
  -  public static int unused_term = 0;
  -
  -  /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  -
  -  /** Count of unused non terminals. */
  -  public static int unused_non_term = 0;
  -
  -  /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  -
  -  /* Timing values used to produce timing report in main.*/
  -
  -  /** Time to produce symbol constant class. */
  -  public static long symbols_time          = 0;
  -
  -  /** Time to produce parser class. */
  -  public static long parser_time           = 0;
  -
  -  /** Time to produce action code class. */
  -  public static long action_code_time      = 0;
  -
  -  /** Time to produce the production table. */
  -  public static long production_table_time = 0;
  -
  -  /** Time to produce the action table. */
  -  public static long action_table_time     = 0;
  -
  -  /** Time to produce the reduce-goto table. */
  -  public static long goto_table_time       = 0;
  -
  -  /* frankf 6/18/96 */
  -  protected static boolean _lr_values;
  +    /** The prefix placed on names that pollute someone else's name space. */
  +    public static String prefix = "CUP$";
   
  -  /** whether or not to emit code for left and right values */
  -  public static boolean lr_values() {return _lr_values;}
  -  protected static void set_lr_values(boolean b) { _lr_values = b;}
  +    /** Name of the generated class for symbol constants. */
  +    public static String symbol_const_class_name = "sym";
   
  -  /*-----------------------------------------------------------*/
  -  /*--- General Methods ---------------------------------------*/
  -  /*-----------------------------------------------------------*/
  +    /** User declarations for direct inclusion in user action class. */
  +    public static String action_code = null;
   
     /** Build a string with the standard prefix. 
      * @param str string to prefix.
      */
     protected static String pre(String str) {
  -    return prefix + parser_class_name + "$" + str;
  +    return prefix + getClassName(Data.getData()) + "$" + str;
     }
   
     /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  @@ -293,11 +126,11 @@
     /** Emit a package spec if the user wants one. 
      * @param out stream to produce output on.
      */
  -  protected static void emit_package(PrintWriter out)
  -    {
  +  protected static void emit_package(PrintWriter out) {
  +      String packageName = Data.getData().getPackageName();
         /* generate a package spec if we have a name for one */
  -      if (package_name != null) {
  -	out.println("package " + package_name + ";"); out.println();
  +      if (packageName != null) {
  +          out.println("package " + packageName + ";"); out.println();
         }
       }
   
  @@ -363,7 +196,7 @@
         out.println("}");
         out.println();
   
  -      symbols_time = System.currentTimeMillis() - start_time;
  +      pData.setGeneratorTime(pData.getGeneratorTime() + System.currentTimeMillis() - start_time);
       }
   
     /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  @@ -387,12 +220,12 @@
           }
           
           /* field for parser object */
  -        out.println("  private final "+parser_class_name+" parser;");
  +        out.println("  private final " + getClassName(pData) + " parser;");
           
           /* constructor */
           out.println();
           out.println("  /** Constructor */");
  -        out.println("  " + pre("actions") + "("+parser_class_name+" parser) {");
  +        out.println("  " + pre("actions") + "(" + getClassName(pData) + " parser) {");
           out.println("    this.parser = parser;");
           out.println("  }");
           
  @@ -480,7 +313,7 @@
               /* Create the code that assigns the left and right values of
                * the new Symbol that the production is reducing to
                */
  -            if (Emit.lr_values()) {	    
  +            if (pData.isCreatingLrValues()) {	    
                   int loffset;
                   String leftstring, rightstring;
                   int roffset = 0;
  @@ -535,7 +368,7 @@
           out.println("}");
           out.println();
           
  -        action_code_time = System.currentTimeMillis() - start_time;
  +        pData.setGeneratorTime(pData.getGeneratorTime() + System.currentTimeMillis() - start_time);
     }
   
     /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  @@ -571,7 +404,7 @@
         out.println("  public short[][] production_table() " + 
   						 "{return _production_table;}");
   
  -      production_table_time = System.currentTimeMillis() - start_time;
  +      pData.setProductionTableTime(System.currentTimeMillis() - start_time);
       }
   
     /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  @@ -672,7 +505,7 @@
         out.println("  /** Access to parse-action table. */");
         out.println("  public short[][] action_table() {return _action_table;}");
   
  -      action_table_time = System.currentTimeMillis() - start_time;
  +      pData.setActionTableTime(System.currentTimeMillis() - start_time);
       }
   
     /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  @@ -681,7 +514,8 @@
     	 * @param out     stream to produce output on.
     	 * @param red_tab the internal representation of the reduce-goto table.
     	 */
  -  	protected static void do_reduce_table(PrintWriter out, 
  +  	protected static void do_reduce_table(Data pData,
  +  	        							  PrintWriter out, 
   										  ParseReduceTable red_tab) {
     	    LalrState       goto_st;
   
  @@ -730,7 +564,7 @@
     	    out.println("  public short[][] reduce_table() {return _reduce_table;}");
     	    out.println();
     	    
  -  	    goto_table_time = System.currentTimeMillis() - start_time;
  +  	    pData.setGotoTableTime(System.currentTimeMillis() - start_time);
     	}
   
     // print a string array encoding the given short[][] array.
  @@ -815,9 +649,12 @@
         emit_package(out);
   
         /* user supplied imports */
  -      for (int i = 0; i < import_list.size(); i++)
  -	out.println("import " + import_list.elementAt(i) + ";");
  +      JavaQName[] imports = pData.getImports();
  +      for (int i = 0;  i < imports.length;  i++) {
  +          out.println("import " + imports[i] + ";");
  +      }
   
  +      String parser_class_name = getClassName(pData);
         /* class header */
         out.println();
         out.println("/** "+Version.title_str+" generated parser.");
  @@ -839,7 +676,7 @@
         /* emit the various tables */
         emit_production_table(pData, out);
         do_action_table(pData, out, action_table, compact_reduces);
  -      do_reduce_table(out, reduce_table);
  +      do_reduce_table(pData, out, reduce_table);
   
         /* instance of the action encapsulation class */
         out.println("  /** Instance of action encapsulation class. */");
  @@ -877,7 +714,7 @@
         /* method to indicate start production */
         out.println("  /** Indicates start production. */");
         out.println("  public int start_production() {return " + 
  -		     start_production.index() + ";}");
  +              	  pData.getStartProduction().index() + ";}");
         out.println();
   
         /* methods to indicate EOF and error symbol indexes */
  @@ -891,30 +728,30 @@
         out.println();
   
         /* user supplied code for user_init() */
  -      if (init_code != null) {
  +      if (pData.getInitCode() != null) {
             out.println();
   	  out.println("  /** User initialization code. */");
   	  out.println("  public void user_init() throws java.lang.Exception");
   	  out.println("    {");
  -	  out.println(init_code);
  +	  out.println(pData.getInitCode());
   	  out.println("    }");
   	}
   
         /* user supplied code for scan */
  -      if (scan_code != null) {
  +      if (pData.getScanCode() != null) {
             out.println();
   	  out.println("  /** Scan to get the next Symbol. */");
   	  out.println("  public java_cup.runtime.Symbol scan()");
   	  out.println("    throws java.lang.Exception");
   	  out.println("    {");
  -	  out.println(scan_code);
  +	  out.println(pData.getScanCode());
   	  out.println("    }");
   	}
   
         /* user supplied code */
  -      if (parser_code != null) {
  +      if (pData.getParserCode() != null) {
   	  out.println();
  -          out.println(parser_code);
  +          out.println(pData.getParserCode());
   	}
   
         /* end of class */
  @@ -923,7 +760,7 @@
         /* put out the action code class */
         emit_action_code(pData, out, start_prod);
   
  -      parser_time = System.currentTimeMillis() - start_time;
  +      pData.setGeneratorTime(pData.getGeneratorTime() + System.currentTimeMillis() - start_time);
       }
   
       /*-----------------------------------------------------------*/
  
  
  
  1.1.2.2   +2 -2      ws-jaxme/src/js/org/apache/ws/jaxme/js/cup/Attic/LalrState.java
  
  Index: LalrState.java
  ===================================================================
  RCS file: /home/cvs/ws-jaxme/src/js/org/apache/ws/jaxme/js/cup/Attic/LalrState.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- LalrState.java	14 Feb 2004 21:12:59 -0000	1.1.2.1
  +++ LalrState.java	15 Feb 2004 21:35:32 -0000	1.1.2.2
  @@ -745,7 +745,7 @@
               System.err.println("the second production.\n");
           
           /* count the conflict */
  -        Emit.num_conflicts++;
  +        pData.incNumConflicts();
           Lexer.getLexer().warning_count++;
       }
   
  @@ -786,7 +786,7 @@
           System.err.println("  Resolved in favor of shifting.\n");
           
           /* count the conflict */
  -        Emit.num_conflicts++;
  +        pData.incNumConflicts();
           Lexer.getLexer().warning_count++;
       }
   
  
  
  
  1.1.2.2   +293 -0    ws-jaxme/src/js/org/apache/ws/jaxme/js/cup/Attic/Data.java
  
  Index: Data.java
  ===================================================================
  RCS file: /home/cvs/ws-jaxme/src/js/org/apache/ws/jaxme/js/cup/Attic/Data.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- Data.java	14 Feb 2004 21:12:59 -0000	1.1.2.1
  +++ Data.java	15 Feb 2004 21:35:32 -0000	1.1.2.2
  @@ -55,6 +55,8 @@
   import java.util.List;
   import java.util.Map;
   
  +import org.apache.ws.jaxme.js.JavaQName;
  +
   
   /** <p>Data container for storing the parser generators productions,
    * terminals, non-terminals, etc. The original Cup used to use
  @@ -88,6 +90,15 @@
       private final NonTerminal startNonTerminal = NonTerminal.newInstance(this, "$START");
       private List productions = new ArrayList();
       private Production[] productionArray;
  +    private Production startProduction;
  +    private String packageName, className;
  +    private String parserCode, initCode, scanCode;
  +    private List imports = new ArrayList();
  +    private int numConflicts, numNotReduced, numUnusedTerminals, numUnusedNonTerminals;
  +    private boolean skippingWarnings, creatingLrValues = true, dumpingStates;
  +    private boolean dumpingTables, dumpingGrammar, showingTimes, debugging;
  +    private boolean compactingTables;
  +    private long generatorTime, productionTableTime, actionTableTime, gotoTableTime;
   
       /** <p>Adds a new {@link LalrState} to the set of states.</p>
        */
  @@ -221,5 +232,287 @@
               productionArray = (Production[]) productions.toArray(new Production[productions.size()]);
           }
           return productionArray;
  +    }
  +
  +    /** <p>Sets the parsers start production.</p>
  +     */
  +    public void setStartProduction(Production pStartProduction) {
  +        startProduction = pStartProduction;
  +    }
  +
  +    /** <p>Returns the parsers start production.</p>
  +     */
  +    public Production getStartProduction() {
  +        return startProduction;
  +    }
  +
  +    /** <p>Sets the name of the package in which to create sources.</p>
  +     * @see #setClassName(String)
  +     */
  +    public void setPackageName(String pPackage) {
  +        packageName = pPackage;
  +    }
  +
  +    /** <p>Returns the name of the package in which to create sources.</p>
  +     * @see #getClassName()
  +     */
  +    public String getPackageName() {
  +        return packageName;
  +    }
  +
  +    /** <p>Sets the name of the parser class being generated,
  +     * excluding the package name. Defaults to "Parser".</p>
  +     * @see #setPackageName(String)
  +     */
  +    public void setClassName(String pClassName) {
  +        className = pClassName;
  +    }
  +
  +    /** <p>Returns the name of the parser class being generated,
  +     * excluding the package name. Defaults to "Parser".</p>
  +     * @see #getPackageName()
  +     */
  +    public String getClassName() {
  +        return className;
  +    }
  +
  +    /** <p>Sets code used to initialize the parser.</p>
  +     */
  +    public void setInitCode(String pInitCode) {
  +        initCode = pInitCode;
  +    }
  +
  +    /** <p>Returns code used to initialize the parser.</p>
  +     */
  +    public String getInitCode() {
  +        return initCode;
  +    }
  +    
  +    /** <p>Sets code to include directly in the parser class.</p>
  +     */
  +    public void setParserCode(String pParserCode) {
  +        parserCode = pParserCode;
  +    }
  +
  +    /** <p>Returns code to include directly in the parser class.</p>
  +     */
  +    public String getParserCode() {
  +        return parserCode;
  +    }
  +
  +    /** <p>Sets code for the parsers <code>scan()</code> method.</p>
  +     */
  +    public void setScanCode(String pScanCode) {
  +        scanCode = pScanCode;
  +    }
  +
  +    /** <p>Returns code for the parsers <code>scan()</code> method.</p>
  +     */
  +    public String getScanCode() {
  +        return scanCode;
  +    }
  +
  +    /** <p>Adds a new item to the list of imports.</p>
  +     */
  +    public void addImport(JavaQName pQName) {
  +        imports.add(pQName);
  +    }
  +
  +    /** <p>Returns the list of imports.</p>
  +     */
  +    public JavaQName[] getImports() {
  +        return (JavaQName[]) imports.toArray(new JavaQName[imports.size()]);
  +    }
  +
  +    /** <p>Increments the number of conflicts.</p>
  +     */
  +    public void incNumConflicts() {
  +        ++numConflicts;
  +    }
  +
  +    /** <p>Returns the number of conflicts.</p>
  +     */
  +    public int getNumConflicts() {
  +        return numConflicts;
  +    }
  +
  +    /** <p>Increments the number of productions being not reduced.</p>
  +     */
  +    public void incNumNotReduced() {
  +        numNotReduced++;
  +    }
  +
  +    /** <p>Returns the number of productions being not reduced.</p>
  +     */
  +    public int getNumNotReduced() {
  +        return numNotReduced;
  +    }
  +
  +    /** <p>Increments the number of unused terminals.</p>
  +     */
  +    public void incNumUnusedTerminals() {
  +        numUnusedTerminals++;
  +    }
  +
  +    /** <p>Returns the number of unused terminals.</p>
  +     */
  +    public int getNumUnusedTerminals() {
  +        return numUnusedTerminals;
  +    }
  +
  +    /** <p>Increments the number of unused non-terminals.</p>
  +     */
  +    public void incNumUnusedNonTerminals() {
  +        numUnusedNonTerminals++;
  +    }
  +
  +    /** <p>Returns the number of unused non-terminals.</p>
  +     */
  +    public int getNumUnusedNonTerminals() {
  +        return numUnusedNonTerminals;
  +    }
  +
  +    /** <p>Returns whether a dump of the parse tables is being created.</p>
  +     */
  +    public boolean isDumpingTables() {
  +        return dumpingTables;
  +    }
  +
  +    /** <p>Sets whether a dump of the parse tables is being created.</p>
  +     */
  +    public void setDumpingTables(boolean pDumpingTables) {
  +        dumpingTables = pDumpingTables;
  +    }
  +
  +    /** <p>Returns whether a dump of the states is being created.</p>
  +     */
  +    public boolean isDumpingStates() {
  +        return dumpingStates;
  +    }
  +
  +    /** <p>Sets whether a dump of the states is being created.</p>
  +     */
  +    public void setDumpingStates(boolean pDumpingStates) {
  +        dumpingStates = pDumpingStates;
  +    }
  +
  +    /** <p>Returns whether a dump of the grammar is being created.</p>
  +     */
  +    public boolean isDumpingGrammar() {
  +        return dumpingGrammar;
  +    }
  +
  +    /** <p>Sets whether a dump of the grammar is being created.</p>
  +     */
  +    public void setDumpingGrammar(boolean pDumpingGrammar) {
  +        dumpingGrammar = pDumpingGrammar;
  +    }
  +
  +    /** <p>Returns whether warnings are being skipped.</p>
  +     */
  +    public boolean isSkippingWarnings() {
  +        return skippingWarnings;
  +    }
  +
  +    /** <p>Sets whether warnings are being skipped.</p>
  +     */
  +    public void setSkippingWarnings(boolean pSkippingWarnings) {
  +        skippingWarnings = pSkippingWarnings;
  +    }
  +
  +    /** <p>Returns whether debugging mode is on.</p>
  +     */
  +    public boolean isDebugging() {
  +        return debugging;
  +    }
  +
  +    /** <p>Sets whether debugging mode is on.</p>
  +     */
  +    public void setDebugging(boolean pDebugging) {
  +        debugging = pDebugging;
  +    }
  +
  +    /** <p>Returns whether tables are compacted by making most
  +     * common reduce the default action.</p> */
  +    public boolean isCompactingTables() {
  +        return compactingTables;
  +    }
  +
  +    /** <p>Sets whether tables are compacted by making most
  +     * common reduce the default action.</p> */
  +    public void setCompactingTables(boolean pCompactingReduce) {
  +        compactingTables = pCompactingReduce;
  +    }
  +
  +    /** <p>Returns whether times are being shown.</p>
  +     */
  +    public boolean isShowingTimes() {
  +        return showingTimes;
  +    }
  +
  +    /** <p>Sets whether times are being shown.</p>
  +     */
  +    public void setShowingTimes(boolean pShowingTime) {
  +        showingTimes = pShowingTime;
  +    }
  +
  +    /** <p>Returns whether LR values are being created.</p>
  +     */
  +    public boolean isCreatingLrValues() {
  +        return creatingLrValues;
  +    }
  +
  +    /** <p>Sets whether LR values are being created.</p>
  +     */
  +    public void setCreatingLrValues(boolean pCreatingLrValues) {
  +        creatingLrValues = pCreatingLrValues;
  +    }
  +
  +    /** <p>Sets the time for generating sources.</p>
  +     */
  +    public void setGeneratorTime(long pGeneratorTime) {
  +        generatorTime = pGeneratorTime;
  +    }
  +
  +    /** <p>Returns the time for generating sources.</p>
  +     */
  +    public long getGeneratorTime() {
  +        return generatorTime;
  +    }
  +
  +    /** <p>Sets the time for creating the production table.</p>
  +     */
  +    public void setProductionTableTime(long pProductionTableTime) {
  +        productionTableTime = pProductionTableTime;
  +    }
  +
  +    /** <p>Returns the time for creating the production table.</p>
  +     */
  +    public long getProductionTableTime() {
  +        return productionTableTime;
  +    }
  +
  +    /** <p>Sets the time for creating the action table.</p>
  +     */
  +    public void setActionTableTime(long pActionTableTime) {
  +        actionTableTime = pActionTableTime;
  +    }
  +
  +    /** <p>Returns the time for creating the action table.</p>
  +     */
  +    public long getActionTableTime() {
  +        return actionTableTime;
  +    }
  +
  +    /** <p>Sets the time for creating the goto table.</p>
  +     */
  +    public void setGotoTableTime(long pGotoTableTime) {
  +        gotoTableTime = pGotoTableTime;
  +    }
  +
  +    /** <p>Returns the time for creating the goto table.</p>
  +     */
  +    public long getGotoTableTime() {
  +        return gotoTableTime;
       }
   }
  
  
  
  1.1.2.2   +12 -16    ws-jaxme/src/js/org/apache/ws/jaxme/js/cup/Attic/Production.java
  
  Index: Production.java
  ===================================================================
  RCS file: /home/cvs/ws-jaxme/src/js/org/apache/ws/jaxme/js/cup/Attic/Production.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- Production.java	14 Feb 2004 21:12:59 -0000	1.1.2.1
  +++ Production.java	15 Feb 2004 21:35:32 -0000	1.1.2.2
  @@ -157,8 +157,7 @@
           }
           
           /* get the generated declaration code for the necessary labels. */
  -        declare_str = declare_labels(
  -                rhs_parts, rightlen, action_str);
  +        declare_str = declare_labels(pData, rhs_parts, rightlen, action_str);
           
           if (action_str == null) 
               action_str = declare_str;
  @@ -367,15 +366,14 @@
        * @param stack_type   the stack type of label?
        * @author frankf
        */ 
  -    protected String make_declaration(
  -            String  labelname,
  -			String  stack_type,
  -			int     offset)
  -    {
  +    protected String make_declaration(Data pData,
  +            						  String  labelname,
  +            						  String  stack_type,
  +            						  int offset) {
           String ret;
           
           /* Put in the left/right value labels */
  -        if (Emit.lr_values())
  +        if (pData.isCreatingLrValues())
               ret = "\t\tint " + labelname + "left = ((java_cup.runtime.Symbol)" + 
               Emit.pre("stack") + ".elementAt(" + Emit.pre("top") + 
               "-" + offset + ")).left;\n" +
  @@ -397,11 +395,10 @@
        * @param final_action the final action string of the production. 
        * @param lhs_type     the object type associated with the LHS symbol.
        */ 
  -    protected String declare_labels(
  -            ProductionPart  rhs[], 
  -			int              rhs_len, 
  -			String           final_action)
  -    {
  +    protected String declare_labels(Data pData,
  +            						ProductionPart  rhs[], 
  +            						int rhs_len, 
  +            						String final_action) {
           String declaration = "";
           
           SymbolPart part;
  @@ -418,7 +415,7 @@
                   if (part.label() != null)
                      {
                       declaration = declaration + 
  -                    make_declaration(part.label(), part.the_symbol().stack_type(), 
  +                    make_declaration(pData, part.label(), part.the_symbol().stack_type(), 
                               rhs_len-pos-1);
                   }
               }
  @@ -527,8 +524,7 @@
                  {
                   
                   
  -                declare_str = declare_labels(
  -                        _rhs, act_loc, "");
  +                declare_str = declare_labels(pData, _rhs, act_loc, "");
                   /* create a new non terminal for the action production */
                   new_nt = NonTerminal.newInstance(pData);
                   new_nt.is_embedded_action = true; /* 24-Mar-1998, CSA */
  
  
  
  1.1.2.2   +1 -1      ws-jaxme/src/js/org/apache/ws/jaxme/js/cup/Attic/ParseActionTable.java
  
  Index: ParseActionTable.java
  ===================================================================
  RCS file: /home/cvs/ws-jaxme/src/js/org/apache/ws/jaxme/js/cup/Attic/ParseActionTable.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- ParseActionTable.java	14 Feb 2004 21:12:59 -0000	1.1.2.1
  +++ ParseActionTable.java	15 Feb 2004 21:35:32 -0000	1.1.2.2
  @@ -141,7 +141,7 @@
                  * emit.not_reduced++;
                  */
                 /* give a warning if they haven't been turned off */
  -              if (!Emit.nowarn) {
  +              if (!pData.isSkippingWarnings()) {
                     System.err.println("*** Production \"" + 
                             prod.to_simple_string() + "\" never reduced");
                     Lexer.getLexer().warning_count++;
  
  
  
  1.1.2.2   +62 -101   ws-jaxme/src/js/org/apache/ws/jaxme/js/cup/Attic/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/ws-jaxme/src/js/org/apache/ws/jaxme/js/cup/Attic/Main.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- Main.java	14 Feb 2004 21:12:59 -0000	1.1.2.1
  +++ Main.java	15 Feb 2004 21:35:32 -0000	1.1.2.2
  @@ -105,8 +105,6 @@
    *   <dd> don't warn about useless productions, etc.
    *   <dt> -nosummary     
    *   <dd> don't print the usual summary of parse states, etc.
  - *   <dt> -progress      
  - *   <dd> print messages to indicate progress of the system
    *   <dt> -time          
    *   <dd> print time usage summary
    *   <dt> -dump_grammar  
  @@ -144,21 +142,6 @@
     /*-------------------------*/
     /* Options set by the user */
     /*-------------------------*/
  -  /** User option -- do we print progress messages. */
  -  protected static boolean print_progress   = true;
  -  /** User option -- do we produce a dump of the state machine */
  -  protected static boolean opt_dump_states  = false;
  -  /** User option -- do we produce a dump of the parse tables */
  -  protected static boolean opt_dump_tables  = false;
  -  /** User option -- do we produce a dump of the grammar */
  -  protected static boolean opt_dump_grammar = false;
  -  /** User option -- do we show timing information as a part of the summary */
  -  protected static boolean opt_show_timing  = false;
  -  /** User option -- do we run produce extra debugging messages */
  -  protected static boolean opt_do_debug     = false;
  -  /** User option -- do we compact tables by making most common reduce the 
  -      default action */
  -  protected static boolean opt_compact_red  = false;
     /** User option -- should we include non terminal symbol numbers in the 
         symbol constant class. */
     protected static boolean include_non_terms = false;
  @@ -167,10 +150,6 @@
     /** User option -- number of conflicts to expect */
     protected static int expect_conflicts = 0;
   
  -  /* frankf added this 6/18/96 */
  -  /** User option -- should generator generate code for left/right values? */
  -  protected static boolean lr_values = true;
  -
     /** User option -- should symbols be put in a class or an interface? [CSA]*/
     protected static boolean sym_interface = false;
   
  @@ -227,14 +206,9 @@
   
             /* process user options and arguments
              */
  -          File destDir = parse_args(argv);
  +          File destDir = parse_args(data, argv);
   
  -          /* frankf 6/18/96
  -           * hackish, yes, but works
  -           */
  -          Emit.set_lr_values(lr_values);
             /* open output files */
  -          if (print_progress) System.err.println("Opening files...");
             /* use a buffered version of standard input */
             lexer = new Lexer(new BufferedReader(new InputStreamReader(System.in)));
             Lexer.setLexer(lexer);
  @@ -242,8 +216,6 @@
             prelim_end = System.currentTimeMillis();
             
             /* parse spec into internal data structures */
  -          if (print_progress) 
  -              System.err.println("Parsing specification from standard input...");
             parse_grammar_spec(data);
             
             parse_end = System.currentTimeMillis();
  @@ -251,13 +223,11 @@
             /* don't proceed unless we are error free */
             if (lexer.error_count == 0) {
                 /* check for unused bits */
  -              if (print_progress) System.err.println("Checking specification...");
                 check_unused(data);
                 
                 check_end = System.currentTimeMillis();
                 
                /* build the state machine and parse tables */
  -              if (print_progress) System.err.println("Building parse tables...");
                 build_parser(data);
                 
                 build_end = System.currentTimeMillis();
  @@ -265,10 +235,9 @@
                 /* output the generated code, if # of conflicts permits */
                 if (lexer.error_count != 0) {
                     // conflicts! don't emit code, don't dump tables.
  -                  opt_dump_tables = false;
  +                  data.setDumpingTables(false);
                 } else { // everything's okay, emit parser.
  -                  if (print_progress) System.err.println("Writing parser...");
  -                  open_files(destDir);
  +                  open_files(data, destDir);
                     emit_parser(data);
                     did_output = true;
                 }
  @@ -277,9 +246,9 @@
             emit_end = System.currentTimeMillis();
             
             /* do requested dumps */
  -          if (opt_dump_grammar) dump_grammar(data);
  -          if (opt_dump_states)  dump_machine(data); 
  -          if (opt_dump_tables)  dump_tables(); 
  +          if (data.isDumpingGrammar()) dump_grammar(data);
  +          if (data.isDumpingStates())  dump_machine(data); 
  +          if (data.isDumpingTables())  dump_tables(); 
             
             dump_end = System.currentTimeMillis();
             
  @@ -292,7 +261,6 @@
                 Data.setData(null);
             }
             /* close input/output files */
  -          if (print_progress) System.err.println("Closing files...");
             close_files();
         }
             
  @@ -347,7 +315,7 @@
      *  flags and variables. 
      * @param argv the command line arguments to be parsed.
      */
  -  protected static File parse_args(String argv[]) {
  +  protected static File parse_args(Data pData, String argv[]) {
         int len = argv.length;
         int i;
         File destDir = null;
  @@ -362,7 +330,7 @@
                     usage("-package must have a name argument");
                 
                 /* record the name */
  -              Emit.package_name = argv[i];
  +              pData.setPackageName(argv[i]);
             } else if (argv[i].equals("-destDir")) {
                 /* must have an arg */
                 if (++i >= len || argv[i].startsWith("-") || 
  @@ -378,7 +346,7 @@
                     usage("-parser must have a name argument");
                 
                 /* record the name */
  -              Emit.parser_class_name = argv[i];
  +              pData.setClassName(argv[i]);
             } else if (argv[i].equals("-symbols")) {
                 /* must have an arg */
                 if (++i >= len || argv[i].startsWith("-") || 
  @@ -401,19 +369,21 @@
                 } catch (NumberFormatException e) {
                     usage("-expect must be followed by a decimal integer");
                 }
  -          } else if (argv[i].equals("-compact_red"))  opt_compact_red = true;
  +          } else if (argv[i].equals("-compact_red"))  pData.setCompactingTables(true);
             else if (argv[i].equals("-nosummary"))    no_summary = true;
  -          else if (argv[i].equals("-nowarn"))       Emit.nowarn = true;
  -          else if (argv[i].equals("-dump_states"))  opt_dump_states = true;
  -          else if (argv[i].equals("-dump_tables"))  opt_dump_tables = true; 
  -          else if (argv[i].equals("-progress"))     print_progress = true;
  -          else if (argv[i].equals("-dump_grammar")) opt_dump_grammar = true;
  -          else if (argv[i].equals("-dump")) 
  -              opt_dump_states = opt_dump_tables = opt_dump_grammar = true; 
  -          else if (argv[i].equals("-time"))         opt_show_timing = true; 
  -          else if (argv[i].equals("-debug"))        opt_do_debug = true;
  +          else if (argv[i].equals("-nowarn"))       pData.setSkippingWarnings(true);
  +          else if (argv[i].equals("-dump_states"))  pData.setDumpingStates(true);
  +          else if (argv[i].equals("-dump_tables"))  pData.setDumpingTables(true); 
  +          else if (argv[i].equals("-dump_grammar")) pData.setDumpingGrammar(true);
  +          else if (argv[i].equals("-dump")) {
  +              pData.setDumpingStates(true);
  +              pData.setDumpingTables(true);
  +              pData.setDumpingGrammar(true);
  +          }
  +          else if (argv[i].equals("-time"))         pData.setShowingTimes(true); 
  +          else if (argv[i].equals("-debug"))        pData.setDebugging(true);
             /* frankf 6/18/96 */
  -          else if (argv[i].equals("-nopositions"))  lr_values = false;
  +          else if (argv[i].equals("-nopositions"))  pData.setCreatingLrValues(false);
             /* CSA 12/21/97 */
             else if (argv[i].equals("-interface"))    sym_interface = true;
             /* CSA 23-Jul-1999 */
  @@ -452,11 +422,11 @@
     /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
   
     /** Open various files used by the system. */
  -  protected static void open_files(File destDir) {
  +  protected static void open_files(Data pData, File destDir) {
         File fil;
         String out_name;
         
  -      String packageName = Emit.package_name;
  +      String packageName = pData.getPackageName();
         if (packageName != null) {
             for (StringTokenizer st = new StringTokenizer(packageName, ".");  st.hasMoreTokens();  ) {
                 destDir = new File(destDir, st.nextToken());
  @@ -469,7 +439,7 @@
         /* open each of the output files */
         
         /* parser class */
  -      out_name = Emit.parser_class_name + ".java";
  +      out_name = Emit.getClassName(pData) + ".java";
         fil = new File(destDir, out_name);
         try {
             parser_class_file = new PrintWriter(
  @@ -517,7 +487,7 @@
           /* create a parser and parse with it */
           parser_obj = new Parser();
           try {
  -            if (opt_do_debug)
  +            if (pData.isDebugging())
                   parser_obj.debug_parse();
               else
                   parser_obj.parse();
  @@ -547,9 +517,8 @@
               /* is this one unused */
               if (term.use_count() == 0) {
                   /* count it and warn if we are doing warnings */
  -                Emit.unused_term++;
  -                if (!Emit.nowarn) 
  -                   {
  +                pData.incNumUnusedTerminals();
  +                if (!pData.isSkippingWarnings()) {
                       System.err.println("Warning: Terminal \"" + term.name() + 
                       "\" was declared but never used");
                       Lexer.getLexer().warning_count++;
  @@ -566,9 +535,8 @@
               if (nt.use_count() == 0)
                  {
                   /* count and warn if we are doing warnings */
  -                Emit.unused_term++;
  -                if (!Emit.nowarn) 
  -                   {
  +                pData.incNumUnusedNonTerminals();
  +                if (!pData.isSkippingWarnings()) {
                       System.err.println("Warning: Non terminal \"" + nt.name() + 
                       "\" was declared but never used");
                       Lexer.getLexer().warning_count++;
  @@ -602,28 +570,28 @@
        */
       protected static void build_parser(Data pData) {
           /* compute nullability of all non terminals */
  -        if (opt_do_debug || print_progress) 
  +        if (pData.isDebugging()) 
               System.err.println("  Computing non-terminal nullability...");
           NonTerminal.compute_nullability(pData);
           
           nullability_end = System.currentTimeMillis();
           
           /* compute first sets of all non terminals */
  -        if (opt_do_debug || print_progress) 
  +        if (pData.isDebugging()) 
               System.err.println("  Computing first sets...");
           NonTerminal.compute_first_sets(pData);
           
           first_end = System.currentTimeMillis();
           
           /* build the LR viable prefix recognition machine */
  -        if (opt_do_debug || print_progress) 
  +        if (pData.isDebugging()) 
               System.err.println("  Building state machine...");
  -        start_state = LalrState.build_machine(pData, Emit.start_production);
  +        start_state = LalrState.build_machine(pData, pData.getStartProduction());
           
           machine_end = System.currentTimeMillis();
           
           /* build the LR parser action and reduce-goto tables */
  -        if (opt_do_debug || print_progress) 
  +        if (pData.isDebugging()) 
               System.err.println("  Filling in tables...");
           action_table = new ParseActionTable(pData.getNumOfLalrStates(), pData.getNumOfTerminals());
           reduce_table = new ParseReduceTable(pData.getNumOfLalrStates(), pData.getNumOfNonTerminals());
  @@ -635,15 +603,14 @@
           table_end = System.currentTimeMillis();
           
           /* check and warn for non-reduced productions */
  -        if (opt_do_debug || print_progress) 
  +        if (pData.isDebugging()) 
               System.err.println("  Checking for non-reduced productions...");
           action_table.check_reductions(pData);
           
           reduce_check_end = System.currentTimeMillis();
           
           /* if we have more conflicts than we expected issue a message and die */
  -        if (Emit.num_conflicts > expect_conflicts)
  -           {
  +        if (pData.getNumConflicts() > expect_conflicts) {
               System.err.println("*** More conflicts encountered than expected " +
               "-- parser generation aborted");
               Lexer.getLexer().error_count++; // indicate the problem.
  @@ -655,7 +622,8 @@
       protected static void emit_parser(Data pData) {
           Emit.symbols(pData, symbol_class_file, include_non_terms, sym_interface);
           Emit.parser(pData, parser_class_file, action_table, reduce_table, 
  -                start_state.index(), Emit.start_production, opt_compact_red,
  +                start_state.index(), pData.getStartProduction(),
  +                pData.isCompactingTables(),
   				suppress_scanner);
       }
   
  @@ -700,28 +668,28 @@
           " unique parse states.");
           
           /* unused symbols */
  -        System.err.println("  " + Emit.unused_term + " terminal" + 
  -                plural(Emit.unused_term) + " declared but not used.");
  -        System.err.println("  " + Emit.unused_non_term + " non-terminal" + 
  -                plural(Emit.unused_term) + " declared but not used.");
  +        System.err.println("  " + pData.getNumUnusedTerminals() + " terminal" + 
  +                plural(pData.getNumUnusedTerminals()) + " declared but not used.");
  +        System.err.println("  " + pData.getNumUnusedNonTerminals() + " non-terminal" + 
  +                plural(pData.getNumUnusedNonTerminals()) + " declared but not used.");
           
           /* productions that didn't reduce */
  -        System.err.println("  " + Emit.not_reduced + " production" + 
  -                plural(Emit.not_reduced) + " never reduced.");
  +        System.err.println("  " + pData.getNumNotReduced() + " production" + 
  +                plural(pData.getNumNotReduced()) + " never reduced.");
           
           /* conflicts */
  -        System.err.println("  " + Emit.num_conflicts + " conflict" +
  -                plural(Emit.num_conflicts) + " detected" +
  +        System.err.println("  " + pData.getNumConflicts() + " conflict" +
  +                plural(pData.getNumConflicts()) + " detected" +
                   " (" + expect_conflicts + " expected).");
           
           /* code location */
           if (output_produced)
  -            System.err.println("  Code written to \"" + Emit.parser_class_name + 
  +            System.err.println("  Code written to \"" + Emit.getClassName(pData) + 
                       ".java\", and \"" + Emit.symbol_const_class_name + ".java\".");
           else
               System.err.println("  No code produced.");
           
  -        if (opt_show_timing) show_times();
  +        if (pData.isShowingTimes()) show_times(pData);
           
           System.err.println(
                   "---------------------------------------------------- (" + 
  @@ -731,8 +699,7 @@
     /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
   
     /** Produce the optional timing summary as part of an overall summary. */
  -  protected static void show_times()
  -    {
  +  protected static void show_times(Data pData) {
         long total_time = final_time - start_time;
   
         System.err.println(". . . . . . . . . . . . . . . . . . . . . . . . . ");
  @@ -767,24 +734,18 @@
         if (emit_end != 0 && build_end != 0)
           System.err.println("      Code Output    "
   	    + timestr(emit_end-build_end, total_time));
  -      if (Emit.symbols_time != 0)
  -	System.err.println("        Symbols      "
  -	    + timestr(Emit.symbols_time, total_time));
  -      if (Emit.parser_time != 0)
  -	System.err.println("        Parser class "
  -	    + timestr(Emit.parser_time, total_time));
  -      if (Emit.action_code_time != 0)
  -	System.err.println("          Actions    "
  -	    + timestr(Emit.action_code_time, total_time));
  -      if (Emit.production_table_time != 0)
  -	System.err.println("          Prod table "
  -	    + timestr(Emit.production_table_time, total_time));
  -      if (Emit.action_table_time != 0)
  -	System.err.println("          Action tab "
  -	    + timestr(Emit.action_table_time, total_time));
  -      if (Emit.goto_table_time != 0)
  -	System.err.println("          Reduce tab "
  -	    + timestr(Emit.goto_table_time, total_time));
  +      if (pData.getGeneratorTime() != 0)
  +          System.err.println("        Sources      "
  +                  + timestr(pData.getGeneratorTime(), total_time));
  +      if (pData.getProductionTableTime() != 0)
  +          System.err.println("          Prod table "
  +                  + timestr(pData.getProductionTableTime(), total_time));
  +      if (pData.getActionTableTime() != 0)
  +          System.err.println("          Action tab "
  +                  + timestr(pData.getActionTableTime(), total_time));
  +      if (pData.getGotoTableTime() != 0)
  +          System.err.println("          Reduce tab "
  +                  + timestr(pData.getGotoTableTime(), total_time));
   
         System.err.println("      Dump Output    "
   	+ timestr(dump_end-emit_end, total_time));
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org