1 
2 package java_cup.runtime;
3 
4 /** This class represents a (terminal or non-terminal) symbol that, among
5  *  other things can be placed on the parse stack.  Symbols are used to
6  *  keep track of state on the parse stack.  The symbol currently on top
7  *  of the stack contains the current state in the parse_state field.
8  *  In addition to the parse_state field, symbols also maintain a record
9  *  of the symbol number that they represent in the sym field.  Finally,
10  *  symbols are used contain to any attributes used by semantic action (this
11  *  is done via fields added in subclasses -- see for example, int_token and
12  *  str_token).
13  *
14  * @see java_cup.runtime.token
15  * @see java_cup.runtime.int_token
16  * @see java_cup.runtime.str_token
17  * @version last updated: 11/25/95
18  * @author  Scott Hudson
19  */
20 
21 public class symbol {
22 
23   /** Full constructor. */
symbol(int sym_num, int state)24   public symbol(int sym_num, int state)
25     {
26       sym = sym_num;
27       parse_state = state;
28     }
29 
30   /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
31 
32   /** Constructor without a known state. */
symbol(int sym_num)33   public symbol(int sym_num)
34     {
35       this(sym_num, -1);
36     }
37 
38   /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
39 
40   /** The symbol number of the terminal or non terminal being represented */
41   public int sym;
42 
43   /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
44 
45   /** The parse state to be recorded on the parse stack with this symbol.
46    *  This field is for the convenience of the parser and shouldn't be
47    *  modified except by the parser.
48    */
49   public int parse_state;
50 };
51