4 /** This class serves as the base class for entries in a parse action table.
5 * Full entries will either be SHIFT(state_num), REDUCE(production), NONASSOC,
6 * or ERROR. Objects of this base class will default to ERROR, while
7 * the other three types will be represented by subclasses.
9 * @see java_cup.reduce_action
10 * @see java_cup.shift_action
11 * @version last updated: 7/2/96
12 * @author Frank Flannery
15 public class parse_action {
17 /*-----------------------------------------------------------*/
18 /*--- Constructor(s) ----------------------------------------*/
19 /*-----------------------------------------------------------*/
21 /** Simple constructor. */
24 /* nothing to do in the base class */
28 /*-----------------------------------------------------------*/
29 /*--- (Access to) Static (Class) Variables ------------------*/
30 /*-----------------------------------------------------------*/
32 /** Constant for action type -- error action. */
33 public static final int ERROR = 0;
35 /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
37 /** Constant for action type -- shift action. */
38 public static final int SHIFT = 1;
40 /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
42 /** Constants for action type -- reduce action. */
43 public static final int REDUCE = 2;
45 /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
47 /** Constants for action type -- reduce action. */
48 public static final int NONASSOC = 3;
50 /*-----------------------------------------------------------*/
51 /*--- General Methods ---------------------------------------*/
52 /*-----------------------------------------------------------*/
54 /** Quick access to the type -- base class defaults to error. */
55 public int kind() {return ERROR;}
57 /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
60 public boolean equals(parse_action other)
62 /* we match all error actions */
63 return other != null && other.kind() == ERROR;
66 /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
68 /** Generic equality test. */
69 public boolean equals(Object other)
71 if (other instanceof parse_action)
72 return equals((parse_action)other);
76 /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
78 /** Compute a hash code. */
81 /* all objects of this class hash together */
85 /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
87 /** Convert to string. */
88 public String toString() {return "ERROR";}
90 /*-----------------------------------------------------------*/