Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

Symbol.java

00001 package java_cup.runtime;
00002 
00003 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00004  * Bandera, a Java(TM) analysis and transformation toolkit           *
00005  * Copyright (C) 1998-2001 SAnToS Laboratories (santos@cis.ksu.edu)  *
00006 
00007  * All rights reserved.                                              *
00008  *                                                                   *
00009  * This work was done as a project in the SAnToS Laboratory,         *
00010  * Department of Computing and Information Sciences, Kansas State    *
00011  * University, USA (http://www.cis.ksu.edu/santos).                  *
00012  * It is understood that any modification not identified as such is  *
00013  * not covered by the preceding statement.                           *
00014  *                                                                   *
00015  * This work is free software; you can redistribute it and/or        *
00016  * modify it under the terms of the GNU Library General Public       *
00017  * License as published by the Free Software Foundation; either      *
00018  * version 2 of the License, or (at your option) any later version.  *
00019  *                                                                   *
00020  * This work is distributed in the hope that it will be useful,      *
00021  * but WITHOUT ANY WARRANTY; without even the implied warranty of    *
00022  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *
00023  * Library General Public License for more details.                  *
00024  *                                                                   *
00025  * You should have received a copy of the GNU Library General Public *
00026  * License along with this toolkit; if not, write to the             *
00027  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,      *
00028  * Boston, MA  02111-1307, USA.                                      *
00029  *                                                                   *
00030  * Java is a trademark of Sun Microsystems, Inc.                     *
00031  *                                                                   *
00032  * To submit a bug report, send a comment, or get the latest news on *
00033  * this project and other SAnToS projects, please visit the web-site *
00034  *                http://www.cis.ksu.edu/santos                      *
00035  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00036 /**
00037  * Defines the Symbol class, which is used to represent all terminals
00038  * and nonterminals while parsing.  The lexer should pass CUP Symbols 
00039  * and CUP returns a Symbol.
00040  *
00041  * @version last updated: 7/3/96
00042  * @author  Frank Flannery
00043  */
00044 
00045 /* ****************************************************************
00046   Class Symbol
00047   what the parser expects to receive from the lexer. 
00048   the token is identified as follows:
00049   sym:    the symbol type
00050   parse_state: the parse state.
00051   value:  is the lexical value of type Object
00052   left :  is the left position in the original input file
00053   right:  is the right position in the original input file
00054 ******************************************************************/
00055 
00056 public class Symbol {
00057 
00058 /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
00059 
00060   /** The symbol number of the terminal or non terminal being represented */
00061   public int sym;
00062 
00063   /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
00064 
00065   /** The parse state to be recorded on the parse stack with this symbol.
00066    *  This field is for the convenience of the parser and shouldn't be 
00067    *  modified except by the parser. 
00068    */
00069   public int parse_state;
00070   /** This allows us to catch some errors caused by scanners recycling
00071    *  symbols.  For the use of the parser only. [CSA, 23-Jul-1999] */
00072   boolean used_by_parser = false;
00073 
00074 /*******************************
00075   The data passed to parser
00076  *******************************/
00077 
00078   public int left, right;
00079   public Object value;
00080 
00081 /***********************************
00082   Constructor for no value or l,r
00083 ***********************************/
00084 
00085   public Symbol(int sym_num) {
00086     this(sym_num, -1);
00087     left = -1;
00088     right = -1;
00089     value = null;
00090   }  
00091 /***********************************
00092   Constructor to give a start state
00093 ***********************************/
00094   Symbol(int sym_num, int state)
00095     {
00096       sym = sym_num;
00097       parse_state = state;
00098     }
00099 /*****************************
00100   Constructor for no value
00101   ***************************/
00102 
00103   public Symbol(int id, int l, int r) {
00104     this(id, l, r, null);
00105   }  
00106 /*******************************
00107   Constructor for l,r values
00108  *******************************/
00109 
00110   public Symbol(int id, int l, int r, Object o) {
00111     this(id);
00112     left = l;
00113     right = r;
00114     value = o;
00115   }  
00116 /*******************************
00117   Constructor for no l,r values
00118 ********************************/
00119 
00120   public Symbol(int id, Object o) {
00121     this(id, -1, -1, o);
00122   }  
00123   /*****************************
00124     Printing this token out. (Override for pretty-print).
00125     ****************************/
00126   public String toString() { return "#"+sym; }  
00127 }

Generated at Thu Feb 7 06:56:04 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001