Package java_cup
Class terminal
java.lang.Object
java_cup.symbol
java_cup.terminal
This class represents a terminal symbol in the grammar. Each terminal
has a textual name, an index, and a string which indicates the type of
object it will be implemented with at runtime (i.e. the class of object
that will be returned by the scanner and pushed on the parse stack to
represent it).
- Version:
- last updated: 7/3/96
- Author:
- Frank Flannery
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static Hashtable
Table of all terminals.protected static Hashtable
Table of all terminals indexed by their index number.static terminal
Special terminal for end of input.static terminal
special terminal used for error recoveryprotected static int
Static counter to assign unique index.Fields inherited from class java_cup.symbol
_index, _name, _stack_type, _use_count
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Enumeration
all()
Access to all terminals.static void
clear()
static terminal
find
(int indx) Lookup a terminal by index.static terminal
Lookup a terminal by name string.boolean
Report this symbol as not being a non-terminal.static int
number()
Total number of terminals.int
get the precedence of a terminalint
void
set_precedence
(int p, int new_prec) set the precedence of a terminaltoString()
Convert to a string.
-
Field Details
-
_all
Table of all terminals. Elements are stored using name strings as the key -
_all_by_index
Table of all terminals indexed by their index number. -
next_index
protected static int next_indexStatic counter to assign unique index. -
EOF
Special terminal for end of input. -
error
special terminal used for error recovery
-
-
Constructor Details
-
terminal
Full constructor.- Parameters:
nm
- the name of the terminal.tp
- the type of the terminal.
-
terminal
Constructor for non-precedented terminal -
terminal
Constructor with default type.- Parameters:
nm
- the name of the terminal.
-
-
Method Details
-
clear
public static void clear() -
all
Access to all terminals. -
find
Lookup a terminal by name string. -
find
Lookup a terminal by index. -
number
public static int number()Total number of terminals. -
is_non_term
public boolean is_non_term()Report this symbol as not being a non-terminal.- Specified by:
is_non_term
in classsymbol
-
toString
Convert to a string. -
precedence_num
public int precedence_num()get the precedence of a terminal -
precedence_side
public int precedence_side() -
set_precedence
public void set_precedence(int p, int new_prec) set the precedence of a terminal
-