Class Reduce

java.lang.Object
  |
  +--Action
        |
        +--Reduce

public class Reduce
extends Action

This class implements the reduce action specified in the LR parsing program from Figure 4.30 of the Dragon book.


Constructor Summary
Reduce(Production production)
          Constructs a reduce action involving the specified production.
 
Method Summary
 int process(LRTable T, LRStack stack, java.lang.String a, int ip)
          Performs the reduce actions specified in the LR parsing program from Figure 4.30 of the Dragon book:

pop 2*|beta| symbols off the stack
let s' be the new state now on top of the stack
push A then goto[s', A] on top of the stack
output the production A -> beta
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Reduce

public Reduce(Production production)
Constructs a reduce action involving the specified production.

Method Detail

toString

public java.lang.String toString()
Returns a string representation of this object.

Overrides:
toString in class java.lang.Object

process

public int process(LRTable T,
                   LRStack stack,
                   java.lang.String a,
                   int ip)
Performs the reduce actions specified in the LR parsing program from Figure 4.30 of the Dragon book:

pop 2*|beta| symbols off the stack
let s' be the new state now on top of the stack
push A then goto[s', A] on top of the stack
output the production A -> beta

Specified by:
process in class Action
Parameters:
T - LR parsing table
stack - the stack
a - the current input symbol (ignored)
ip - the current input-symbol pointer (ignored)
Returns:
ip as is