lalr_item

Overview | Package | Class | Tree | Deprecated | Index | Help | Weka's home

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## weka.core.parser.java_cup
Class lalr_item

    java.lang.Object
      weka.core.parser.java_cup.lr_item_core
          weka.core.parser.java_cup.lalr_item

    public class lalr_item

extends lr_item_core

This class represents an LALR item. Each LALR item consists of a production, a "dot" at a position within that production, and a set of lookahead symbols (terminal). (The first two of these parts are provide by the super class). An item is designed to represent a configuration that the parser may be in. For example, an item of the form:

        [A ::= B * C d E  , {a,b,c}]

indicates that the parser is in the middle of parsing the production

        A ::= B C d E

that B has already been parsed, and that we will expect to see a lookahead of either a, b, or c once the complete RHS of this production has been found.

Items may initially be missing some items from their lookahead sets. Links are maintained from each item to the set of items that would need to be updated if symbols are added to its lookahead set. During "lookahead propagation", we add symbols to various lookahead sets and propagate these changes across these dependency links as needed.

Version:
  last updated: 11/25/95
Author:
  Scott Hudson
See Also:
  `lalr_item_set`, `lalr_state`

Constructor Summary
`lalr_item(production prod)` Constructor with default position and empty lookahead set.
`lalr_item(production prod, int pos, terminal_set look)` Full constructor.
`lalr_item(production prod, terminal_set look)` Constructor with default position (dot at start).

Method Summary
`void` | `add_propagate(lalr_item prop_to)` Add a new item to the set of items we propagate to.
`terminal_set` | `calc_lookahead(terminal_set lookahead_after)` Calculate lookahead representing symbols that could appear after the symbol that the dot is currently in front of.
`boolean` | `equals(lalr_item other)` Equality comparison -- here we only require the cores to be equal since we need to do sets of items based only on core equality (ignoring lookahead sets).
`boolean` | `equals(java.lang.Object other)` Generic equality comparison.
`int` | `hashCode()` Return a hash code -- here we only hash the core since we only test core matching in LALR items.
`boolean` | `lookahead_visible()` Determine if everything from the symbol one beyond the dot all the way to the end of the right hand side is nullable.
`terminal_set` | `lookahead()` The lookahead symbols of the item.
`java.util.Stack` | `propagate_items()` Links to items that the lookahead needs to be propagated to
`void` | `propagate_lookaheads(terminal_set incoming)` Propagate incoming lookaheads through this item to others need to be changed.
`lalr_item` | `shift()` Produce the new lalr_item that results from shifting the dot one position to the right.
`java.lang.String` | `toString()` Convert to string.

Methods inherited from class weka.core.parser.java_cup.lr_item_core
`core_equals, core_hashCode, dot_at_end, dot_before_nt, dot_pos, equals, shift_core, symbol_after_dot, the_production, to_simple_string`

Methods inherited from class java.lang.Object
`getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### lalr_item

    public lalr_item(production prod,
                     int pos,
                     terminal_set look)
              throws internal_error

  Full constructor.

  Parameters:
    `prod` - the production for the item.
    `pos` - the position of the "dot" within the production.
    `look` - the set of lookahead symbols.
  Throws:
    `internal_error`

### lalr_item

    public lalr_item(production prod,
                     terminal_set look)
              throws internal_error

  Constructor with default position (dot at start).

  Parameters:
    `prod` - the production for the item.
    `look` - the set of lookahead symbols.
  Throws:
    `internal_error`

### lalr_item

    public lalr_item(production prod)
              throws internal_error

  Constructor with default position and empty lookahead set.

  Parameters:
    `prod` - the production for the item.
  Throws:
    `internal_error`

Method Detail

### lookahead

    public terminal_set lookahead()

  The lookahead symbols of the item.

### propagate_items

    public java.util.Stack propagate_items()

  Links to items that the lookahead needs to be propagated to

### add_propagate

    public void add_propagate(lalr_item prop_to)

  Add a new item to the set of items we propagate to.

### propagate_lookaheads

    public void propagate_lookaheads(terminal_set incoming)
                              throws internal_error

  Propagate incoming lookaheads through this item to others need to be changed.

  Throws:
    `internal_error`

### shift

    public lalr_item shift()
                    throws internal_error

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

  Throws:
    `internal_error`

### calc_lookahead

    public terminal_set calc_lookahead(terminal_set lookahead_after)
                                throws internal_error

  Calculate lookahead representing symbols that could appear after the symbol that the dot is currently in front of. Note: this routine must not be invoked before first sets and nullability has been calculated for all non terminals.

  Throws:
    `internal_error`

### lookahead_visible

    public boolean lookahead_visible()
                              throws internal_error

  Determine if everything from the symbol one beyond the dot all the way to the end of the right hand side is nullable. This would indicate that the lookahead of this item must be included in the lookaheads of all items produced as a closure of this item. Note: this routine should not be invoked until after first sets and nullability have been calculated for all non terminals.

  Throws:
    `internal_error`

### equals

    public boolean equals(lalr_item other)

  Equality comparison -- here we only require the cores to be equal since we need to do sets of items based only on core equality (ignoring lookahead sets).

### equals

    public boolean equals(java.lang.Object other)

  Generic equality comparison.

  Overrides:
    `equals` in class `lr_item_core`

### hashCode

    public int hashCode()

  Return a hash code -- here we only hash the core since we only test core matching in LALR items.

  Overrides:
    `hashCode` in class `lr_item_core`

### toString

    public java.lang.String toString()

  Convert to string.

  Overrides:
    `toString` in class `lr_item_core`

Overview | Package | Class | Tree | Deprecated | Index | Help | Weka's home

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD