KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > micronova > util > cc > html > Token


1 /*
2
3 Copyright 2003-2007 MicroNova (R)
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or
7 without modification, are permitted provided that the following
8 conditions are met:
9
10     * Redistributions of source code must retain the above copyright
11     notice, this list of conditions and the following disclaimer.
12
13     * Redistributions in binary form must reproduce the above copyright
14     notice, this list of conditions and the following disclaimer in the
15     documentation and/or other materials provided with the distribution.
16
17     * Neither the name of MicroNova nor the names of its contributors
18     may be used to endorse or promote products derived from this
19     software without specific prior written permission.
20
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 POSSIBILITY OF SUCH DAMAGE.
32
33 */

34
35
36 /* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
37 package com.micronova.util.cc.html;
38
39 /**
40  * Describes the input token stream.
41  */

42
43 public class Token {
44
45   /**
46    * An integer that describes the kind of this token. This numbering
47    * system is determined by JavaCCParser, and a table of these numbers is
48    * stored in the file ...Constants.java.
49    */

50   public int kind;
51
52   /**
53    * beginLine and beginColumn describe the position of the first character
54    * of this token; endLine and endColumn describe the position of the
55    * last character of this token.
56    */

57   public int beginLine, beginColumn, endLine, endColumn;
58
59   /**
60    * The string image of the token.
61    */

62   public String JavaDoc image;
63
64   /**
65    * A reference to the next regular (non-special) token from the input
66    * stream. If this is the last token from the input stream, or if the
67    * token manager has not read tokens beyond this one, this field is
68    * set to null. This is true only if this token is also a regular
69    * token. Otherwise, see below for a description of the contents of
70    * this field.
71    */

72   public Token next;
73
74   /**
75    * This field is used to access special tokens that occur prior to this
76    * token, but after the immediately preceding regular (non-special) token.
77    * If there are no such special tokens, this field is set to null.
78    * When there are more than one such special token, this field refers
79    * to the last of these special tokens, which in turn refers to the next
80    * previous special token through its specialToken field, and so on
81    * until the first special token (whose specialToken field is null).
82    * The next fields of special tokens refer to other special tokens that
83    * immediately follow it (without an intervening regular token). If there
84    * is no such token, this field is null.
85    */

86   public Token specialToken;
87
88   /**
89    * Returns the image.
90    */

91   public String JavaDoc toString()
92   {
93      return image;
94   }
95
96   /**
97    * Returns a new Token object, by default. However, if you want, you
98    * can create and return subclass objects based on the value of ofKind.
99    * Simply add the cases to the switch for all those special cases.
100    * For example, if you have a subclass of Token called IDToken that
101    * you want to create if ofKind is ID, simlpy add something like :
102    *
103    * case MyParserConstants.ID : return new IDToken();
104    *
105    * to the following switch statement. Then you can cast matchedToken
106    * variable to the appropriate type and use it in your lexical actions.
107    */

108   public static final Token newToken(int ofKind)
109   {
110      switch(ofKind)
111      {
112        default : return new Token();
113      }
114   }
115
116 }
117
Popular Tags