01: /* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
02: /**************************************************************************************
03: * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
04: * http://aspectwerkz.codehaus.org *
05: * ---------------------------------------------------------------------------------- *
06: * The software in this package is published under the terms of the LGPL license *
07: * a copy of which has been included with this distribution in the license.txt file. *
08: **************************************************************************************/package org.codehaus.aspectwerkz.expression.ast;
09:
10: /**
11: * Describes the input token stream.
12: */
13:
14: public class Token {
15:
16: /**
17: * An integer that describes the kind of this token. This numbering system is determined by JavaCCParser, and a
18: * table of these numbers is stored in the file ...Constants.java.
19: */
20: public int kind;
21:
22: /**
23: * beginLine and beginColumn describe the position of the first character of this token; endLine and endColumn
24: * describe the position of the last character of this token.
25: */
26: public int beginLine, beginColumn, endLine, endColumn;
27:
28: /**
29: * The string image of the token.
30: */
31: public String image;
32:
33: /**
34: * A reference to the next regular (non-special) token from the input stream. If this is the last token from the
35: * input stream, or if the token manager has not read tokens beyond this one, this field is set to null. This is
36: * true only if this token is also a regular token. Otherwise, see below for a description of the contents of this
37: * field.
38: */
39: public Token next;
40:
41: /**
42: * This field is used to access special tokens that occur prior to this token, but after the immediately preceding
43: * regular (non-special) token. If there are no such special tokens, this field is set to null. When there are more
44: * than one such special token, this field refers to the last of these special tokens, which in turn refers to the
45: * next previous special token through its specialToken field, and so on until the first special token (whose
46: * specialToken field is null). The next fields of special tokens refer to other special tokens that immediately
47: * follow it (without an intervening regular token). If there is no such token, this field is null.
48: */
49: public Token specialToken;
50:
51: /**
52: * Returns the image.
53: */
54: public String toString() {
55: return image;
56: }
57:
58: /**
59: * Returns a new Token object, by default. However, if you want, you can create and return subclass objects based on
60: * the value of ofKind. Simply add the cases to the switch for all those special cases. For example, if you have a
61: * subclass of Token called IDToken that you want to create if ofKind is ID, simlpy add something like : case
62: * MyParserConstants.ID : return new IDToken(); to the following switch statement. Then you can cast matchedToken
63: * variable to the appropriate type and use it in your lexical actions.
64: */
65: public static final Token newToken(int ofKind) {
66: switch (ofKind) {
67: default:
68: return new Token();
69: }
70: }
71:
72: }
|