OLD | NEW |
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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 return string_[tok]; | 253 return string_[tok]; |
254 } | 254 } |
255 | 255 |
256 // Returns the precedence > 0 for binary and compare | 256 // Returns the precedence > 0 for binary and compare |
257 // operators; returns 0 otherwise. | 257 // operators; returns 0 otherwise. |
258 static int Precedence(Value tok) { | 258 static int Precedence(Value tok) { |
259 ASSERT(0 <= tok && tok < NUM_TOKENS); | 259 ASSERT(0 <= tok && tok < NUM_TOKENS); |
260 return precedence_[tok]; | 260 return precedence_[tok]; |
261 } | 261 } |
262 | 262 |
263 // Returns the keyword value if str is a keyword; | |
264 // returns IDENTIFIER otherwise. The class must | |
265 // have been initialized. | |
266 static Value Lookup(const char* str); | |
267 | |
268 // Must be called once to initialize the class. | |
269 // Multiple calls are ignored. | |
270 static void Initialize(); | |
271 | |
272 private: | 263 private: |
273 #ifdef DEBUG | 264 #ifdef DEBUG |
274 static const char* name_[NUM_TOKENS]; | 265 static const char* name_[NUM_TOKENS]; |
275 #endif | 266 #endif |
276 static const char* string_[NUM_TOKENS]; | 267 static const char* string_[NUM_TOKENS]; |
277 static int8_t precedence_[NUM_TOKENS]; | 268 static int8_t precedence_[NUM_TOKENS]; |
278 }; | 269 }; |
279 | 270 |
280 } } // namespace v8::internal | 271 } } // namespace v8::internal |
281 | 272 |
282 #endif // V8_TOKEN_H_ | 273 #endif // V8_TOKEN_H_ |
OLD | NEW |