Debian Codegraph @

src/com/google/javascript/rhino/Token.java

raw symbols SCIP
1 /*
2 *
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * The Original Code is Rhino code, released
17 * May 6, 1999.
18 *
19 * The Initial Developer of the Original Code is
20 * Netscape Communications Corporation.
21 * Portions created by the Initial Developer are Copyright (C) 1997-1999
22 * the Initial Developer. All Rights Reserved.
23 *
24 * Contributor(s):
25 * Roger Lawrence
26 * Mike McCabe
27 * Igor Bukanov
28 * Milen Nankov
29 *
30 * Alternatively, the contents of this file may be used under the terms of
31 * the GNU General Public License Version 2 or later (the "GPL"), in which
32 * case the provisions of the GPL are applicable instead of those above. If
33 * you wish to allow use of your version of this file only under the terms of
34 * the GPL and not to allow others to use your version of this file under the
35 * MPL, indicate your decision by deleting the provisions above and replacing
36 * them with the notice and other provisions required by the GPL. If you do
37 * not delete the provisions above, a recipient may use your version of this
38 * file under either the MPL or the GPL.
39 *
40 * ***** END LICENSE BLOCK ***** */
41
42 package com.google.javascript.rhino;
43
44 /**
45 * This class implements the JavaScript scanner.
46 *
47 * It is based on the C source files jsscan.c and jsscan.h
48 * in the jsref package.
49 *
50 */
51
52 public class Token {
53
54 /**
55 * Token types. These values correspond to JSTokenType values in
56 * jsscan.c.
57 */
58 public final static int
59 ERROR = -1,
60
61 RETURN = 4,
62 BITOR = 9,
63 BITXOR = 10,
64 BITAND = 11,
65 EQ = 12,
66 NE = 13,
67 LT = 14,
68 LE = 15,
69 GT = 16,
70 GE = 17,
71 LSH = 18,
72 RSH = 19,
73 URSH = 20,
74 ADD = 21,
75 SUB = 22,
76 MUL = 23,
77 DIV = 24,
78 MOD = 25,
79 NOT = 26,
80 BITNOT = 27,
81 POS = 28,
82 NEG = 29,
83 NEW = 30,
84 DELPROP = 31,
85 TYPEOF = 32,
86 GETPROP = 33,
87 GETELEM = 35,
88 CALL = 37,
89 NAME = 38,
90 NUMBER = 39,
91 STRING = 40,
92 NULL = 41,
93 THIS = 42,
94 FALSE = 43,
95 TRUE = 44,
96 SHEQ = 45, // shallow equality (===)
97 SHNE = 46, // shallow inequality (!==)
98 REGEXP = 47,
99 THROW = 49,
100 IN = 51,
101 INSTANCEOF = 52,
102 ARRAYLIT = 63, // array literal
103 OBJECTLIT = 64, // object literal
104
105 TRY = 77,
106 PARAM_LIST = 83,
107 COMMA = 85, // comma operator
108
109 ASSIGN = 86, // simple assignment (=)
110 ASSIGN_BITOR = 87, // |=
111 ASSIGN_BITXOR = 88, // ^=
112 ASSIGN_BITAND = 89, // &=
113 ASSIGN_LSH = 90, // <<=
114 ASSIGN_RSH = 91, // >>=
115 ASSIGN_URSH = 92, // >>>=
116 ASSIGN_ADD = 93, // +=
117 ASSIGN_SUB = 94, // -=
118 ASSIGN_MUL = 95, // *=
119 ASSIGN_DIV = 96, // /=
120 ASSIGN_MOD = 97, // %=
121
122 HOOK = 98, // conditional (?:)
123 OR = 100, // logical or (||)
124 AND = 101, // logical and (&&)
125 INC = 102, // increment (++)
126 DEC = 103, // decrement (--)
127 FUNCTION = 105, // function keyword
128 IF = 108, // if keyword
129 SWITCH = 110, // switch keyword
130 CASE = 111, // case keyword
131 DEFAULT_CASE = 112, // default keyword
132 WHILE = 113, // while keyword
133 DO = 114, // do keyword
134 FOR = 115, // for keyword
135 BREAK = 116, // break keyword
136 CONTINUE = 117, // continue keyword
137 VAR = 118, // var keyword
138 WITH = 119, // with keyword
139 CATCH = 120, // catch keyword
140 VOID = 122, // void keyword
141
142 EMPTY = 124,
143
144 BLOCK = 125, // statement block
145 LABEL = 126, // label
146 EXPR_RESULT = 130, // expression statement in scripts
147 SCRIPT = 132, // top-level node for entire script
148
149 GETTER_DEF = 147,
150 SETTER_DEF = 148,
151
152 CONST = 149, // JS 1.5 const keyword
153 DEBUGGER = 152,
154
155 // JSCompiler introduced tokens
156 LABEL_NAME = 153,
157 STRING_KEY = 154, // object literal key
158 CAST = 155,
159
160 // JSDoc-only tokens
161 ANNOTATION = 300,
162 PIPE = 301,
163 STAR = 302,
164 EOC = 303,
165 QMARK = 304,
166 ELLIPSIS = 305,
167 BANG = 306,
168 EQUALS = 307,
169 LB = 308, // left brackets
170 LC = 309, // left curly braces
171 COLON = 310;
172
173 // Transitional definitions
174 // TODO(johnlenz): remove these
175 public final static int
176 DEFAULT = DEFAULT_CASE,
177 GET = GETTER_DEF,
178 LP = PARAM_LIST,
179 SET = SETTER_DEF;
180
181 public static String name(int token) {
182 switch (token) {
183 case ERROR: return "ERROR";
184 case RETURN: return "RETURN";
185 case BITOR: return "BITOR";
186 case BITXOR: return "BITXOR";
187 case BITAND: return "BITAND";
188 case EQ: return "EQ";
189 case NE: return "NE";
190 case LT: return "LT";
191 case LE: return "LE";
192 case GT: return "GT";
193 case GE: return "GE";
194 case LSH: return "LSH";
195 case RSH: return "RSH";
196 case URSH: return "URSH";
197 case ADD: return "ADD";
198 case SUB: return "SUB";
199 case MUL: return "MUL";
200 case DIV: return "DIV";
201 case MOD: return "MOD";
202 case NOT: return "NOT";
203 case BITNOT: return "BITNOT";
204 case POS: return "POS";
205 case NEG: return "NEG";
206 case NEW: return "NEW";
207 case DELPROP: return "DELPROP";
208 case TYPEOF: return "TYPEOF";
209 case GETPROP: return "GETPROP";
210 case GETELEM: return "GETELEM";
211 case CALL: return "CALL";
212 case NAME: return "NAME";
213 case LABEL_NAME: return "LABEL_NAME";
214 case NUMBER: return "NUMBER";
215 case STRING: return "STRING";
216 case STRING_KEY: return "STRING_KEY";
217 case NULL: return "NULL";
218 case THIS: return "THIS";
219 case FALSE: return "FALSE";
220 case TRUE: return "TRUE";
221 case SHEQ: return "SHEQ";
222 case SHNE: return "SHNE";
223 case REGEXP: return "REGEXP";
224 case THROW: return "THROW";
225 case IN: return "IN";
226 case INSTANCEOF: return "INSTANCEOF";
227 case ARRAYLIT: return "ARRAYLIT";
228 case OBJECTLIT: return "OBJECTLIT";
229 case TRY: return "TRY";
230 case PARAM_LIST: return "PARAM_LIST";
231 case COMMA: return "COMMA";
232 case ASSIGN: return "ASSIGN";
233 case ASSIGN_BITOR: return "ASSIGN_BITOR";
234 case ASSIGN_BITXOR: return "ASSIGN_BITXOR";
235 case ASSIGN_BITAND: return "ASSIGN_BITAND";
236 case ASSIGN_LSH: return "ASSIGN_LSH";
237 case ASSIGN_RSH: return "ASSIGN_RSH";
238 case ASSIGN_URSH: return "ASSIGN_URSH";
239 case ASSIGN_ADD: return "ASSIGN_ADD";
240 case ASSIGN_SUB: return "ASSIGN_SUB";
241 case ASSIGN_MUL: return "ASSIGN_MUL";
242 case ASSIGN_DIV: return "ASSIGN_DIV";
243 case ASSIGN_MOD: return "ASSIGN_MOD";
244 case HOOK: return "HOOK";
245 case OR: return "OR";
246 case AND: return "AND";
247 case INC: return "INC";
248 case DEC: return "DEC";
249 case FUNCTION: return "FUNCTION";
250 case IF: return "IF";
251 case SWITCH: return "SWITCH";
252 case CASE: return "CASE";
253 case DEFAULT_CASE: return "DEFAULT_CASE";
254 case WHILE: return "WHILE";
255 case DO: return "DO";
256 case FOR: return "FOR";
257 case BREAK: return "BREAK";
258 case CONTINUE: return "CONTINUE";
259 case VAR: return "VAR";
260 case WITH: return "WITH";
261 case CATCH: return "CATCH";
262 case EMPTY: return "EMPTY";
263 case BLOCK: return "BLOCK";
264 case LABEL: return "LABEL";
265 case EXPR_RESULT: return "EXPR_RESULT";
266 case SCRIPT: return "SCRIPT";
267 case GETTER_DEF: return "GETTER_DEF";
268 case SETTER_DEF: return "SETTER_DEF";
269 case CONST: return "CONST";
270 case DEBUGGER: return "DEBUGGER";
271 case CAST: return "CAST";
272 case ANNOTATION: return "ANNOTATION";
273 case PIPE: return "PIPE";
274 case STAR: return "STAR";
275 case EOC: return "EOC";
276 case QMARK: return "QMARK";
277 case ELLIPSIS: return "ELLIPSIS";
278 case BANG: return "BANG";
279 case VOID: return "VOID";
280 case EQUALS: return "EQUALS";
281 case LB: return "LB";
282 case LC: return "LC";
283 case COLON: return "COLON";
284 }
285
286 // Token without name
287 throw new IllegalStateException(String.valueOf(token));
288 }
289 }