| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 KW(kSTATIC, "static", 0, kPseudoKeyword) \ | 178 KW(kSTATIC, "static", 0, kPseudoKeyword) \ |
| 179 KW(kSUPER, "super", 0, kKeyword) \ | 179 KW(kSUPER, "super", 0, kKeyword) \ |
| 180 KW(kSWITCH, "switch", 0, kKeyword) \ | 180 KW(kSWITCH, "switch", 0, kKeyword) \ |
| 181 KW(kTHIS, "this", 0, kKeyword) \ | 181 KW(kTHIS, "this", 0, kKeyword) \ |
| 182 KW(kTHROW, "throw", 0, kKeyword) \ | 182 KW(kTHROW, "throw", 0, kKeyword) \ |
| 183 KW(kTRUE, "true", 0, kKeyword) \ | 183 KW(kTRUE, "true", 0, kKeyword) \ |
| 184 KW(kTRY, "try", 0, kKeyword) \ | 184 KW(kTRY, "try", 0, kKeyword) \ |
| 185 KW(kTYPEDEF, "typedef", 0, kPseudoKeyword) \ | 185 KW(kTYPEDEF, "typedef", 0, kPseudoKeyword) \ |
| 186 KW(kVAR, "var", 0, kKeyword) \ | 186 KW(kVAR, "var", 0, kKeyword) \ |
| 187 KW(kVOID, "void", 0, kKeyword) \ | 187 KW(kVOID, "void", 0, kKeyword) \ |
| 188 KW(kWHILE, "while", 0, kKeyword) /* == kLastKeyword */ | 188 KW(kWHILE, "while", 0, kKeyword) \ |
| 189 KW(kWITH, "with", 0, kKeyword) /* == kLastKeyword */ |
| 189 | 190 |
| 190 | 191 |
| 191 class String; | 192 class String; |
| 192 | 193 |
| 193 class Token { | 194 class Token { |
| 194 public: | 195 public: |
| 195 #define T(t, s, p, a) t, | 196 #define T(t, s, p, a) t, |
| 196 enum Kind { | 197 enum Kind { |
| 197 DART_TOKEN_LIST(T) | 198 DART_TOKEN_LIST(T) |
| 198 DART_KEYWORD_LIST(T) | 199 DART_KEYWORD_LIST(T) |
| 199 kNumTokens | 200 kNumTokens |
| 200 }; | 201 }; |
| 201 #undef T | 202 #undef T |
| 202 | 203 |
| 203 enum Attribute { | 204 enum Attribute { |
| 204 kNoAttribute = 0, | 205 kNoAttribute = 0, |
| 205 kKeyword = 1 << 0, | 206 kKeyword = 1 << 0, |
| 206 kPseudoKeyword = 1 << 1, | 207 kPseudoKeyword = 1 << 1, |
| 207 }; | 208 }; |
| 208 | 209 |
| 209 static const Kind kFirstKeyword = kABSTRACT; | 210 static const Kind kFirstKeyword = kABSTRACT; |
| 210 static const Kind kLastKeyword = kWHILE; | 211 static const Kind kLastKeyword = kWITH; |
| 211 static const int numKeywords = kWHILE - kABSTRACT + 1; | 212 static const int numKeywords = kLastKeyword - kFirstKeyword + 1; |
| 212 | 213 |
| 213 static bool IsAssignmentOperator(Kind tok) { | 214 static bool IsAssignmentOperator(Kind tok) { |
| 214 return kASSIGN <= tok && tok <= kASSIGN_MOD; | 215 return kASSIGN <= tok && tok <= kASSIGN_MOD; |
| 215 } | 216 } |
| 216 | 217 |
| 217 static bool IsRelationalOperator(Kind tok) { | 218 static bool IsRelationalOperator(Kind tok) { |
| 218 return kLT <= tok && tok <= kGTE; | 219 return kLT <= tok && tok <= kGTE; |
| 219 } | 220 } |
| 220 | 221 |
| 221 static bool IsEqualityOperator(Kind tok) { | 222 static bool IsEqualityOperator(Kind tok) { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 static const char* name_[]; | 297 static const char* name_[]; |
| 297 static const char* tok_str_[]; | 298 static const char* tok_str_[]; |
| 298 static const uint8_t precedence_[]; | 299 static const uint8_t precedence_[]; |
| 299 static const Attribute attributes_[]; | 300 static const Attribute attributes_[]; |
| 300 }; | 301 }; |
| 301 | 302 |
| 302 | 303 |
| 303 } // namespace dart | 304 } // namespace dart |
| 304 | 305 |
| 305 #endif // VM_TOKEN_H_ | 306 #endif // VM_TOKEN_H_ |
| OLD | NEW |