| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_TOKEN_H_ | 5 #ifndef VM_TOKEN_H_ |
| 6 #define VM_TOKEN_H_ | 6 #define VM_TOKEN_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 } | 211 } |
| 212 | 212 |
| 213 static bool IsInstanceofOperator(Kind tok) { | 213 static bool IsInstanceofOperator(Kind tok) { |
| 214 return (tok == kIS) || (tok == kISNOT); | 214 return (tok == kIS) || (tok == kISNOT); |
| 215 } | 215 } |
| 216 | 216 |
| 217 static bool IsPseudoKeyword(Kind tok) { | 217 static bool IsPseudoKeyword(Kind tok) { |
| 218 return (Attributes(tok) & kPseudoKeyword) != 0; | 218 return (Attributes(tok) & kPseudoKeyword) != 0; |
| 219 } | 219 } |
| 220 | 220 |
| 221 static bool IsKeyword(Kind tok) { |
| 222 return (Attributes(tok) & kKeyword) != 0; |
| 223 } |
| 224 |
| 221 static bool IsIdentifier(Kind tok) { | 225 static bool IsIdentifier(Kind tok) { |
| 222 return (tok == kIDENT) || IsPseudoKeyword(tok); | 226 return (tok == kIDENT) || IsPseudoKeyword(tok); |
| 223 } | 227 } |
| 224 | 228 |
| 225 static const char* Name(Kind tok) { | 229 static const char* Name(Kind tok) { |
| 226 ASSERT(tok < kNumTokens); | 230 ASSERT(tok < kNumTokens); |
| 227 return name_[tok]; | 231 return name_[tok]; |
| 228 } | 232 } |
| 229 | 233 |
| 230 static const char* Str(Kind tok) { | 234 static const char* Str(Kind tok) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 246 ASSERT(tok < kNumTokens); | 250 ASSERT(tok < kNumTokens); |
| 247 return IsRelationalOperator(tok) || | 251 return IsRelationalOperator(tok) || |
| 248 (tok == kEQ) || | 252 (tok == kEQ) || |
| 249 (tok >= kADD && tok <= kMOD) || // Arithmetic operations. | 253 (tok >= kADD && tok <= kMOD) || // Arithmetic operations. |
| 250 (tok >= kBIT_OR && tok <= kSHR) || // Bit operations. | 254 (tok >= kBIT_OR && tok <= kSHR) || // Bit operations. |
| 251 (tok == kINDEX) || | 255 (tok == kINDEX) || |
| 252 (tok == kASSIGN_INDEX) || | 256 (tok == kASSIGN_INDEX) || |
| 253 (tok == kNEGATE); | 257 (tok == kNEGATE); |
| 254 } | 258 } |
| 255 | 259 |
| 260 static bool NeedsLiteralToken(Kind tok) { |
| 261 ASSERT(tok < kNumTokens); |
| 262 return ((tok == Token::kINTEGER) || |
| 263 (tok == Token::kSTRING) || |
| 264 (tok == Token::kINTERPOL_VAR) || |
| 265 (tok == Token::kERROR) || |
| 266 (tok == Token::kDOUBLE)); |
| 267 } |
| 268 |
| 256 private: | 269 private: |
| 257 static const char* name_[kNumTokens]; | 270 static const char* name_[kNumTokens]; |
| 258 static const char* tok_str_[kNumTokens]; | 271 static const char* tok_str_[kNumTokens]; |
| 259 static const uint8_t precedence_[kNumTokens]; | 272 static const uint8_t precedence_[kNumTokens]; |
| 260 static const Attribute attributes_[kNumTokens]; | 273 static const Attribute attributes_[kNumTokens]; |
| 261 }; | 274 }; |
| 262 | 275 |
| 263 | 276 |
| 264 } // namespace dart | 277 } // namespace dart |
| 265 | 278 |
| 266 #endif // VM_TOKEN_H_ | 279 #endif // VM_TOKEN_H_ |
| OLD | NEW |