KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejen > util > arl > Token


1 /* Generated By:JavaCC: Do not edit this line. Token.java Version 2.1 */
2 //
3
// Ejen (code generation system)
4
// Copyright (C) 2001, 2002 François Wolff (ejen@noos.fr).
5
//
6
// This file is part of Ejen.
7
//
8
// Ejen is free software; you can redistribute it and/or modify
9
// it under the terms of the GNU General Public License as published by
10
// the Free Software Foundation; either version 2 of the License, or
11
// (at your option) any later version.
12
//
13
// Ejen is distributed in the hope that it will be useful,
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
// GNU General Public License for more details.
17
//
18
// You should have received a copy of the GNU General Public License
19
// along with Ejen; if not, write to the Free Software
20
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
//
22
package org.ejen.util.arl;
23
24 /**
25  * Describes the input token stream.
26  */

27 public class Token {
28
29     /**
30      * An integer that describes the kind of this token. This numbering
31      * system is determined by JavaCCParser, and a table of these numbers is
32      * stored in the file ...Constants.java.
33      */

34     public int kind;
35
36     /**
37      * beginLine and beginColumn describe the position of the first character
38      * of this token; endLine and endColumn describe the position of the
39      * last character of this token.
40      */

41     public int beginLine, beginColumn, endLine, endColumn;
42
43     /**
44      * The string image of the token.
45      */

46     public String JavaDoc image;
47
48     /**
49      * A reference to the next regular (non-special) token from the input
50      * stream. If this is the last token from the input stream, or if the
51      * token manager has not read tokens beyond this one, this field is
52      * set to null. This is true only if this token is also a regular
53      * token. Otherwise, see below for a description of the contents of
54      * this field.
55      */

56     public Token next;
57
58     /**
59      * This field is used to access special tokens that occur prior to this
60      * token, but after the immediately preceding regular (non-special) token.
61      * If there are no such special tokens, this field is set to null.
62      * When there are more than one such special token, this field refers
63      * to the last of these special tokens, which in turn refers to the next
64      * previous special token through its specialToken field, and so on
65      * until the first special token (whose specialToken field is null).
66      * The next fields of special tokens refer to other special tokens that
67      * immediately follow it (without an intervening regular token). If there
68      * is no such token, this field is null.
69      */

70     public Token specialToken;
71
72     /**
73      * Returns the image.
74      */

75     public final String JavaDoc toString() {
76         return image;
77     }
78
79     /**
80      * Returns a new Token object, by default. However, if you want, you
81      * can create and return subclass objects based on the value of ofKind.
82      * Simply add the cases to the switch for all those special cases.
83      * For example, if you have a subclass of Token called IDToken that
84      * you want to create if ofKind is ID, simlpy add something like :
85      *
86      * case MyParserConstants.ID : return new IDToken();
87      *
88      * to the following switch statement. Then you can cast matchedToken
89      * variable to the appropriate type and use it in your lexical actions.
90      */

91     public static final Token newToken(int ofKind) {
92         switch (ofKind) {
93         default:
94             return new Token();
95         }
96     }
97 }
98
Popular Tags