KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > tools > example > debug > expr > Token


1 /*
2  * @(#)Token.java 1.8 05/11/17
3  *
4  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 /* Generated By:JavaCC: Do not edit this line. Token.java Version 0.7pre3 */
9 package com.sun.tools.example.debug.expr;
10
11 /**
12  * Describes the input token stream.
13  */

14
15 public class Token {
16
17   /**
18    * An integer that describes the kind of this token. This numbering
19    * system is determined by JavaCCParser, and a table of these numbers is
20    * stored in the file ...Constants.java.
21    */

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

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

34   public String JavaDoc 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 JavaDoc 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
Popular Tags