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).
- Version:
- last updated: 11/25/95
- Author:
- Scott Hudson
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static HashtableTable of all non-terminals -- elements are stored using name strings as the keyprotected static HashtableTable of all non terminals indexed by their index number.protected terminal_setFirst set for this non-terminal.protected booleanNullability of this non terminal.protected HashtableTable of all productions with this non terminal on the LHS.booleanflag non-terminals created to embed action productionsprotected static intStatic counter to assign unique indexes.protected static intStatic counter for creating unique non-terminal namesstatic final non_terminalspecial 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 TypeMethodDescriptionvoidadd_production(production prod) Add a production to our set of productions.static Enumerationall()Access to all non-terminals.static voidclear()static voidCompute first sets for all non-terminals.static voidCompute nullability of all non-terminals.static non_terminalfind(int indx) Lookup a non terminal by index.static non_terminallookup a non terminal by name stringFirst set for this non-terminal.booleanIndicate that this symbol is a non-terminal.protected booleanTest to see if this non terminal currently looks nullable.booleannullable()Nullability of this non terminal.intTotal number of productions with this non terminal on the LHS.static intnumber()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 -
_all_by_index
Table of all non terminals indexed by their index number. -
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 -
is_embedded_action
public boolean is_embedded_actionflag non-terminals created to embed action productions -
_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
-
clear
public static void clear() -
all
Access to all non-terminals. -
find
lookup a non terminal by name string -
find
Lookup a non terminal by index. -
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_termin classsymbol
-
looks_nullable
Test to see if this non terminal currently looks nullable.- Throws:
internal_error
-
toString
convert to string
-