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