Top Description Fields Constructors Methods
java_cup

public Class non_terminal

extends symbol
Class Inheritance
Imports
java.util.Hashtable, .Enumeration

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).
Author
Scott Hudson
Version
last updated: 11/25/95

Field Summary

Modifier and TypeField and Description
protected static Hashtable<K, V>
_all

Table of all non-terminals -- elements are stored using name strings as the key

protected static Hashtable<K, V>
_all_by_index

Table of all non terminals indexed by their index number.

protected terminal_set
_first_set

First set for this non-terminal.

protected boolean
_nullable

Nullability of this non terminal.

protected Hashtable<K, V>
_productions

Table of all productions with this non terminal on the LHS.

public boolean
is_embedded_action

flag non-terminals created to embed action productions

protected static int
next_index

Static counter to assign unique indexes.

protected static int
next_nt

Static counter for creating unique non-terminal names

public static final non_terminal
START_nt

special non-terminal for start symbol

Inherited from java_cup.symbol:
_index_name_stack_type_use_count

Constructor Summary

AccessConstructor and Description
public
non_terminal(String
the name of the non terminal.
nm
,
String
the type string for the non terminal.
tp
)

Full constructor.

public
non_terminal(String
the name of the non terminal.
nm
)

Constructor with default type.

Method Summary

Modifier and TypeMethod and Description
public void
add_production(production prod)

Add a production to our set of productions.

public static Enumeration<E>
all()

Access to all non-terminals.

public static void
compute_first_sets()

Compute first sets for all non-terminals.

public static void
compute_nullability()

Compute nullability of all non-terminals.

pack-priv static non_terminal
create_new(String
base name to construct unique name from.
prefix
)

Method for creating a new uniquely named hidden non-terminal using the given string as a base for the name (or "NT$" if null is passed).

pack-priv static non_terminal
create_new()

static routine for creating a new uniquely named hidden non-terminal

public static non_terminal
find(String with_name)

lookup a non terminal by name string

public static non_terminal
find(int indx)

Lookup a non terminal by index.

public terminal_set
first_set()

First set for this non-terminal.

public boolean
is_non_term()

Implements abstract java_cup.symbol.is_non_term.

Indicate that this symbol is a non-terminal.
protected boolean
looks_nullable()

Test to see if this non terminal currently looks nullable.

public boolean
nullable()

Nullability of this non terminal.

public int
num_productions()

Total number of productions with this non terminal on the LHS.

public static int
number()

Total number of non-terminals.

public Enumeration<E>
productions()

Access to productions with this non terminal on the LHS.

public String
toString()

Overrides java_cup.symbol.toString.

convert to string
Inherited from java_cup.symbol:
indexnamenote_usestack_typeuse_count

Field Detail

_allback to summary
protected static Hashtable<K, V> _all

Table of all non-terminals -- elements are stored using name strings as the key

_all_by_indexback to summary
protected static Hashtable<K, V> _all_by_index

Table of all non terminals indexed by their index number.

_first_setback to summary
protected terminal_set _first_set

First set for this non-terminal.

_nullableback to summary
protected boolean _nullable

Nullability of this non terminal.

_productionsback to summary
protected Hashtable<K, V> _productions

Table of all productions with this non terminal on the LHS.

is_embedded_actionback to summary
public boolean is_embedded_action

flag non-terminals created to embed action productions

next_indexback to summary
protected static int next_index

Static counter to assign unique indexes.

next_ntback to summary
protected static int next_nt

Static counter for creating unique non-terminal names

START_ntback to summary
public static final non_terminal START_nt

special non-terminal for start symbol

Constructor Detail

non_terminalback to summary
public non_terminal(String nm, String tp)

Full constructor.

Parameters
nm:String

the name of the non terminal.

tp:String

the type string for the non terminal.

non_terminalback to summary
public non_terminal(String nm)

Constructor with default type.

Parameters
nm:String

the name of the non terminal.

Method Detail

add_productionback to summary
public void add_production(production prod) throws internal_error

Add a production to our set of productions.

allback to summary
public static Enumeration<E> all()

Access to all non-terminals.

compute_first_setsback to summary
public static void compute_first_sets() throws internal_error

Compute first sets for all non-terminals. This assumes nullability has already computed.

compute_nullabilityback to summary
public static void compute_nullability() throws internal_error

Compute nullability of all non-terminals.

create_newback to summary
pack-priv static non_terminal create_new(String prefix) throws internal_error

Method for creating a new uniquely named hidden non-terminal using the given string as a base for the name (or "NT$" if null is passed).

Parameters
prefix:String

base name to construct unique name from.

create_newback to summary
pack-priv static non_terminal create_new() throws internal_error

static routine for creating a new uniquely named hidden non-terminal

findback to summary
public static non_terminal find(String with_name)

lookup a non terminal by name string

findback to summary
public static non_terminal find(int indx)

Lookup a non terminal by index.

first_setback to summary
public terminal_set first_set()

First set for this non-terminal.

is_non_termback to summary
public boolean is_non_term()

Implements abstract java_cup.symbol.is_non_term.

Indicate that this symbol is a non-terminal.

looks_nullableback to summary
protected boolean looks_nullable() throws internal_error

Test to see if this non terminal currently looks nullable.

nullableback to summary
public boolean nullable()

Nullability of this non terminal.

num_productionsback to summary
public int num_productions()

Total number of productions with this non terminal on the LHS.

numberback to summary
public static int number()

Total number of non-terminals.

productionsback to summary
public Enumeration<E> productions()

Access to productions with this non terminal on the LHS.

toStringback to summary
public String toString()

Overrides java_cup.symbol.toString.

convert to string

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.