| OLD | NEW |
| 1 // Copyright (c) 2011, 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 "vm/assert.h" | 8 #include "vm/assert.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| 11 | 11 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 TOK(kLIBRARY, "#library", 0, kNoAttribute) \ | 129 TOK(kLIBRARY, "#library", 0, kNoAttribute) \ |
| 130 TOK(kIMPORT, "#import", 0, kNoAttribute) \ | 130 TOK(kIMPORT, "#import", 0, kNoAttribute) \ |
| 131 TOK(kSOURCE, "#source", 0, kNoAttribute) \ | 131 TOK(kSOURCE, "#source", 0, kNoAttribute) \ |
| 132 | 132 |
| 133 // List of keywords. The list must be alphabetically ordered. The | 133 // List of keywords. The list must be alphabetically ordered. The |
| 134 // keyword recognition code depends on the ordering. | 134 // keyword recognition code depends on the ordering. |
| 135 // If you add a keyword at the beginning or end of this list, make sure | 135 // If you add a keyword at the beginning or end of this list, make sure |
| 136 // to update kFirstKeyword and kLastKeyword below. | 136 // to update kFirstKeyword and kLastKeyword below. |
| 137 #define DART_KEYWORD_LIST(KW) \ | 137 #define DART_KEYWORD_LIST(KW) \ |
| 138 KW(kABSTRACT, "abstract", 0, kPseudoKeyword) /* == kFirstKeyword */ \ | 138 KW(kABSTRACT, "abstract", 0, kPseudoKeyword) /* == kFirstKeyword */ \ |
| 139 KW(kASSERT, "assert", 0, kKeyword) \ | 139 KW(kASSERT, "assert", 0, kPseudoKeyword) \ |
| 140 KW(kBREAK, "break", 0, kKeyword) \ | 140 KW(kBREAK, "break", 0, kKeyword) \ |
| 141 KW(kCASE, "case", 0, kKeyword) \ | 141 KW(kCASE, "case", 0, kKeyword) \ |
| 142 KW(kCATCH, "catch", 0, kKeyword) \ | 142 KW(kCATCH, "catch", 0, kKeyword) \ |
| 143 KW(kCLASS, "class", 0, kKeyword) \ | 143 KW(kCLASS, "class", 0, kKeyword) \ |
| 144 KW(kCONST, "const", 0, kKeyword) \ | 144 KW(kCONST, "const", 0, kKeyword) \ |
| 145 KW(kCONTINUE, "continue", 0, kKeyword) \ | 145 KW(kCONTINUE, "continue", 0, kKeyword) \ |
| 146 KW(kDEFAULT, "default", 0, kKeyword) \ | 146 KW(kDEFAULT, "default", 0, kKeyword) \ |
| 147 KW(kDO, "do", 0, kKeyword) \ | 147 KW(kDO, "do", 0, kKeyword) \ |
| 148 KW(kELSE, "else", 0, kKeyword) \ | 148 KW(kELSE, "else", 0, kKeyword) \ |
| 149 KW(kEXTENDS, "extends", 0, kKeyword) \ | 149 KW(kEXTENDS, "extends", 0, kKeyword) \ |
| (...skipping 14 matching lines...) Expand all Loading... |
| 164 KW(kOPERATOR, "operator", 0, kPseudoKeyword) \ | 164 KW(kOPERATOR, "operator", 0, kPseudoKeyword) \ |
| 165 KW(kRETURN, "return", 0, kKeyword) \ | 165 KW(kRETURN, "return", 0, kKeyword) \ |
| 166 KW(kSET, "set", 0, kPseudoKeyword) \ | 166 KW(kSET, "set", 0, kPseudoKeyword) \ |
| 167 KW(kSTATIC, "static", 0, kPseudoKeyword) \ | 167 KW(kSTATIC, "static", 0, kPseudoKeyword) \ |
| 168 KW(kSUPER, "super", 0, kKeyword) \ | 168 KW(kSUPER, "super", 0, kKeyword) \ |
| 169 KW(kSWITCH, "switch", 0, kKeyword) \ | 169 KW(kSWITCH, "switch", 0, kKeyword) \ |
| 170 KW(kTHIS, "this", 0, kKeyword) \ | 170 KW(kTHIS, "this", 0, kKeyword) \ |
| 171 KW(kTHROW, "throw", 0, kKeyword) \ | 171 KW(kTHROW, "throw", 0, kKeyword) \ |
| 172 KW(kTRUE, "true", 0, kKeyword) \ | 172 KW(kTRUE, "true", 0, kKeyword) \ |
| 173 KW(kTRY, "try", 0, kKeyword) \ | 173 KW(kTRY, "try", 0, kKeyword) \ |
| 174 KW(kTYPEDEF, "typedef", 0, kKeyword) \ | 174 KW(kTYPEDEF, "typedef", 0, kPseudoKeyword) \ |
| 175 KW(kVAR, "var", 0, kKeyword) \ | 175 KW(kVAR, "var", 0, kKeyword) \ |
| 176 KW(kVOID, "void", 0, kKeyword) \ | 176 KW(kVOID, "void", 0, kKeyword) \ |
| 177 KW(kWHILE, "while", 0, kKeyword) /* == kLastKeyword */ | 177 KW(kWHILE, "while", 0, kKeyword) /* == kLastKeyword */ |
| 178 | 178 |
| 179 | 179 |
| 180 class Token { | 180 class Token { |
| 181 public: | 181 public: |
| 182 #define T(t, s, p, a) t, | 182 #define T(t, s, p, a) t, |
| 183 enum Kind { | 183 enum Kind { |
| 184 DART_TOKEN_LIST(T) | 184 DART_TOKEN_LIST(T) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 210 } | 210 } |
| 211 | 211 |
| 212 static bool IsInstanceofOperator(Kind tok) { | 212 static bool IsInstanceofOperator(Kind tok) { |
| 213 return (tok == kIS) || (tok == kISNOT); | 213 return (tok == kIS) || (tok == kISNOT); |
| 214 } | 214 } |
| 215 | 215 |
| 216 static bool IsPseudoKeyword(Kind tok) { | 216 static bool IsPseudoKeyword(Kind tok) { |
| 217 return (Attributes(tok) & kPseudoKeyword) != 0; | 217 return (Attributes(tok) & kPseudoKeyword) != 0; |
| 218 } | 218 } |
| 219 | 219 |
| 220 static bool IsIdentifier(Kind tok) { |
| 221 return (tok == kIDENT) || IsPseudoKeyword(tok); |
| 222 } |
| 223 |
| 220 static const char* Name(Kind tok) { | 224 static const char* Name(Kind tok) { |
| 221 ASSERT(tok < kNumTokens); | 225 ASSERT(tok < kNumTokens); |
| 222 return name_[tok]; | 226 return name_[tok]; |
| 223 } | 227 } |
| 224 | 228 |
| 225 static const char* Str(Kind tok) { | 229 static const char* Str(Kind tok) { |
| 226 ASSERT(tok < kNumTokens); | 230 ASSERT(tok < kNumTokens); |
| 227 return tok_str_[tok]; | 231 return tok_str_[tok]; |
| 228 } | 232 } |
| 229 | 233 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 253 static const char* name_[kNumTokens]; | 257 static const char* name_[kNumTokens]; |
| 254 static const char* tok_str_[kNumTokens]; | 258 static const char* tok_str_[kNumTokens]; |
| 255 static const uint8_t precedence_[kNumTokens]; | 259 static const uint8_t precedence_[kNumTokens]; |
| 256 static const Attribute attributes_[kNumTokens]; | 260 static const Attribute attributes_[kNumTokens]; |
| 257 }; | 261 }; |
| 258 | 262 |
| 259 | 263 |
| 260 } // namespace dart | 264 } // namespace dart |
| 261 | 265 |
| 262 #endif // VM_TOKEN_H_ | 266 #endif // VM_TOKEN_H_ |
| OLD | NEW |