|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
|
|
package com.sun.java_cup.internal.runtime; |
|
|
|
/** |
|
* Defines the Symbol class, which is used to represent all terminals |
|
* and nonterminals while parsing. The lexer should pass CUP Symbols |
|
* and CUP returns a Symbol. |
|
* |
|
* @author Frank Flannery |
|
*/ |
|
|
|
/* **************************************************************** |
|
Class Symbol |
|
what the parser expects to receive from the lexer. |
|
the token is identified as follows: |
|
sym: the symbol type |
|
parse_state: the parse state. |
|
value: is the lexical value of type Object |
|
left : is the left position in the original input file |
|
right: is the right position in the original input file |
|
******************************************************************/ |
|
|
|
public class Symbol { |
|
|
|
/******************************* |
|
Constructor for l,r values |
|
*******************************/ |
|
|
|
public Symbol(int id, int l, int r, Object o) { |
|
this(id); |
|
left = l; |
|
right = r; |
|
value = o; |
|
} |
|
|
|
/******************************* |
|
Constructor for no l,r values |
|
********************************/ |
|
|
|
public Symbol(int id, Object o) { |
|
this(id); |
|
left = -1; |
|
right = -1; |
|
value = o; |
|
} |
|
|
|
/***************************** |
|
Constructor for no value |
|
***************************/ |
|
|
|
public Symbol(int sym_num, int l, int r) { |
|
sym = sym_num; |
|
left = l; |
|
right = r; |
|
value = null; |
|
} |
|
|
|
/*********************************** |
|
Constructor for no value or l,r |
|
***********************************/ |
|
|
|
public Symbol(int sym_num) { |
|
this(sym_num, -1); |
|
left = -1; |
|
right = -1; |
|
value = null; |
|
} |
|
|
|
|
|
|
|
***********************************/ |
|
public Symbol(int sym_num, int state) |
|
{ |
|
sym = sym_num; |
|
parse_state = state; |
|
} |
|
|
|
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ |
|
|
|
|
|
public int sym; |
|
|
|
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ |
|
|
|
|
|
|
|
|
|
*/ |
|
public int parse_state; |
|
|
|
* symbols. For the use of the parser only. [CSA, 23-Jul-1999] */ |
|
boolean used_by_parser = false; |
|
|
|
/******************************* |
|
The data passed to parser |
|
*******************************/ |
|
|
|
public int left, right; |
|
public Object value; |
|
|
|
|
|
|
|
****************************/ |
|
public String toString() { return "#"+sym; } |
|
} |