FileDocCategorySizeDatePackage
symbol.javaAPI DocJava SE 5 API3668Fri Aug 26 14:54:54 BST 2005com.sun.java_cup.internal

symbol

public abstract class symbol extends Object
This abstract class serves as the base class for grammar symbols (i.e., both terminals and non-terminals). Each symbol has a name string, and a string giving the type of object that the symbol will be represented by on the runtime parse stack. In addition, each symbol maintains a use count in order to detect symbols that are declared but never used, and an index number that indicates where it appears in parse tables (index numbers are unique within terminals or non terminals, but not across both).
see
com.sun.java_cup.internal.terminal
see
com.sun.java_cup.internal.non_terminal
version
last updated: 7/3/96
author
Frank Flannery

Fields Summary
protected String
_name
String for the human readable name of the symbol.
protected String
_stack_type
String for the type of object used for the symbol on the parse stack.
protected int
_use_count
Count of how many times the symbol appears in productions.
protected int
_index
Index of this symbol (terminal or non terminal) in the parse tables. Note: indexes are unique among terminals and unique among non terminals, however, a terminal may have the same index as a non-terminal, etc.
Constructors Summary
public symbol(String nm, String tp)
Full constructor.

param
nm the name of the symbol.
param
tp a string with the type name.

       /* sanity check */
       if (nm == null) nm = "";

       /* apply default if no type given */
       if (tp == null) tp = "Object";

       _name = nm;
       _stack_type = tp;
     
public symbol(String nm)
Constructor with default type.

param
nm the name of the symbol.

       this(nm, null);
     
Methods Summary
public intindex()
Index of this symbol (terminal or non terminal) in the parse tables. Note: indexes are unique among terminals and unique among non terminals, however, a terminal may have the same index as a non-terminal, etc.

return _index;
public abstract booleanis_non_term()
Indicate if this is a non-terminal. Here in the base class we don't know, so this is abstract.

public java.lang.Stringname()
String for the human readable name of the symbol.

return _name;
public voidnote_use()
Increment the use count.

_use_count++;
public java.lang.Stringstack_type()
String for the type of object used for the symbol on the parse stack.

return _stack_type;
public java.lang.StringtoString()
Convert to a string.

      return name();
    
public intuse_count()
Count of how many times the symbol appears in productions.


              
      return _use_count;