3 /** This class represents a transition in an LALR viable prefix recognition
4 * machine. Transitions can be under terminals for non-terminals. They are
5 * internally linked together into singly linked lists containing all the
6 * transitions out of a single state via the _next field.
8 * @see java_cup.lalr_state
9 * @version last updated: 11/25/95
10 * @author Scott Hudson
13 public class lalr_transition {
15 /*-----------------------------------------------------------*/
16 /*--- Constructor(s) ----------------------------------------*/
17 /*-----------------------------------------------------------*/
20 * @param on_sym symbol we are transitioning on.
21 * @param to_st state we transition to.
22 * @param nxt next transition in linked list.
24 public lalr_transition(symbol on_sym, lalr_state to_st, lalr_transition nxt)
29 throw new internal_error("Attempt to create transition on null symbol");
31 throw new internal_error("Attempt to create transition to null state");
39 /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
41 /** Constructor with null next.
42 * @param on_sym symbol we are transitioning on.
43 * @param to_st state we transition to.
45 public lalr_transition(symbol on_sym, lalr_state to_st) throws internal_error
47 this(on_sym, to_st, null);
50 /*-----------------------------------------------------------*/
51 /*--- (Access to) Instance Variables ------------------------*/
52 /*-----------------------------------------------------------*/
54 /** The symbol we make the transition on. */
55 protected symbol _on_symbol;
57 /** The symbol we make the transition on. */
58 public symbol on_symbol() {return _on_symbol;}
60 /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
62 /** The state we transition to. */
63 protected lalr_state _to_state;
65 /** The state we transition to. */
66 public lalr_state to_state() {return _to_state;}
68 /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
70 /** Next transition in linked list of transitions out of a state */
71 protected lalr_transition _next;
73 /** Next transition in linked list of transitions out of a state */
74 public lalr_transition next() {return _next;}
76 /*-----------------------------------------------------------*/
77 /*--- General Methods ---------------------------------------*/
78 /*-----------------------------------------------------------*/
80 /** Convert to a string. */
81 public String toString()
85 result = "transition on " + on_symbol().name() + " to state [";
86 result += _to_state.index();
92 /*-----------------------------------------------------------*/