1
package java_cup.runtime;
4
* Defines the Symbol class, which is used to represent all terminals
5
* and nonterminals while parsing. The lexer should pass CUP Symbols
6
* and CUP returns a Symbol.
8
* @version last updated: 7/3/96
9
* @author Frank Flannery
12
/* ****************************************************************
14
what the parser expects to receive from the lexer.
15
the token is identified as follows:
17
parse_state: the parse state.
18
value: is the lexical value of type Object
19
left : is the left position in the original input file
20
right: is the right position in the original input file
21
******************************************************************/
25
/*******************************
26
Constructor for l,r values
27
*******************************/
29
public Symbol(int id, int l, int r, Object o) {
36
/*******************************
37
Constructor for no l,r values
38
********************************/
40
public Symbol(int id, Object o) {
44
/*****************************
45
Constructor for no value
46
***************************/
48
public Symbol(int id, int l, int r) {
52
/***********************************
53
Constructor for no value or l,r
54
***********************************/
56
public Symbol(int sym_num) {
63
/***********************************
64
Constructor to give a start state
65
***********************************/
66
Symbol(int sym_num, int state)
72
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
74
/** The symbol number of the terminal or non terminal being represented */
77
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
79
/** The parse state to be recorded on the parse stack with this symbol.
80
* This field is for the convenience of the parser and shouldn't be
81
* modified except by the parser.
83
public int parse_state;
84
/** This allows us to catch some errors caused by scanners recycling
85
* symbols. For the use of the parser only. [CSA, 23-Jul-1999] */
86
boolean used_by_parser = false;
88
/*******************************
89
The data passed to parser
90
*******************************/
92
public int left, right;
95
/*****************************
96
Printing this token out. (Override for pretty-print).
97
****************************/
98
public String toString() { return "#"+sym; }