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: private static final long serialVersionUID = 0L;
037:
038: /**
039: * An integer that describes the kind of this token. This numbering
040: * system is determined by JavaCCParser, and a table of these numbers is
041: * stored in the file ...Constants.java.
042: */
043: int kind;
044:
045: /**
046: * beginLine and beginColumn describe the position of the first character
047: * of this token; endLine and endColumn describe the position of the
048: * last character of this token.
049: */
050: int beginLine, beginColumn, endLine, endColumn;
051:
052: /**
053: * The string image of the token.
054: */
055: String image;
056:
057: /**
058: * A reference to the next regular (non-special) token from the input
059: * stream. If this is the last token from the input stream, or if the
060: * token manager has not read tokens beyond this one, this field is
061: * set to null. This is true only if this token is also a regular
062: * token. Otherwise, see below for a description of the contents of
063: * this field.
064: */
065: Token next;
066:
067: /**
068: * This field is used to access special tokens that occur prior to this
069: * token, but after the immediately preceding regular (non-special) token.
070: * If there are no such special tokens, this field is set to null.
071: * When there are more than one such special token, this field refers
072: * to the last of these special tokens, which in turn refers to the next
073: * previous special token through its specialToken field, and so on
074: * until the first special token (whose specialToken field is null).
075: * The next fields of special tokens refer to other special tokens that
076: * immediately follow it (without an intervening regular token). If there
077: * is no such token, this field is null.
078: */
079: Token specialToken;
080:
081: /**
082: * Returns the image.
083: */
084: public final String toString() {
085: return image;
086: }
087:
088: /**
089: * Returns a new Token object, by default. However, if you want, you
090: * can create and return subclass objects based on the value of ofKind.
091: * Simply add the cases to the switch for all those special cases.
092: * For example, if you have a subclass of Token called IDToken that
093: * you want to create if ofKind is ID, simlpy add something like :
094: *
095: * case MyParserConstants.ID : return new IDToken();
096: *
097: * to the following switch statement. Then you can cast matchedToken
098: * variable to the appropriate type and use it in your lexical actions.
099: */
100: static final Token newToken(int ofKind) {
101: switch (ofKind) {
102: default:
103: return new Token();
104: }
105: }
106:
107: }
|