Package java_cup
Class lr_item_core
- java.lang.Object
-
- java_cup.lr_item_core
-
- Direct Known Subclasses:
lalr_item
public class lr_item_core extends java.lang.ObjectThe "core" of an LR item. This includes a production and the position of a marker (the "dot") within the production. Typically item cores are written using a production with an embedded "dot" to indicate their position. For example:A ::= B * C d EThis represents a point in a parse where the parser is trying to match the given production, and has succeeded in matching everything before the "dot" (and hence is expecting to see the symbols after the dot next). See lalr_item, lalr_item_set, and lalr_start for full details on the meaning and use of items.- Version:
- last updated: 11/25/95
- Author:
- Scott Hudson
- See Also:
lalr_item,lalr_item_set,lalr_state
-
-
Field Summary
Fields Modifier and Type Field Description protected int_core_hash_cacheCache of the hash code.protected int_dot_posThe position of the "dot" -- this indicates the part of the production that the marker is before, so 0 indicates a dot at the beginning of the RHS.protected symbol_symbol_after_dotCache of symbol after the dot.protected production_the_productionThe production for the item.
-
Constructor Summary
Constructors Constructor Description lr_item_core(production prod)Constructor for dot at start of right hand side.lr_item_core(production prod, int pos)Full constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancore_equals(lr_item_core other)Equality comparison for the core only.intcore_hashCode()Hash code for the core (separated so we keep non overridden version).booleandot_at_end()Is the dot at the end of the production?non_terminaldot_before_nt()Determine if we have a dot before a non terminal, and if so which one (return null or the non terminal).intdot_pos()The position of the "dot" -- this indicates the part of the production that the marker is before, so 0 indicates a dot at the beginning of the RHS.booleanequals(lr_item_core other)Equality comparison.booleanequals(java.lang.Object other)Generic equality comparison.inthashCode()Hash code for the item.protected intobj_hash()Return the hash code that object would have provided for us so we have a (nearly) unique id for debugging.lr_item_coreshift_core()Produce a new lr_item_core that results from shifting the dot one position to the right.symbolsymbol_after_dot()Return the symbol after the dot.productionthe_production()The production for the item.java.lang.Stringto_simple_string()Convert to a string (separated out from toString() so we can call it from subclass that overrides toString()).java.lang.StringtoString()Convert to a string
-
-
-
Field Detail
-
_the_production
protected production _the_production
The production for the item.
-
_dot_pos
protected int _dot_pos
The position of the "dot" -- this indicates the part of the production that the marker is before, so 0 indicates a dot at the beginning of the RHS.
-
_core_hash_cache
protected int _core_hash_cache
Cache of the hash code.
-
_symbol_after_dot
protected symbol _symbol_after_dot
Cache of symbol after the dot.
-
-
Constructor Detail
-
lr_item_core
public lr_item_core(production prod, int pos) throws internal_error
Full constructor.- Parameters:
prod- production this item uses.pos- position of the "dot" within the item.- Throws:
internal_error
-
lr_item_core
public lr_item_core(production prod) throws internal_error
Constructor for dot at start of right hand side.- Parameters:
prod- production this item uses.- Throws:
internal_error
-
-
Method Detail
-
the_production
public production the_production()
The production for the item.
-
dot_pos
public int dot_pos()
The position of the "dot" -- this indicates the part of the production that the marker is before, so 0 indicates a dot at the beginning of the RHS.
-
dot_at_end
public boolean dot_at_end()
Is the dot at the end of the production?
-
symbol_after_dot
public symbol symbol_after_dot()
Return the symbol after the dot. If there is no symbol after the dot we return null.
-
dot_before_nt
public non_terminal dot_before_nt()
Determine if we have a dot before a non terminal, and if so which one (return null or the non terminal).
-
shift_core
public lr_item_core shift_core() throws internal_error
Produce a new lr_item_core that results from shifting the dot one position to the right.- Throws:
internal_error
-
core_equals
public boolean core_equals(lr_item_core other)
Equality comparison for the core only. This is separate out because we need separate access in a super class.
-
equals
public boolean equals(lr_item_core other)
Equality comparison.
-
equals
public boolean equals(java.lang.Object other)
Generic equality comparison.- Overrides:
equalsin classjava.lang.Object
-
core_hashCode
public int core_hashCode()
Hash code for the core (separated so we keep non overridden version).
-
hashCode
public int hashCode()
Hash code for the item.- Overrides:
hashCodein classjava.lang.Object
-
obj_hash
protected int obj_hash()
Return the hash code that object would have provided for us so we have a (nearly) unique id for debugging.
-
to_simple_string
public java.lang.String to_simple_string() throws internal_errorConvert to a string (separated out from toString() so we can call it from subclass that overrides toString()).- Throws:
internal_error
-
toString
public java.lang.String toString()
Convert to a string- Overrides:
toStringin classjava.lang.Object
-
-