This class provides fairly conventional set oriented operations (union, sub/super-set tests, etc.), as well as an LALR "closure" operation (see compute_closure()).
java_cup.lalr_item , java_cup.lalr_state
| Modifier and Type | Field and Description |
|---|---|
| protected Hashtable | _all
A hash table to implement the set. |
| protected Integer | hashcode_cache
Cached hashcode for this set. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | lalr_item_set(lalr_item_set
indicates set we should copy from. other)Constructor for cloning from another set. |
| Modifier and Type | Method and Description |
|---|---|
| public lalr_item | |
| public void | add(lalr_item_set
the set to be added. other)Add a complete set, merging lookaheads where items are already in the set |
| public Enumeration | |
| public void | |
| public boolean | |
| public boolean | |
| public boolean | equals(Object
the reference object with which to compare. other)Overrides java. |
| public lalr_item | |
| public lalr_item | |
| public int | |
| public boolean | is_subset_of(lalr_item_set
the other set in question. other)Is this set an (improper) subset of another? |
| public boolean | is_superset_of(lalr_item_set
the other set in question. other)Is this set an (improper) superset of another? |
| protected void | |
| public void | |
| public void | |
| public int | |
| public String |
| _all | back to summary |
|---|---|
| protected Hashtable<K, V> _all A hash table to implement the set. We store the items using themselves as keys. | |
| hashcode_cache | back to summary |
|---|---|
| protected Integer hashcode_cache Cached hashcode for this set. | |
| lalr_item_set | back to summary |
|---|---|
| public lalr_item_set() Constructor for an empty set. | |
| lalr_item_set | back to summary |
|---|---|
| public lalr_item_set(lalr_item_set other) throws internal_error Constructor for cloning from another set.
| |
| add | back to summary |
|---|---|
| public lalr_item add(lalr_item itm) throws internal_error Add a singleton item, merging lookahead sets if the item is already part of the set. returns the element of the set that was added or merged into.
| |
| add | back to summary |
|---|---|
| public void add(lalr_item_set other) throws internal_error Add a complete set, merging lookaheads where items are already in the set
| |
| all | back to summary |
|---|---|
| public Enumeration Access to all elements of the set. | |
| compute_closure | back to summary |
|---|---|
| public void compute_closure() throws internal_error Compute the closure of the set using the LALR closure rules. Basically for every item of the form: [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. | |
| contains | back to summary |
|---|---|
| public boolean contains(lalr_item itm) Does the set contain a particular item?
| |
| equals | back to summary |
|---|---|
| public boolean equals(lalr_item_set other) Equality comparison. | |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Generic equality comparison.
| |
| find | back to summary |
|---|---|
| public lalr_item find(lalr_item itm) Return the item in the set matching a particular item (or null if not found)
| |
| get_one | back to summary |
|---|---|
| public lalr_item get_one() throws internal_error Remove and return one item from the set (done in hash order). | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Return hash code.
| |
| is_subset_of | back to summary |
|---|---|
| public boolean is_subset_of(lalr_item_set other) throws internal_error Is this set an (improper) subset of another?
| |
| is_superset_of | back to summary |
|---|---|
| public boolean is_superset_of(lalr_item_set other) throws internal_error Is this set an (improper) superset of another?
| |
| not_null | back to summary |
|---|---|
| protected void not_null(Object obj) throws internal_error Helper function for null test. Throws an interal_error exception if its parameter is null.
| |
| remove | back to summary |
|---|---|
| public void remove(lalr_item itm) throws internal_error Remove a single item if it is in the set.
| |
| remove | back to summary |
|---|---|
| public void remove(lalr_item_set other) throws internal_error Remove (set subtract) a complete set.
| |
| size | back to summary |
|---|---|
| public int size() Size of the set | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Convert to string.
| |