Top Description Fields Constructors Methods
java_cup

public Class lr_item_core

extends Object
Class Inheritance
Known Direct Subclasses
java_cup.lalr_item

The "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 E
 
This 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.
Author
Scott Hudson
Version
last updated: 11/25/95
See Also
java_cup.lalr_item, java_cup.lalr_item_set, java_cup.lalr_state

Field Summary

Modifier and TypeField and Description
protected int
_core_hash_cache

Cache of the hash code.

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.

protected symbol
_symbol_after_dot

Cache of symbol after the dot.

protected production
_the_production

The production for the item.

Constructor Summary

AccessConstructor and Description
public
lr_item_core(production
production this item uses.
prod
,
int
position of the "dot" within the item.
pos
)

Full constructor.

public
lr_item_core(production
production this item uses.
prod
)

Constructor for dot at start of right hand side.

Method Summary

Modifier and TypeMethod and Description
public boolean
core_equals(lr_item_core other)

Equality comparison for the core only.

public int
core_hashCode()

Hash code for the core (separated so we keep non overridden version).

public boolean
dot_at_end()

Is the dot at the end of the production?

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).

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.

public boolean
equals(lr_item_core other)

Equality comparison.

public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Generic equality comparison.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Hash code for the item.
protected int
obj_hash()

Return the hash code that object would have provided for us so we have a (nearly) unique id for debugging.

public lr_item_core
shift_core()

Produce a new lr_item_core that results from shifting the dot one position to the right.

public symbol
symbol_after_dot()

Return the symbol after the dot.

public production
the_production()

The production for the item.

public String
to_simple_string()

Convert to a string (separated out from toString() so we can call it from subclass that overrides toString()).

public String
toString()

Overrides java.lang.Object.toString.

Convert to a string
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

_core_hash_cacheback to summary
protected int _core_hash_cache

Cache of the hash code.

_dot_posback to summary
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.

_symbol_after_dotback to summary
protected symbol _symbol_after_dot

Cache of symbol after the dot.

_the_productionback to summary
protected production _the_production

The production for the item.

Constructor Detail

lr_item_coreback to summary
public lr_item_core(production prod, int pos) throws internal_error

Full constructor.

Parameters
prod:production

production this item uses.

pos:int

position of the "dot" within the item.

lr_item_coreback to summary
public lr_item_core(production prod) throws internal_error

Constructor for dot at start of right hand side.

Parameters
prod:production

production this item uses.

Method Detail

core_equalsback to summary
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.

core_hashCodeback to summary
public int core_hashCode()

Hash code for the core (separated so we keep non overridden version).

dot_at_endback to summary
public boolean dot_at_end()

Is the dot at the end of the production?

dot_before_ntback to summary
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).

dot_posback to summary
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.

equalsback to summary
public boolean equals(lr_item_core other)

Equality comparison.

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Generic equality comparison.

Parameters
other:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Hash code for the item.

Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object.

obj_hashback to summary
protected int obj_hash()

Return the hash code that object would have provided for us so we have a (nearly) unique id for debugging.

shift_coreback to summary
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.

symbol_after_dotback to summary
public symbol symbol_after_dot()

Return the symbol after the dot. If there is no symbol after the dot we return null.

the_productionback to summary
public production the_production()

The production for the item.

to_simple_stringback to summary
public String to_simple_string() throws internal_error

Convert to a string (separated out from toString() so we can call it from subclass that overrides toString()).

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Convert to a string

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.