java_cup

Class terminal

public class terminal extends symbol

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
static terminalerror
special terminal used for error recovery
static terminalEOF
Special terminal for end of input.
protected static intnext_index
Static counter to assign unique index.
protected static Hashtable_all
Table of all terminals.
protected static Hashtable_all_by_index
Table of all terminals indexed by their index number.
Constructor Summary
terminal(String nm, String tp, int precedence_side, int precedence_num)
Full constructor.
terminal(String nm, String tp)
Constructor for non-precedented terminal
terminal(String nm)
Constructor with default type.
Method Summary
static Enumerationall()
Access to all terminals.
static voidclear()
static terminalfind(String with_name)
Lookup a terminal by name string.
static terminalfind(int indx)
Lookup a terminal by index.
booleanis_non_term()
Report this symbol as not being a non-terminal.
static intnumber()
Total number of terminals.
intprecedence_num()
get the precedence of a terminal
intprecedence_side()
voidset_precedence(int p, int new_prec)
set the precedence of a terminal
StringtoString()
Convert to a string.

Field Detail

error

public static terminal error
special terminal used for error recovery

EOF

public static terminal EOF
Special terminal for end of input.

next_index

protected static int next_index
Static counter to assign unique index.

_all

protected static Hashtable _all
Table of all terminals. Elements are stored using name strings as the key

_all_by_index

protected static Hashtable _all_by_index
Table of all terminals indexed by their index number.

Constructor Detail

terminal

public terminal(String nm, String tp, int precedence_side, int precedence_num)
Full constructor.

Parameters: nm the name of the terminal. tp the type of the terminal.

terminal

public terminal(String nm, String tp)
Constructor for non-precedented terminal

terminal

public terminal(String nm)
Constructor with default type.

Parameters: nm the name of the terminal.

Method Detail

all

public static Enumeration all()
Access to all terminals.

clear

public static void clear()

find

public static terminal find(String with_name)
Lookup a terminal by name string.

find

public static terminal find(int indx)
Lookup a terminal by index.

is_non_term

public boolean is_non_term()
Report this symbol as not being a non-terminal.

number

public static int number()
Total number of terminals.

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

toString

public String toString()
Convert to a string.