View Javadoc
1   /*
2    * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
3    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4    *
5    * This code is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU General Public License version 2 only, as
7    * published by the Free Software Foundation.  Oracle designates this
8    * particular file as subject to the "Classpath" exception as provided
9    * by Oracle in the LICENSE file that accompanied this code.
10   *
11   * This code is distributed in the hope that it will be useful, but WITHOUT
12   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14   * version 2 for more details (a copy is included in the LICENSE file that
15   * accompanied this code).
16   *
17   * You should have received a copy of the GNU General Public License version
18   * 2 along with this work; if not, write to the Free Software Foundation,
19   * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20   *
21   * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22   * or visit www.oracle.com if you need additional information or have any
23   * questions.
24   */
25  
26  /*
27   * This source code is provided to illustrate the usage of a given feature
28   * or technique and has been deliberately simplified. Additional steps
29   * required for a production-quality application, such as security checks,
30   * input validation and proper error handling, might not be present in
31   * this sample code.
32   */
33  
34  
35  /* Generated By:JavaCC: Do not edit this line. Token.java Version 0.7pre3 */
36  package com.sun.tools.example.debug.expr;
37  
38  /**
39   * Describes the input token stream.
40   */
41  
42  public class Token {
43  
44    /**
45     * An integer that describes the kind of this token.  This numbering
46     * system is determined by JavaCCParser, and a table of these numbers is
47     * stored in the file ...Constants.java.
48     */
49    public int kind;
50  
51    /**
52     * beginLine and beginColumn describe the position of the first character
53     * of this token; endLine and endColumn describe the position of the
54     * last character of this token.
55     */
56    public int beginLine, beginColumn, endLine, endColumn;
57  
58    /**
59     * The string image of the token.
60     */
61    public String image;
62  
63    /**
64     * A reference to the next regular (non-special) token from the input
65     * stream.  If this is the last token from the input stream, or if the
66     * token manager has not read tokens beyond this one, this field is
67     * set to null.  This is true only if this token is also a regular
68     * token.  Otherwise, see below for a description of the contents of
69     * this field.
70     */
71    public Token next;
72  
73    /**
74     * This field is used to access special tokens that occur prior to this
75     * token, but after the immediately preceding regular (non-special) token.
76     * If there are no such special tokens, this field is set to null.
77     * When there are more than one such special token, this field refers
78     * to the last of these special tokens, which in turn refers to the next
79     * previous special token through its specialToken field, and so on
80     * until the first special token (whose specialToken field is null).
81     * The next fields of special tokens refer to other special tokens that
82     * immediately follow it (without an intervening regular token).  If there
83     * is no such token, this field is null.
84     */
85    public Token specialToken;
86  
87    /**
88     * Returns the image.
89     */
90    @Override
91    public final String 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 }