4 /** This class represents a shift action within the parse table.
5 * The action simply stores the state that it shifts to and responds
6 * to queries about its type.
8 * @version last updated: 11/25/95
11 public class shift_action extends parse_action {
13 /*-----------------------------------------------------------*/
14 /*--- Constructor(s) ----------------------------------------*/
15 /*-----------------------------------------------------------*/
17 /** Simple constructor.
18 * @param shft_to the state that this action shifts to.
20 public shift_action(lalr_state shft_to) throws internal_error
24 throw new internal_error(
25 "Attempt to create a shift_action to a null state");
30 /*-----------------------------------------------------------*/
31 /*--- (Access to) Instance Variables ------------------------*/
32 /*-----------------------------------------------------------*/
34 /** The state we shift to. */
35 protected lalr_state _shift_to;
37 /** The state we shift to. */
38 public lalr_state shift_to() {return _shift_to;}
40 /*-----------------------------------------------------------*/
41 /*--- General Methods ---------------------------------------*/
42 /*-----------------------------------------------------------*/
44 /** Quick access to type of action. */
45 public int kind() {return SHIFT;}
47 /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
50 public boolean equals(shift_action other)
52 return other != null && other.shift_to() == shift_to();
55 /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
57 /** Generic equality test. */
58 public boolean equals(Object other)
60 if (other instanceof shift_action)
61 return equals((shift_action)other);
66 /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
68 /** Compute a hash code. */
71 /* use the hash code of the state we are shifting to */
72 return shift_to().hashCode();
75 /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
77 /** Convert to a string. */
78 public String toString() {return "SHIFT(to state " + shift_to().index() + ")";}
80 /*-----------------------------------------------------------*/