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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 KW(kTHIS, "this", 0, kKeyword) \ | 171 KW(kTHIS, "this", 0, kKeyword) \ |
172 KW(kTHROW, "throw", 0, kKeyword) \ | 172 KW(kTHROW, "throw", 0, kKeyword) \ |
173 KW(kTRUE, "true", 0, kKeyword) \ | 173 KW(kTRUE, "true", 0, kKeyword) \ |
174 KW(kTRY, "try", 0, kKeyword) \ | 174 KW(kTRY, "try", 0, kKeyword) \ |
175 KW(kTYPEDEF, "typedef", 0, kPseudoKeyword) \ | 175 KW(kTYPEDEF, "typedef", 0, kPseudoKeyword) \ |
176 KW(kVAR, "var", 0, kKeyword) \ | 176 KW(kVAR, "var", 0, kKeyword) \ |
177 KW(kVOID, "void", 0, kKeyword) \ | 177 KW(kVOID, "void", 0, kKeyword) \ |
178 KW(kWHILE, "while", 0, kKeyword) /* == kLastKeyword */ | 178 KW(kWHILE, "while", 0, kKeyword) /* == kLastKeyword */ |
179 | 179 |
180 | 180 |
| 181 class String; |
| 182 |
181 class Token { | 183 class Token { |
182 public: | 184 public: |
183 #define T(t, s, p, a) t, | 185 #define T(t, s, p, a) t, |
184 enum Kind { | 186 enum Kind { |
185 DART_TOKEN_LIST(T) | 187 DART_TOKEN_LIST(T) |
186 DART_KEYWORD_LIST(T) | 188 DART_KEYWORD_LIST(T) |
187 kNumTokens | 189 kNumTokens |
188 }; | 190 }; |
189 #undef T | 191 #undef T |
190 | 192 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 261 |
260 static bool NeedsLiteralToken(Kind tok) { | 262 static bool NeedsLiteralToken(Kind tok) { |
261 ASSERT(tok < kNumTokens); | 263 ASSERT(tok < kNumTokens); |
262 return ((tok == Token::kINTEGER) || | 264 return ((tok == Token::kINTEGER) || |
263 (tok == Token::kSTRING) || | 265 (tok == Token::kSTRING) || |
264 (tok == Token::kINTERPOL_VAR) || | 266 (tok == Token::kINTERPOL_VAR) || |
265 (tok == Token::kERROR) || | 267 (tok == Token::kERROR) || |
266 (tok == Token::kDOUBLE)); | 268 (tok == Token::kDOUBLE)); |
267 } | 269 } |
268 | 270 |
| 271 // Returns kILLEGAL if 'name' does not match a BinaryOp. |
| 272 static Token::Kind GetBinaryOp(const String& name); |
| 273 |
269 private: | 274 private: |
270 static const char* name_[]; | 275 static const char* name_[]; |
271 static const char* tok_str_[]; | 276 static const char* tok_str_[]; |
272 static const uint8_t precedence_[]; | 277 static const uint8_t precedence_[]; |
273 static const Attribute attributes_[]; | 278 static const Attribute attributes_[]; |
274 }; | 279 }; |
275 | 280 |
276 | 281 |
277 } // namespace dart | 282 } // namespace dart |
278 | 283 |
279 #endif // VM_TOKEN_H_ | 284 #endif // VM_TOKEN_H_ |
OLD | NEW |