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