001 /*
002 * Sonar, open source software quality management tool.
003 * Copyright (C) 2008-2011 SonarSource
004 * mailto:contact AT sonarsource DOT com
005 *
006 * Sonar is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * Sonar is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public
017 * License along with Sonar; if not, write to the Free Software
018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
019 */
020
021 /* Generated By:JavaCC: Do not edit this line. Token.java Version 4.1 */
022 /* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null */
023 package net.sourceforge.pmd.cpd.cppast;
024
025 /**
026 * Describes the input token stream.
027 */
028
029 public class Token {
030
031 /**
032 * An integer that describes the kind of this token. This numbering
033 * system is determined by JavaCCParser, and a table of these numbers is
034 * stored in the file ...Constants.java.
035 */
036 public int kind;
037
038 /** The line number of the first character of this Token. */
039 public int beginLine;
040 /** The column number of the first character of this Token. */
041 public int beginColumn;
042 /** The line number of the last character of this Token. */
043 public int endLine;
044 /** The column number of the last character of this Token. */
045 public int endColumn;
046
047 /**
048 * The string image of the token.
049 */
050 public String image;
051
052 /**
053 * A reference to the next regular (non-special) token from the input
054 * stream. If this is the last token from the input stream, or if the
055 * token manager has not read tokens beyond this one, this field is
056 * set to null. This is true only if this token is also a regular
057 * token. Otherwise, see below for a description of the contents of
058 * this field.
059 */
060 public Token next;
061
062 /**
063 * This field is used to access special tokens that occur prior to this
064 * token, but after the immediately preceding regular (non-special) token.
065 * If there are no such special tokens, this field is set to null.
066 * When there are more than one such special token, this field refers
067 * to the last of these special tokens, which in turn refers to the next
068 * previous special token through its specialToken field, and so on
069 * until the first special token (whose specialToken field is null).
070 * The next fields of special tokens refer to other special tokens that
071 * immediately follow it (without an intervening regular token). If there
072 * is no such token, this field is null.
073 */
074 public Token specialToken;
075
076 /**
077 * An optional attribute value of the Token.
078 * Tokens which are not used as syntactic sugar will often contain
079 * meaningful values that will be used later on by the compiler or
080 * interpreter. This attribute value is often different from the image.
081 * Any subclass of Token that actually wants to return a non-null value can
082 * override this method as appropriate.
083 */
084 public Object getValue() {
085 return null;
086 }
087
088 /**
089 * No-argument constructor
090 */
091 public Token() {}
092
093 /**
094 * Constructs a new token for the specified Image.
095 */
096 public Token(int kind)
097 {
098 this(kind, null);
099 }
100
101 /**
102 * Constructs a new token for the specified Image and Kind.
103 */
104 public Token(int kind, String image)
105 {
106 this.kind = kind;
107 this.image = image;
108 }
109
110 /**
111 * Returns the image.
112 */
113 public String toString()
114 {
115 return image;
116 }
117
118 /**
119 * Returns a new Token object, by default. However, if you want, you
120 * can create and return subclass objects based on the value of ofKind.
121 * Simply add the cases to the switch for all those special cases.
122 * For example, if you have a subclass of Token called IDToken that
123 * you want to create if ofKind is ID, simply add something like :
124 *
125 * case MyParserConstants.ID : return new IDToken(ofKind, image);
126 *
127 * to the following switch statement. Then you can cast matchedToken
128 * variable to the appropriate type and use sit in your lexical actions.
129 */
130 public static Token newToken(int ofKind, String image)
131 {
132 switch(ofKind)
133 {
134 default : return new Token(ofKind, image);
135 }
136 }
137
138 public static Token newToken(int ofKind)
139 {
140 return newToken(ofKind, null);
141 }
142
143 }
144 /* JavaCC - OriginalChecksum=1917659c640ac2c65feaa32a37580421 (do not edit this line) */