Package java_cup
Class non_terminal
java.lang.Object
java_cup.symbol
java_cup.non_terminal
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
FieldsModifier and TypeFieldDescriptionprotected static Hashtable
Table of all non-terminals -- elements are stored using name strings as the keyprotected terminal_set
First set for this non-terminal.protected boolean
Nullability of this non terminal.protected Hashtable
Table of all productions with this non terminal on the LHS.protected static int
Static counter to assign unique indexes.protected static int
Static counter for creating unique non-terminal namesstatic final non_terminal
special non-terminal for start symbolFields inherited from class java_cup.symbol
_index, _name, _stack_type, _use_count
-
Constructor Summary
ConstructorsConstructorDescriptionnon_terminal
(String nm) Constructor with default type.non_terminal
(String nm, String tp) Full constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add_production
(production prod) Add a production to our set of productions.static Enumeration
all()
Access to all non-terminals.static void
Compute first sets for all non-terminals.static void
Compute nullability of all non-terminals.static non_terminal
lookup a non terminal by name stringFirst set for this non-terminal.boolean
Indicate that this symbol is a non-terminal.protected boolean
Test to see if this non terminal currently looks nullable.boolean
nullable()
Nullability of this non terminal.int
Total number of productions with this non terminal on the LHS.static int
number()
Total number of non-terminals.Access to productions with this non terminal on the LHS.toString()
convert to string
-
Field Details
-
_all
Table of all non-terminals -- elements are stored using name strings as the key -
next_index
protected static int next_indexStatic counter to assign unique indexes. -
next_nt
protected static int next_ntStatic counter for creating unique non-terminal names -
START_nt
special non-terminal for start symbol -
_productions
Table of all productions with this non terminal on the LHS. -
_nullable
protected boolean _nullableNullability of this non terminal. -
_first_set
First set for this non-terminal.
-
-
Constructor Details
-
non_terminal
Full constructor.- Parameters:
nm
- the name of the non terminal.tp
- the type string for the non terminal.
-
non_terminal
Constructor with default type.- Parameters:
nm
- the name of the non terminal.
-
-
Method Details
-
all
Access to all non-terminals. -
find
lookup a non terminal by name string -
number
public static int number()Total number of non-terminals. -
compute_nullability
Compute nullability of all non-terminals.- Throws:
internal_error
-
compute_first_sets
Compute first sets for all non-terminals. This assumes nullability has already computed.- Throws:
internal_error
-
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
Add a production to our set of productions.- Throws:
internal_error
-
nullable
public boolean nullable()Nullability of this non terminal. -
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_term
in classsymbol
-
looks_nullable
Test to see if this non terminal currently looks nullable.- Throws:
internal_error
-
toString
convert to string
-