KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > bsh > Token


1 /* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
2 package bsh;
3 /*
4     This file has been modified for BeanShell to make Token serializable.
5     If this file is regenerated please make this change.
6
7     All BeanShell modifications are demarcated by "Begin BeanShell
8     Modification - ... " and "End BeanShell Modification - ..."
9 */

10
11 /**
12  * Describes the input token stream.
13  */

14
15     // Begin BeanShell Modification - serializable
16
public class Token implements java.io.Serializable JavaDoc {
17     // End BeanShell Modification - serializable
18

19   /**
20    * An integer that describes the kind of this token. This numbering
21    * system is determined by JavaCCParser, and a table of these numbers is
22    * stored in the file ...Constants.java.
23    */

24   public int kind;
25
26   /**
27    * beginLine and beginColumn describe the position of the first character
28    * of this token; endLine and endColumn describe the position of the
29    * last character of this token.
30    */

31   public int beginLine, beginColumn, endLine, endColumn;
32
33   /**
34    * The string image of the token.
35    */

36   public String JavaDoc image;
37
38   /**
39    * A reference to the next regular (non-special) token from the input
40    * stream. If this is the last token from the input stream, or if the
41    * token manager has not read tokens beyond this one, this field is
42    * set to null. This is true only if this token is also a regular
43    * token. Otherwise, see below for a description of the contents of
44    * this field.
45    */

46   public Token next;
47
48   /**
49    * This field is used to access special tokens that occur prior to this
50    * token, but after the immediately preceding regular (non-special) token.
51    * If there are no such special tokens, this field is set to null.
52    * When there are more than one such special token, this field refers
53    * to the last of these special tokens, which in turn refers to the next
54    * previous special token through its specialToken field, and so on
55    * until the first special token (whose specialToken field is null).
56    * The next fields of special tokens refer to other special tokens that
57    * immediately follow it (without an intervening regular token). If there
58    * is no such token, this field is null.
59    */

60   public Token specialToken;
61
62   /**
63    * Returns the image.
64    */

65   public String JavaDoc toString()
66   {
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   {
84      switch(ofKind)
85      {
86        default : return new Token();
87      }
88   }
89
90 }
91
Popular Tags