KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > java_cup > internal > lalr_transition


1 package com.sun.java_cup.internal;
2
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.
7  *
8  * @see com.sun.java_cup.internal.lalr_state
9  * @version last updated: 11/25/95
10  * @author Scott Hudson
11  *
12  */

13 public class lalr_transition {
14
15   /*-----------------------------------------------------------*/
16   /*--- Constructor(s) ----------------------------------------*/
17   /*-----------------------------------------------------------*/
18
19   /** Full constructor.
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.
23    */

24   public lalr_transition(symbol on_sym, lalr_state to_st, lalr_transition nxt)
25     throws internal_error
26     {
27       /* sanity checks */
28       if (on_sym == null)
29     throw new internal_error("Attempt to create transition on null symbol");
30       if (to_st == null)
31     throw new internal_error("Attempt to create transition to null state");
32
33       /* initialize */
34       _on_symbol = on_sym;
35       _to_state = to_st;
36       _next = nxt;
37     }
38
39   /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
40
41   /** Constructor with null next.
42    * @param on_sym symbol we are transitioning on.
43    * @param to_st state we transition to.
44    */

45   public lalr_transition(symbol on_sym, lalr_state to_st) throws internal_error
46     {
47       this(on_sym, to_st, null);
48     }
49
50   /*-----------------------------------------------------------*/
51   /*--- (Access to) Instance Variables ------------------------*/
52   /*-----------------------------------------------------------*/
53
54   /** The symbol we make the transition on. */
55   protected symbol _on_symbol;
56
57   /** The symbol we make the transition on. */
58   public symbol on_symbol() {return _on_symbol;}
59
60   /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
61
62   /** The state we transition to. */
63   protected lalr_state _to_state;
64
65   /** The state we transition to. */
66   public lalr_state to_state() {return _to_state;}
67
68   /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
69
70   /** Next transition in linked list of transitions out of a state */
71   protected lalr_transition _next;
72
73   /** Next transition in linked list of transitions out of a state */
74   public lalr_transition next() {return _next;}
75
76   /*-----------------------------------------------------------*/
77   /*--- General Methods ---------------------------------------*/
78   /*-----------------------------------------------------------*/
79
80   /** Convert to a string. */
81   public String JavaDoc toString()
82     {
83       String JavaDoc result;
84
85       result = "transition on " + on_symbol().name() + " to state [";
86       result += _to_state.index();
87       result += "]";
88
89       return result;
90     }
91
92   /*-----------------------------------------------------------*/
93 }
94
Popular Tags