java_cup

Class 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).

Version: last updated: 7/3/96

Author: Frank Flannery

See Also: terminal non_terminal

Field Summary
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
symbol(String nm, String tp)
Full constructor.
symbol(String nm)
Constructor with default type.
Method Summary
intindex()
Index of this symbol (terminal or non terminal) in the parse tables.
abstract booleanis_non_term()
Indicate if this is a non-terminal.
Stringname()
String for the human readable name of the symbol.
voidnote_use()
Increment the use count.
Stringstack_type()
String for the type of object used for the symbol on the parse stack.
StringtoString()
Convert to a string.
intuse_count()
Count of how many times the symbol appears in productions.

Field Detail

_index

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.

_name

protected String _name
String for the human readable name of the symbol.

_stack_type

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

_use_count

protected int _use_count
Count of how many times the symbol appears in productions.

Constructor Detail

symbol

public symbol(String nm, String tp)
Full constructor.

Parameters: nm the name of the symbol. tp a string with the type name.

symbol

public symbol(String nm)
Constructor with default type.

Parameters: nm the name of the symbol.

Method Detail

index

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_term

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.

name

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

note_use

public void note_use()
Increment the use count.

stack_type

public String stack_type()
String for the type of object used for the symbol on the parse stack.

toString

public String toString()
Convert to a string.

use_count

public int use_count()
Count of how many times the symbol appears in productions.