Package java_cup
Class non_terminal
- java.lang.Object
-
- java_cup.symbol
-
- java_cup.non_terminal
-
public class non_terminal extends symbol
This class represents a non-terminal symbol in the grammar. Each non 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 pushed on the parse stack to represent it).
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.Hashtable_allTable of all non-terminals -- elements are stored using name strings as the keyprotected terminal_set_first_setFirst set for this non-terminal.protected boolean_nullableNullability of this non terminal.protected java.util.Hashtable_productionsTable of all productions with this non terminal on the LHS.protected static intnext_indexStatic counter to assign unique indexes.protected static intnext_ntStatic counter for creating unique non-terminal namesstatic non_terminalSTART_ntspecial non-terminal for start symbol-
Fields inherited from class java_cup.symbol
_index, _name, _stack_type, _use_count
-
-
Constructor Summary
Constructors Constructor Description non_terminal(java.lang.String nm)Constructor with default type.non_terminal(java.lang.String nm, java.lang.String tp)Full constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd_production(production prod)Add a production to our set of productions.static java.util.Enumerationall()Access to all non-terminals.static voidcompute_first_sets()Compute first sets for all non-terminals.static voidcompute_nullability()Compute nullability of all non-terminals.static non_terminalfind(java.lang.String with_name)lookup a non terminal by name stringterminal_setfirst_set()First set for this non-terminal.booleanis_non_term()Indicate that this symbol is a non-terminal.protected booleanlooks_nullable()Test to see if this non terminal currently looks nullable.booleannullable()Nullability of this non terminal.intnum_productions()Total number of productions with this non terminal on the LHS.static intnumber()Total number of non-terminals.java.util.Enumerationproductions()Access to productions with this non terminal on the LHS.java.lang.StringtoString()convert to string
-
-
-
Field Detail
-
_all
protected static java.util.Hashtable _all
Table of all non-terminals -- elements are stored using name strings as the key
-
next_index
protected static int next_index
Static counter to assign unique indexes.
-
next_nt
protected static int next_nt
Static counter for creating unique non-terminal names
-
START_nt
public static final non_terminal START_nt
special non-terminal for start symbol
-
_productions
protected java.util.Hashtable _productions
Table of all productions with this non terminal on the LHS.
-
_nullable
protected boolean _nullable
Nullability of this non terminal.
-
_first_set
protected terminal_set _first_set
First set for this non-terminal.
-
-
Constructor Detail
-
non_terminal
public non_terminal(java.lang.String nm, java.lang.String tp)Full constructor.- Parameters:
nm- the name of the non terminal.tp- the type string for the non terminal.
-
non_terminal
public non_terminal(java.lang.String nm)
Constructor with default type.- Parameters:
nm- the name of the non terminal.
-
-
Method Detail
-
all
public static java.util.Enumeration all()
Access to all non-terminals.
-
find
public static non_terminal find(java.lang.String with_name)
lookup a non terminal by name string
-
number
public static int number()
Total number of non-terminals.
-
compute_nullability
public static void compute_nullability() throws internal_errorCompute nullability of all non-terminals.- Throws:
internal_error
-
compute_first_sets
public static void compute_first_sets() throws internal_errorCompute first sets for all non-terminals. This assumes nullability has already computed.- Throws:
internal_error
-
productions
public java.util.Enumeration productions()
Access to productions with this non terminal on the LHS.
-
num_productions
public int num_productions()
Total number of productions with this non terminal on the LHS.
-
add_production
public void add_production(production prod) throws internal_error
Add a production to our set of productions.- Throws:
internal_error
-
nullable
public boolean nullable()
Nullability of this non terminal.
-
first_set
public terminal_set first_set()
First set for this non-terminal.
-
is_non_term
public boolean is_non_term()
Indicate that this symbol is a non-terminal.- Specified by:
is_non_termin classsymbol
-
looks_nullable
protected boolean looks_nullable() throws internal_errorTest to see if this non terminal currently looks nullable.- Throws:
internal_error
-
-