|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava_cup.symbol
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).
terminal
,
non_terminal
Field Summary | |
protected int |
_index
Index of this symbol (terminal or non terminal) in the parse tables. |
protected java.lang.String |
_name
String for the human readable name of the symbol. |
protected java.lang.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. |
Constructor Summary | |
symbol(java.lang.String nm)
Constructor with default type. |
|
symbol(java.lang.String nm,
java.lang.String tp)
Full constructor. |
Method Summary | |
int |
index()
Index of this symbol (terminal or non terminal) in the parse tables. |
abstract boolean |
is_non_term()
Indicate if this is a non-terminal. |
java.lang.String |
name()
String for the human readable name of the symbol. |
void |
note_use()
Increment the use count. |
java.lang.String |
stack_type()
String for the type of object used for the symbol on the parse stack. |
java.lang.String |
toString()
Convert to a string. |
int |
use_count()
Count of how many times the symbol appears in productions. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.lang.String _name
protected java.lang.String _stack_type
protected int _use_count
protected int _index
Constructor Detail |
public symbol(java.lang.String nm, java.lang.String tp)
nm
- the name of the symbol.tp
- a string with the type name.public symbol(java.lang.String nm)
nm
- the name of the symbol.Method Detail |
public java.lang.String name()
public java.lang.String stack_type()
public int use_count()
public void note_use()
public int index()
public abstract boolean is_non_term()
public java.lang.String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |