|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava_cup.lalr_item_set
This class represents a set of LALR items. For purposes of building these sets, items are considered unique only if they have unique cores (i.e., ignoring differences in their lookahead sets).
This class provides fairly conventional set oriented operations (union, sub/super-set tests, etc.), as well as an LALR "closure" operation (see compute_closure()).
lalr_item
,
lalr_state
Field Summary | |
protected java.util.Hashtable |
_all
A hash table to implement the set. |
protected java.lang.Integer |
hashcode_cache
Cached hashcode for this set. |
Constructor Summary | |
lalr_item_set()
Constructor for an empty set. |
|
lalr_item_set(lalr_item_set other)
Constructor for cloning from another set. |
Method Summary | |
void |
add(lalr_item_set other)
Add a complete set, merging lookaheads where items are already in the set |
lalr_item |
add(lalr_item itm)
Add a singleton item, merging lookahead sets if the item is already part of the set. |
java.util.Enumeration |
all()
Access to all elements of the set. |
void |
compute_closure()
Compute the closure of the set using the LALR closure rules. |
boolean |
contains(lalr_item itm)
Does the set contain a particular item? |
boolean |
equals(lalr_item_set other)
Equality comparison. |
boolean |
equals(java.lang.Object other)
Generic equality comparison. |
lalr_item |
find(lalr_item itm)
Return the item in the set matching a particular item (or null if not found) |
lalr_item |
get_one()
Remove and return one item from the set (done in hash order). |
int |
hashCode()
Return hash code. |
boolean |
is_subset_of(lalr_item_set other)
Is this set an (improper) subset of another? |
boolean |
is_superset_of(lalr_item_set other)
Is this set an (improper) superset of another? |
protected void |
not_null(java.lang.Object obj)
Helper function for null test. |
void |
remove(lalr_item_set other)
Remove (set subtract) a complete set. |
void |
remove(lalr_item itm)
Remove a single item if it is in the set. |
int |
size()
Size of the set |
java.lang.String |
toString()
Convert to string. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.util.Hashtable _all
protected java.lang.Integer hashcode_cache
Constructor Detail |
public lalr_item_set()
public lalr_item_set(lalr_item_set other) throws internal_error
other
- indicates set we should copy from.Method Detail |
public java.util.Enumeration all()
public int size()
public boolean contains(lalr_item itm)
itm
- the item in question.public lalr_item find(lalr_item itm)
itm
- the item we are looking for.public boolean is_subset_of(lalr_item_set other) throws internal_error
other
- the other set in question.
internal_error
public boolean is_superset_of(lalr_item_set other) throws internal_error
other
- the other set in question.
internal_error
public lalr_item add(lalr_item itm) throws internal_error
itm
- the item being added.
internal_error
public void remove(lalr_item itm) throws internal_error
itm
- the item to remove.
internal_error
public void add(lalr_item_set other) throws internal_error
other
- the set to be added.
internal_error
public void remove(lalr_item_set other) throws internal_error
other
- the set to remove.
internal_error
public lalr_item get_one() throws internal_error
internal_error
protected void not_null(java.lang.Object obj) throws internal_error
obj
- the object we are testing.
internal_error
public void compute_closure() throws internal_error
[L ::= a *N alpha, l](where N is a a non terminal and alpha is a string of symbols) make sure there are also items of the form:
[N ::= *beta, first(alpha l)]corresponding to each production of N. Items with identical cores but differing lookahead sets are merged by creating a new item with the same core and the union of the lookahead sets (the LA in LALR stands for "lookahead merged" and this is where the merger is). This routine assumes that nullability and first sets have been computed for all productions before it is called.
internal_error
public boolean equals(lalr_item_set other)
public boolean equals(java.lang.Object other)
public int hashCode()
public java.lang.String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |