Thu, 02 Oct 2008 19:58:40 -0700
6754988: Update copyright year
Summary: Update for files that have been modified starting July 2008
Reviewed-by: ohair, tbell
duke@1 | 1 | /* |
xdono@117 | 2 | * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@1 | 7 | * published by the Free Software Foundation. Sun designates this |
duke@1 | 8 | * particular file as subject to the "Classpath" exception as provided |
duke@1 | 9 | * by Sun in the LICENSE file that accompanied this code. |
duke@1 | 10 | * |
duke@1 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 15 | * accompanied this code). |
duke@1 | 16 | * |
duke@1 | 17 | * You should have received a copy of the GNU General Public License version |
duke@1 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 20 | * |
duke@1 | 21 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@1 | 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@1 | 23 | * have any questions. |
duke@1 | 24 | */ |
duke@1 | 25 | |
duke@1 | 26 | package com.sun.tools.javac.parser; |
duke@1 | 27 | |
mcimadamore@80 | 28 | import java.util.ResourceBundle; |
mcimadamore@80 | 29 | |
mcimadamore@80 | 30 | import com.sun.tools.javac.api.Formattable; |
duke@1 | 31 | |
duke@1 | 32 | /** An interface that defines codes for Java source tokens |
duke@1 | 33 | * returned from lexical analysis. |
duke@1 | 34 | * |
duke@1 | 35 | * <p><b>This is NOT part of any API supported by Sun Microsystems. If |
duke@1 | 36 | * you write code that depends on this, you do so at your own risk. |
duke@1 | 37 | * This code and its internal interfaces are subject to change or |
duke@1 | 38 | * deletion without notice.</b> |
duke@1 | 39 | */ |
mcimadamore@80 | 40 | public enum Token implements Formattable { |
duke@1 | 41 | EOF, |
duke@1 | 42 | ERROR, |
duke@1 | 43 | IDENTIFIER, |
duke@1 | 44 | ABSTRACT("abstract"), |
duke@1 | 45 | ASSERT("assert"), |
duke@1 | 46 | BOOLEAN("boolean"), |
duke@1 | 47 | BREAK("break"), |
duke@1 | 48 | BYTE("byte"), |
duke@1 | 49 | CASE("case"), |
duke@1 | 50 | CATCH("catch"), |
duke@1 | 51 | CHAR("char"), |
duke@1 | 52 | CLASS("class"), |
duke@1 | 53 | CONST("const"), |
duke@1 | 54 | CONTINUE("continue"), |
duke@1 | 55 | DEFAULT("default"), |
duke@1 | 56 | DO("do"), |
duke@1 | 57 | DOUBLE("double"), |
duke@1 | 58 | ELSE("else"), |
duke@1 | 59 | ENUM("enum"), |
duke@1 | 60 | EXTENDS("extends"), |
duke@1 | 61 | FINAL("final"), |
duke@1 | 62 | FINALLY("finally"), |
duke@1 | 63 | FLOAT("float"), |
duke@1 | 64 | FOR("for"), |
duke@1 | 65 | GOTO("goto"), |
duke@1 | 66 | IF("if"), |
duke@1 | 67 | IMPLEMENTS("implements"), |
duke@1 | 68 | IMPORT("import"), |
duke@1 | 69 | INSTANCEOF("instanceof"), |
duke@1 | 70 | INT("int"), |
duke@1 | 71 | INTERFACE("interface"), |
duke@1 | 72 | LONG("long"), |
duke@1 | 73 | NATIVE("native"), |
duke@1 | 74 | NEW("new"), |
duke@1 | 75 | PACKAGE("package"), |
duke@1 | 76 | PRIVATE("private"), |
duke@1 | 77 | PROTECTED("protected"), |
duke@1 | 78 | PUBLIC("public"), |
duke@1 | 79 | RETURN("return"), |
duke@1 | 80 | SHORT("short"), |
duke@1 | 81 | STATIC("static"), |
duke@1 | 82 | STRICTFP("strictfp"), |
duke@1 | 83 | SUPER("super"), |
duke@1 | 84 | SWITCH("switch"), |
duke@1 | 85 | SYNCHRONIZED("synchronized"), |
duke@1 | 86 | THIS("this"), |
duke@1 | 87 | THROW("throw"), |
duke@1 | 88 | THROWS("throws"), |
duke@1 | 89 | TRANSIENT("transient"), |
duke@1 | 90 | TRY("try"), |
duke@1 | 91 | VOID("void"), |
duke@1 | 92 | VOLATILE("volatile"), |
duke@1 | 93 | WHILE("while"), |
duke@1 | 94 | INTLITERAL, |
duke@1 | 95 | LONGLITERAL, |
duke@1 | 96 | FLOATLITERAL, |
duke@1 | 97 | DOUBLELITERAL, |
duke@1 | 98 | CHARLITERAL, |
duke@1 | 99 | STRINGLITERAL, |
duke@1 | 100 | TRUE("true"), |
duke@1 | 101 | FALSE("false"), |
duke@1 | 102 | NULL("null"), |
duke@1 | 103 | LPAREN("("), |
duke@1 | 104 | RPAREN(")"), |
duke@1 | 105 | LBRACE("{"), |
duke@1 | 106 | RBRACE("}"), |
duke@1 | 107 | LBRACKET("["), |
duke@1 | 108 | RBRACKET("]"), |
duke@1 | 109 | SEMI(";"), |
duke@1 | 110 | COMMA(","), |
duke@1 | 111 | DOT("."), |
duke@1 | 112 | ELLIPSIS("..."), |
duke@1 | 113 | EQ("="), |
duke@1 | 114 | GT(">"), |
duke@1 | 115 | LT("<"), |
duke@1 | 116 | BANG("!"), |
duke@1 | 117 | TILDE("~"), |
duke@1 | 118 | QUES("?"), |
duke@1 | 119 | COLON(":"), |
duke@1 | 120 | EQEQ("=="), |
duke@1 | 121 | LTEQ("<="), |
duke@1 | 122 | GTEQ(">="), |
duke@1 | 123 | BANGEQ("!="), |
duke@1 | 124 | AMPAMP("&&"), |
duke@1 | 125 | BARBAR("||"), |
duke@1 | 126 | PLUSPLUS("++"), |
duke@1 | 127 | SUBSUB("--"), |
duke@1 | 128 | PLUS("+"), |
duke@1 | 129 | SUB("-"), |
duke@1 | 130 | STAR("*"), |
duke@1 | 131 | SLASH("/"), |
duke@1 | 132 | AMP("&"), |
duke@1 | 133 | BAR("|"), |
duke@1 | 134 | CARET("^"), |
duke@1 | 135 | PERCENT("%"), |
duke@1 | 136 | LTLT("<<"), |
duke@1 | 137 | GTGT(">>"), |
duke@1 | 138 | GTGTGT(">>>"), |
duke@1 | 139 | PLUSEQ("+="), |
duke@1 | 140 | SUBEQ("-="), |
duke@1 | 141 | STAREQ("*="), |
duke@1 | 142 | SLASHEQ("/="), |
duke@1 | 143 | AMPEQ("&="), |
duke@1 | 144 | BAREQ("|="), |
duke@1 | 145 | CARETEQ("^="), |
duke@1 | 146 | PERCENTEQ("%="), |
duke@1 | 147 | LTLTEQ("<<="), |
duke@1 | 148 | GTGTEQ(">>="), |
duke@1 | 149 | GTGTGTEQ(">>>="), |
duke@1 | 150 | MONKEYS_AT("@"), |
duke@1 | 151 | CUSTOM; |
duke@1 | 152 | |
duke@1 | 153 | Token() { |
duke@1 | 154 | this(null); |
duke@1 | 155 | } |
duke@1 | 156 | Token(String name) { |
duke@1 | 157 | this.name = name; |
duke@1 | 158 | } |
duke@1 | 159 | |
duke@1 | 160 | public final String name; |
mcimadamore@80 | 161 | |
mcimadamore@80 | 162 | public String toString() { |
mcimadamore@80 | 163 | switch (this) { |
mcimadamore@80 | 164 | case IDENTIFIER: |
mcimadamore@80 | 165 | return "token.identifier"; |
mcimadamore@80 | 166 | case CHARLITERAL: |
mcimadamore@80 | 167 | return "token.character"; |
mcimadamore@80 | 168 | case STRINGLITERAL: |
mcimadamore@80 | 169 | return "token.string"; |
mcimadamore@80 | 170 | case INTLITERAL: |
mcimadamore@80 | 171 | return "token.integer"; |
mcimadamore@80 | 172 | case LONGLITERAL: |
mcimadamore@80 | 173 | return "token.long-integer"; |
mcimadamore@80 | 174 | case FLOATLITERAL: |
mcimadamore@80 | 175 | return "token.float"; |
mcimadamore@80 | 176 | case DOUBLELITERAL: |
mcimadamore@80 | 177 | return "token.double"; |
mcimadamore@80 | 178 | case ERROR: |
mcimadamore@80 | 179 | return "token.bad-symbol"; |
mcimadamore@80 | 180 | case EOF: |
mcimadamore@80 | 181 | return "token.end-of-input"; |
mcimadamore@80 | 182 | case DOT: case COMMA: case SEMI: case LPAREN: case RPAREN: |
mcimadamore@80 | 183 | case LBRACKET: case RBRACKET: case LBRACE: case RBRACE: |
mcimadamore@80 | 184 | return "'" + name + "'"; |
mcimadamore@80 | 185 | default: |
mcimadamore@80 | 186 | return name; |
mcimadamore@80 | 187 | } |
mcimadamore@80 | 188 | } |
mcimadamore@80 | 189 | |
mcimadamore@80 | 190 | public String getKind() { |
mcimadamore@80 | 191 | return "Token"; |
mcimadamore@80 | 192 | } |
mcimadamore@80 | 193 | |
mcimadamore@80 | 194 | public String toString(ResourceBundle bundle) { |
mcimadamore@80 | 195 | String s = toString(); |
mcimadamore@80 | 196 | return s.startsWith("token.") ? bundle.getString("compiler.misc." + s) : s; |
mcimadamore@80 | 197 | } |
duke@1 | 198 | } |