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