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