| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 class Token { | 204 class Token { |
| 205 public: | 205 public: |
| 206 // All token values. | 206 // All token values. |
| 207 #define T(name, string, precedence) name, | 207 #define T(name, string, precedence) name, |
| 208 enum Value { | 208 enum Value { |
| 209 TOKEN_LIST(T, T, IGNORE_TOKEN) | 209 TOKEN_LIST(T, T, IGNORE_TOKEN) |
| 210 NUM_TOKENS | 210 NUM_TOKENS |
| 211 }; | 211 }; |
| 212 #undef T | 212 #undef T |
| 213 | 213 |
| 214 #ifdef DEBUG | |
| 215 // Returns a string corresponding to the C++ token name | 214 // Returns a string corresponding to the C++ token name |
| 216 // (e.g. "LT" for the token LT). | 215 // (e.g. "LT" for the token LT). |
| 217 static const char* Name(Value tok) { | 216 static const char* Name(Value tok) { |
| 218 ASSERT(0 <= tok && tok < NUM_TOKENS); | 217 ASSERT(0 <= tok && tok < NUM_TOKENS); |
| 219 return name_[tok]; | 218 return name_[tok]; |
| 220 } | 219 } |
| 221 #endif | |
| 222 | 220 |
| 223 // Predicates | 221 // Predicates |
| 224 static bool IsAssignmentOp(Value tok) { | 222 static bool IsAssignmentOp(Value tok) { |
| 225 return INIT_VAR <= tok && tok <= ASSIGN_MOD; | 223 return INIT_VAR <= tok && tok <= ASSIGN_MOD; |
| 226 } | 224 } |
| 227 | 225 |
| 228 static bool IsBinaryOp(Value op) { | 226 static bool IsBinaryOp(Value op) { |
| 229 return COMMA <= op && op <= MOD; | 227 return COMMA <= op && op <= MOD; |
| 230 } | 228 } |
| 231 | 229 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 254 } | 252 } |
| 255 | 253 |
| 256 // Returns the precedence > 0 for binary and compare | 254 // Returns the precedence > 0 for binary and compare |
| 257 // operators; returns 0 otherwise. | 255 // operators; returns 0 otherwise. |
| 258 static int Precedence(Value tok) { | 256 static int Precedence(Value tok) { |
| 259 ASSERT(0 <= tok && tok < NUM_TOKENS); | 257 ASSERT(0 <= tok && tok < NUM_TOKENS); |
| 260 return precedence_[tok]; | 258 return precedence_[tok]; |
| 261 } | 259 } |
| 262 | 260 |
| 263 private: | 261 private: |
| 264 #ifdef DEBUG | |
| 265 static const char* name_[NUM_TOKENS]; | 262 static const char* name_[NUM_TOKENS]; |
| 266 #endif | |
| 267 static const char* string_[NUM_TOKENS]; | 263 static const char* string_[NUM_TOKENS]; |
| 268 static int8_t precedence_[NUM_TOKENS]; | 264 static int8_t precedence_[NUM_TOKENS]; |
| 269 }; | 265 }; |
| 270 | 266 |
| 271 } } // namespace v8::internal | 267 } } // namespace v8::internal |
| 272 | 268 |
| 273 #endif // V8_TOKEN_H_ | 269 #endif // V8_TOKEN_H_ |
| OLD | NEW |