author | ohair |
Tue, 25 May 2010 15:54:51 -0700 | |
changeset 5520 | 86e4b9a9da40 |
parent 1471 | 57506cdfb7b4 |
child 5847 | 1908176fd6e3 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
5520 | 2 |
* Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. |
10 | 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 |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 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 |
* |
|
5520 | 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. |
|
10 | 24 |
*/ |
25 |
||
26 |
package com.sun.tools.javac.parser; |
|
27 |
||
1471
57506cdfb7b4
6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents:
1264
diff
changeset
|
28 |
import java.util.Locale; |
939
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
29 |
|
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
30 |
import com.sun.tools.javac.api.Formattable; |
1471
57506cdfb7b4
6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents:
1264
diff
changeset
|
31 |
import com.sun.tools.javac.api.Messages; |
10 | 32 |
|
33 |
/** An interface that defines codes for Java source tokens |
|
34 |
* returned from lexical analysis. |
|
35 |
* |
|
36 |
* <p><b>This is NOT part of any API supported by Sun Microsystems. If |
|
37 |
* you write code that depends on this, you do so at your own risk. |
|
38 |
* This code and its internal interfaces are subject to change or |
|
39 |
* deletion without notice.</b> |
|
40 |
*/ |
|
939
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
41 |
public enum Token implements Formattable { |
10 | 42 |
EOF, |
43 |
ERROR, |
|
44 |
IDENTIFIER, |
|
45 |
ABSTRACT("abstract"), |
|
46 |
ASSERT("assert"), |
|
47 |
BOOLEAN("boolean"), |
|
48 |
BREAK("break"), |
|
49 |
BYTE("byte"), |
|
50 |
CASE("case"), |
|
51 |
CATCH("catch"), |
|
52 |
CHAR("char"), |
|
53 |
CLASS("class"), |
|
54 |
CONST("const"), |
|
55 |
CONTINUE("continue"), |
|
56 |
DEFAULT("default"), |
|
57 |
DO("do"), |
|
58 |
DOUBLE("double"), |
|
59 |
ELSE("else"), |
|
60 |
ENUM("enum"), |
|
61 |
EXTENDS("extends"), |
|
62 |
FINAL("final"), |
|
63 |
FINALLY("finally"), |
|
64 |
FLOAT("float"), |
|
65 |
FOR("for"), |
|
66 |
GOTO("goto"), |
|
67 |
IF("if"), |
|
68 |
IMPLEMENTS("implements"), |
|
69 |
IMPORT("import"), |
|
70 |
INSTANCEOF("instanceof"), |
|
71 |
INT("int"), |
|
72 |
INTERFACE("interface"), |
|
73 |
LONG("long"), |
|
74 |
NATIVE("native"), |
|
75 |
NEW("new"), |
|
76 |
PACKAGE("package"), |
|
77 |
PRIVATE("private"), |
|
78 |
PROTECTED("protected"), |
|
79 |
PUBLIC("public"), |
|
80 |
RETURN("return"), |
|
81 |
SHORT("short"), |
|
82 |
STATIC("static"), |
|
83 |
STRICTFP("strictfp"), |
|
84 |
SUPER("super"), |
|
85 |
SWITCH("switch"), |
|
86 |
SYNCHRONIZED("synchronized"), |
|
87 |
THIS("this"), |
|
88 |
THROW("throw"), |
|
89 |
THROWS("throws"), |
|
90 |
TRANSIENT("transient"), |
|
91 |
TRY("try"), |
|
92 |
VOID("void"), |
|
93 |
VOLATILE("volatile"), |
|
94 |
WHILE("while"), |
|
95 |
INTLITERAL, |
|
96 |
LONGLITERAL, |
|
97 |
FLOATLITERAL, |
|
98 |
DOUBLELITERAL, |
|
99 |
CHARLITERAL, |
|
100 |
STRINGLITERAL, |
|
101 |
TRUE("true"), |
|
102 |
FALSE("false"), |
|
103 |
NULL("null"), |
|
104 |
LPAREN("("), |
|
105 |
RPAREN(")"), |
|
106 |
LBRACE("{"), |
|
107 |
RBRACE("}"), |
|
108 |
LBRACKET("["), |
|
109 |
RBRACKET("]"), |
|
110 |
SEMI(";"), |
|
111 |
COMMA(","), |
|
112 |
DOT("."), |
|
113 |
ELLIPSIS("..."), |
|
114 |
EQ("="), |
|
115 |
GT(">"), |
|
116 |
LT("<"), |
|
117 |
BANG("!"), |
|
118 |
TILDE("~"), |
|
119 |
QUES("?"), |
|
120 |
COLON(":"), |
|
121 |
EQEQ("=="), |
|
122 |
LTEQ("<="), |
|
123 |
GTEQ(">="), |
|
124 |
BANGEQ("!="), |
|
125 |
AMPAMP("&&"), |
|
126 |
BARBAR("||"), |
|
127 |
PLUSPLUS("++"), |
|
128 |
SUBSUB("--"), |
|
129 |
PLUS("+"), |
|
130 |
SUB("-"), |
|
131 |
STAR("*"), |
|
132 |
SLASH("/"), |
|
133 |
AMP("&"), |
|
134 |
BAR("|"), |
|
135 |
CARET("^"), |
|
136 |
PERCENT("%"), |
|
137 |
LTLT("<<"), |
|
138 |
GTGT(">>"), |
|
139 |
GTGTGT(">>>"), |
|
140 |
PLUSEQ("+="), |
|
141 |
SUBEQ("-="), |
|
142 |
STAREQ("*="), |
|
143 |
SLASHEQ("/="), |
|
144 |
AMPEQ("&="), |
|
145 |
BAREQ("|="), |
|
146 |
CARETEQ("^="), |
|
147 |
PERCENTEQ("%="), |
|
148 |
LTLTEQ("<<="), |
|
149 |
GTGTEQ(">>="), |
|
150 |
GTGTGTEQ(">>>="), |
|
151 |
MONKEYS_AT("@"), |
|
152 |
CUSTOM; |
|
153 |
||
154 |
Token() { |
|
155 |
this(null); |
|
156 |
} |
|
157 |
Token(String name) { |
|
158 |
this.name = name; |
|
159 |
} |
|
160 |
||
161 |
public final String name; |
|
939
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
162 |
|
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
163 |
public String toString() { |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
164 |
switch (this) { |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
165 |
case IDENTIFIER: |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
166 |
return "token.identifier"; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
167 |
case CHARLITERAL: |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
168 |
return "token.character"; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
169 |
case STRINGLITERAL: |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
170 |
return "token.string"; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
171 |
case INTLITERAL: |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
172 |
return "token.integer"; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
173 |
case LONGLITERAL: |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
174 |
return "token.long-integer"; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
175 |
case FLOATLITERAL: |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
176 |
return "token.float"; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
177 |
case DOUBLELITERAL: |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
178 |
return "token.double"; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
179 |
case ERROR: |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
180 |
return "token.bad-symbol"; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
181 |
case EOF: |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
182 |
return "token.end-of-input"; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
183 |
case DOT: case COMMA: case SEMI: case LPAREN: case RPAREN: |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
184 |
case LBRACKET: case RBRACKET: case LBRACE: case RBRACE: |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
185 |
return "'" + name + "'"; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
186 |
default: |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
187 |
return name; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
188 |
} |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
189 |
} |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
190 |
|
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
191 |
public String getKind() { |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
192 |
return "Token"; |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
193 |
} |
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
194 |
|
1471
57506cdfb7b4
6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents:
1264
diff
changeset
|
195 |
public String toString(Locale locale, Messages messages) { |
57506cdfb7b4
6406133: JCDiagnostic.getMessage ignores locale argument
mcimadamore
parents:
1264
diff
changeset
|
196 |
return name != null ? toString() : messages.getLocalizedString(locale, "compiler.misc." + toString()); |
939
38e24969c7e9
6717241: some diagnostic argument is prematurely converted into a String object
mcimadamore
parents:
10
diff
changeset
|
197 |
} |
10 | 198 |
} |