Source code: com/tripi/asp/parse/Token.java
1 /* Generated By:JavaCC: Do not edit this line. Token.java Version 2.1 */
2 package com.tripi.asp.parse;
3
4 import com.tripi.asp.DebugContext;
5
6 /**
7 * Describes the input token stream.
8 */
9
10 public class Token {
11
12 /**
13 * An integer that describes the kind of this token. This numbering
14 * system is determined by JavaCCParser, and a table of these numbers is
15 * stored in the file ...Constants.java.
16 */
17 public int kind;
18
19 /**
20 * beginLine and beginColumn describe the position of the first character
21 * of this token; endLine and endColumn describe the position of the
22 * last character of this token.
23 */
24 public int beginLine, beginColumn, endLine, endColumn;
25
26 /**
27 * Filename
28 */
29 public String filename;
30
31 /**
32 * The string image of the token.
33 */
34 public String image;
35
36 /**
37 * A reference to the next regular (non-special) token from the input
38 * stream. If this is the last token from the input stream, or if the
39 * token manager has not read tokens beyond this one, this field is
40 * set to null. This is true only if this token is also a regular
41 * token. Otherwise, see below for a description of the contents of
42 * this field.
43 */
44 public Token next;
45
46 /**
47 * This field is used to access special tokens that occur prior to this
48 * token, but after the immediately preceding regular (non-special) token.
49 * If there are no such special tokens, this field is set to null.
50 * When there are more than one such special token, this field refers
51 * to the last of these special tokens, which in turn refers to the next
52 * previous special token through its specialToken field, and so on
53 * until the first special token (whose specialToken field is null).
54 * The next fields of special tokens refer to other special tokens that
55 * immediately follow it (without an intervening regular token). If there
56 * is no such token, this field is null.
57 */
58 public Token specialToken;
59
60 /**
61 * Returns the image.
62 */
63 public final String toString()
64 {
65 return image;
66 }
67
68 /**
69 * Returns a new Token object, by default. However, if you want, you
70 * can create and return subclass objects based on the value of ofKind.
71 * Simply add the cases to the switch for all those special cases.
72 * For example, if you have a subclass of Token called IDToken that
73 * you want to create if ofKind is ID, simlpy add something like :
74 *
75 * case MyParserConstants.ID : return new IDToken();
76 *
77 * to the following switch statement. Then you can cast matchedToken
78 * variable to the appropriate type and use it in your lexical actions.
79 */
80 public static final Token newToken(int ofKind)
81 {
82 switch(ofKind)
83 {
84 default : return new Token();
85 }
86 }
87
88 /**
89 * Fills a debugging context bassed on this token's location.
90 * @param dbgContext Debugging context to fill.
91 */
92 public void fillDebugContext(DebugContext dbgContext)
93 {
94 if (dbgContext == null) return;
95 dbgContext.setFilename(filename);
96 dbgContext.setLineNo(beginLine);
97 }
98 }