Top Description Fields Constructors Methods
java_cup

public abstract Class symbol

extends Object
Class Inheritance
Known Direct Subclasses
java_cup.terminal, java_cup.non_terminal

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).
Author
Frank Flannery
Version
last updated: 7/3/96
See Also
java_cup.terminal, java_cup.non_terminal

Field Summary

Modifier and TypeField and Description
protected int
_index

Index of this symbol (terminal or non terminal) in the parse tables.

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.

Constructor Summary

AccessConstructor and Description
public
symbol(String
the name of the symbol.
nm
,
String
a string with the type name.
tp
)

Full constructor.

public
symbol(String
the name of the symbol.
nm
)

Constructor with default type.

Method Summary

Modifier and TypeMethod and Description
public int
index()

Index of this symbol (terminal or non terminal) in the parse tables.

public abstract boolean
is_non_term()

Indicate if this is a non-terminal.

public String
name()

String for the human readable name of the symbol.

public void
note_use()

Increment the use count.

public String
stack_type()

String for the type of object used for the symbol on the parse stack.

public String
toString()

Overrides java.lang.Object.toString.

Convert to a string.
public int
use_count()

Count of how many times the symbol appears in productions.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_indexback to summary
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.

_nameback to summary
protected String _name

String for the human readable name of the symbol.

_stack_typeback to summary
protected String _stack_type

String for the type of object used for the symbol on the parse stack.

_use_countback to summary
protected int _use_count

Count of how many times the symbol appears in productions.

Constructor Detail

symbolback to summary
public symbol(String nm, String tp)

Full constructor.

Parameters
nm:String

the name of the symbol.

tp:String

a string with the type name.

symbolback to summary
public symbol(String nm)

Constructor with default type.

Parameters
nm:String

the name of the symbol.

Method Detail

indexback to summary
public 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.

is_non_termback to summary
public abstract boolean is_non_term()

Indicate if this is a non-terminal. Here in the base class we don't know, so this is abstract.

nameback to summary
public String name()

String for the human readable name of the symbol.

note_useback to summary
public void note_use()

Increment the use count.

stack_typeback to summary
public String stack_type()

String for the type of object used for the symbol on the parse stack.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Convert to a string.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.

use_countback to summary
public int use_count()

Count of how many times the symbol appears in productions.