1. package com.sun.java_cup.internal;
  2. /** This class serves as the base class for entries in a parse action table.
  3. * Full entries will either be SHIFT(state_num), REDUCE(production), NONASSOC,
  4. * or ERROR. Objects of this base class will default to ERROR, while
  5. * the other three types will be represented by subclasses.
  6. *
  7. * @see com.sun.java_cup.internal.reduce_action
  8. * @see com.sun.java_cup.internal.shift_action
  9. * @version last updated: 7/2/96
  10. * @author Frank Flannery
  11. */
  12. public class parse_action {
  13. /*-----------------------------------------------------------*/
  14. /*--- Constructor(s) ----------------------------------------*/
  15. /*-----------------------------------------------------------*/
  16. /** Simple constructor. */
  17. public parse_action()
  18. {
  19. /* nothing to do in the base class */
  20. }
  21. /*-----------------------------------------------------------*/
  22. /*--- (Access to) Static (Class) Variables ------------------*/
  23. /*-----------------------------------------------------------*/
  24. /** Constant for action type -- error action. */
  25. public static final int ERROR = 0;
  26. /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  27. /** Constant for action type -- shift action. */
  28. public static final int SHIFT = 1;
  29. /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  30. /** Constants for action type -- reduce action. */
  31. public static final int REDUCE = 2;
  32. /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  33. /** Constants for action type -- reduce action. */
  34. public static final int NONASSOC = 3;
  35. /*-----------------------------------------------------------*/
  36. /*--- General Methods ---------------------------------------*/
  37. /*-----------------------------------------------------------*/
  38. /** Quick access to the type -- base class defaults to error. */
  39. public int kind() {return ERROR;}
  40. /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  41. /** Equality test. */
  42. public boolean equals(parse_action other)
  43. {
  44. /* we match all error actions */
  45. return other != null && other.kind() == ERROR;
  46. }
  47. /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  48. /** Generic equality test. */
  49. public boolean equals(Object other)
  50. {
  51. if (other instanceof parse_action)
  52. return equals((parse_action)other);
  53. else
  54. return false;
  55. }
  56. /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  57. /** Compute a hash code. */
  58. public int hashCode()
  59. {
  60. /* all objects of this class hash together */
  61. return 0xCafe123;
  62. }
  63. /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
  64. /** Convert to string. */
  65. public String toString() {return "ERROR";}
  66. /*-----------------------------------------------------------*/
  67. }