Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Side by Side Diff: src/token.h

Issue 6529032: Merge 6168:6800 from bleeding_edge to experimental/gc branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/stub-cache.cc ('k') | src/top.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 K(SWITCH, "switch", 0) \ 148 K(SWITCH, "switch", 0) \
149 K(THIS, "this", 0) \ 149 K(THIS, "this", 0) \
150 K(THROW, "throw", 0) \ 150 K(THROW, "throw", 0) \
151 K(TRY, "try", 0) \ 151 K(TRY, "try", 0) \
152 /* TYPEOF */ \ 152 /* TYPEOF */ \
153 K(VAR, "var", 0) \ 153 K(VAR, "var", 0) \
154 /* VOID */ \ 154 /* VOID */ \
155 K(WHILE, "while", 0) \ 155 K(WHILE, "while", 0) \
156 K(WITH, "with", 0) \ 156 K(WITH, "with", 0) \
157 \ 157 \
158 /* Future reserved words (ECMA-262, section 7.5.3, page 14). */ \
159 F(ABSTRACT, "abstract", 0) \
160 F(BOOLEAN, "boolean", 0) \
161 F(BYTE, "byte", 0) \
162 F(CHAR, "char", 0) \
163 F(CLASS, "class", 0) \
164 K(CONST, "const", 0) \
165 F(DOUBLE, "double", 0) \
166 F(ENUM, "enum", 0) \
167 F(EXPORT, "export", 0) \
168 F(EXTENDS, "extends", 0) \
169 F(FINAL, "final", 0) \
170 F(FLOAT, "float", 0) \
171 F(GOTO, "goto", 0) \
172 F(IMPLEMENTS, "implements", 0) \
173 F(IMPORT, "import", 0) \
174 F(INT, "int", 0) \
175 F(INTERFACE, "interface", 0) \
176 F(LONG, "long", 0) \
177 K(NATIVE, "native", 0) \
178 F(PACKAGE, "package", 0) \
179 F(PRIVATE, "private", 0) \
180 F(PROTECTED, "protected", 0) \
181 F(PUBLIC, "public", 0) \
182 F(SHORT, "short", 0) \
183 F(STATIC, "static", 0) \
184 F(SUPER, "super", 0) \
185 F(SYNCHRONIZED, "synchronized", 0) \
186 F(THROWS, "throws", 0) \
187 F(TRANSIENT, "transient", 0) \
188 F(VOLATILE, "volatile", 0) \
189 \
190 /* Literals (ECMA-262, section 7.8, page 16). */ \ 158 /* Literals (ECMA-262, section 7.8, page 16). */ \
191 K(NULL_LITERAL, "null", 0) \ 159 K(NULL_LITERAL, "null", 0) \
192 K(TRUE_LITERAL, "true", 0) \ 160 K(TRUE_LITERAL, "true", 0) \
193 K(FALSE_LITERAL, "false", 0) \ 161 K(FALSE_LITERAL, "false", 0) \
194 T(NUMBER, NULL, 0) \ 162 T(NUMBER, NULL, 0) \
195 T(STRING, NULL, 0) \ 163 T(STRING, NULL, 0) \
196 \ 164 \
197 /* Identifiers (not keywords or future reserved words). */ \ 165 /* Identifiers (not keywords or future reserved words). */ \
198 T(IDENTIFIER, NULL, 0) \ 166 T(IDENTIFIER, NULL, 0) \
199 \ 167 \
168 /* Future reserved words (ECMA-262, section 7.6.1.2). */ \
169 T(FUTURE_RESERVED_WORD, NULL, 0) \
170 K(CONST, "const", 0) \
171 K(NATIVE, "native", 0) \
172 \
200 /* Illegal token - not able to scan. */ \ 173 /* Illegal token - not able to scan. */ \
201 T(ILLEGAL, "ILLEGAL", 0) \ 174 T(ILLEGAL, "ILLEGAL", 0) \
202 \ 175 \
203 /* Scanner-internal use only. */ \ 176 /* Scanner-internal use only. */ \
204 T(WHITESPACE, NULL, 0) 177 T(WHITESPACE, NULL, 0)
205 178
206 179
207 class Token { 180 class Token {
208 public: 181 public:
209 // All token values. 182 // All token values.
210 #define T(name, string, precedence) name, 183 #define T(name, string, precedence) name,
211 enum Value { 184 enum Value {
212 TOKEN_LIST(T, T, IGNORE_TOKEN) 185 TOKEN_LIST(T, T, IGNORE_TOKEN)
213 NUM_TOKENS 186 NUM_TOKENS
214 }; 187 };
215 #undef T 188 #undef T
216 189
217 // Returns a string corresponding to the C++ token name 190 // Returns a string corresponding to the C++ token name
218 // (e.g. "LT" for the token LT). 191 // (e.g. "LT" for the token LT).
219 static const char* Name(Value tok) { 192 static const char* Name(Value tok) {
220 ASSERT(0 <= tok && tok < NUM_TOKENS); 193 ASSERT(tok < NUM_TOKENS); // tok is unsigned
221 return name_[tok]; 194 return name_[tok];
222 } 195 }
223 196
224 // Predicates 197 // Predicates
225 static bool IsKeyword(Value tok) { 198 static bool IsKeyword(Value tok) {
226 return token_type[tok] == 'K'; 199 return token_type[tok] == 'K';
227 } 200 }
228 201
229 static bool IsAssignmentOp(Value tok) { 202 static bool IsAssignmentOp(Value tok) {
230 return INIT_VAR <= tok && tok <= ASSIGN_MOD; 203 return INIT_VAR <= tok && tok <= ASSIGN_MOD;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 } 258 }
286 259
287 static bool IsShiftOp(Value op) { 260 static bool IsShiftOp(Value op) {
288 return (SHL <= op) && (op <= SHR); 261 return (SHL <= op) && (op <= SHR);
289 } 262 }
290 263
291 // Returns a string corresponding to the JS token string 264 // Returns a string corresponding to the JS token string
292 // (.e., "<" for the token LT) or NULL if the token doesn't 265 // (.e., "<" for the token LT) or NULL if the token doesn't
293 // have a (unique) string (e.g. an IDENTIFIER). 266 // have a (unique) string (e.g. an IDENTIFIER).
294 static const char* String(Value tok) { 267 static const char* String(Value tok) {
295 ASSERT(0 <= tok && tok < NUM_TOKENS); 268 ASSERT(tok < NUM_TOKENS); // tok is unsigned.
296 return string_[tok]; 269 return string_[tok];
297 } 270 }
298 271
299 // Returns the precedence > 0 for binary and compare 272 // Returns the precedence > 0 for binary and compare
300 // operators; returns 0 otherwise. 273 // operators; returns 0 otherwise.
301 static int Precedence(Value tok) { 274 static int Precedence(Value tok) {
302 ASSERT(0 <= tok && tok < NUM_TOKENS); 275 ASSERT(tok < NUM_TOKENS); // tok is unsigned.
303 return precedence_[tok]; 276 return precedence_[tok];
304 } 277 }
305 278
306 private: 279 private:
307 static const char* name_[NUM_TOKENS]; 280 static const char* name_[NUM_TOKENS];
308 static const char* string_[NUM_TOKENS]; 281 static const char* string_[NUM_TOKENS];
309 static int8_t precedence_[NUM_TOKENS]; 282 static int8_t precedence_[NUM_TOKENS];
310 static const char token_type[NUM_TOKENS]; 283 static const char token_type[NUM_TOKENS];
311 }; 284 };
312 285
313 } } // namespace v8::internal 286 } } // namespace v8::internal
314 287
315 #endif // V8_TOKEN_H_ 288 #endif // V8_TOKEN_H_
OLDNEW
« no previous file with comments | « src/stub-cache.cc ('k') | src/top.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698