001 /** 002 * ========================================= 003 * LibFormula : a free Java formula library 004 * ========================================= 005 * 006 * Project Info: http://reporting.pentaho.org/libformula/ 007 * 008 * (C) Copyright 2006-2007, by Pentaho Corporation and Contributors. 009 * 010 * This library is free software; you can redistribute it and/or modify it under the terms 011 * of the GNU Lesser General Public License as published by the Free Software Foundation; 012 * either version 2.1 of the License, or (at your option) any later version. 013 * 014 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 015 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 016 * See the GNU Lesser General Public License for more details. 017 * 018 * You should have received a copy of the GNU Lesser General Public License along with this 019 * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 020 * Boston, MA 02111-1307, USA. 021 * 022 * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 023 * in the United States and other countries.] 024 * 025 * 026 * ------------ 027 * $Id: Token.java 3521 2007-10-16 10:55:14Z tmorgner $ 028 * ------------ 029 * (C) Copyright 2006-2007, by Pentaho Corporation. 030 */ 031 032 /* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */ 033 package org.jfree.formula.parser; 034 035 /** 036 * Describes the input token stream. 037 */ 038 039 public class Token { 040 041 /** 042 * An integer that describes the kind of this token. This numbering 043 * system is determined by JavaCCParser, and a table of these numbers is 044 * stored in the file ...Constants.java. 045 */ 046 public int kind; 047 048 /** 049 * beginLine and beginColumn describe the position of the first character 050 * of this token; endLine and endColumn describe the position of the 051 * last character of this token. 052 */ 053 public int beginLine; 054 public int beginColumn; 055 public int endLine; 056 public int endColumn; 057 058 /** 059 * The string image of the token. 060 */ 061 public String image; 062 063 /** 064 * A reference to the next regular (non-special) token from the input 065 * stream. If this is the last token from the input stream, or if the 066 * token manager has not read tokens beyond this one, this field is 067 * set to null. This is true only if this token is also a regular 068 * token. Otherwise, see below for a description of the contents of 069 * this field. 070 */ 071 public Token next; 072 073 /** 074 * This field is used to access special tokens that occur prior to this 075 * token, but after the immediately preceding regular (non-special) token. 076 * If there are no such special tokens, this field is set to null. 077 * When there are more than one such special token, this field refers 078 * to the last of these special tokens, which in turn refers to the next 079 * previous special token through its specialToken field, and so on 080 * until the first special token (whose specialToken field is null). 081 * The next fields of special tokens refer to other special tokens that 082 * immediately follow it (without an intervening regular token). If there 083 * is no such token, this field is null. 084 */ 085 public Token specialToken; 086 087 public Token() 088 { 089 } 090 091 /** 092 * Returns the image. 093 */ 094 public String toString() 095 { 096 return image; 097 } 098 099 /** 100 * Returns a new Token object, by default. However, if you want, you 101 * can create and return subclass objects based on the value of ofKind. 102 * Simply add the cases to the switch for all those special cases. 103 * For example, if you have a subclass of Token called IDToken that 104 * you want to create if ofKind is ID, simlpy add something like : 105 * 106 * case MyParserConstants.ID : return new IDToken(); 107 * 108 * to the following switch statement. Then you can cast matchedToken 109 * variable to the appropriate type and use it in your lexical actions. 110 */ 111 public static Token newToken(final int ofKind) 112 { 113 switch(ofKind) 114 { 115 default : return new Token(); 116 } 117 } 118 119 }