Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(778)

Side by Side Diff: runtime/vm/token.h

Issue 9107070: Proper handling of built-in identifiers (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/parser.cc ('k') | tests/language/language.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 TOK(kLIBRARY, "#library", 0, kNoAttribute) \ 127 TOK(kLIBRARY, "#library", 0, kNoAttribute) \
128 TOK(kIMPORT, "#import", 0, kNoAttribute) \ 128 TOK(kIMPORT, "#import", 0, kNoAttribute) \
129 TOK(kSOURCE, "#source", 0, kNoAttribute) \ 129 TOK(kSOURCE, "#source", 0, kNoAttribute) \
130 130
131 // List of keywords. The list must be alphabetically ordered. The 131 // List of keywords. The list must be alphabetically ordered. The
132 // keyword recognition code depends on the ordering. 132 // keyword recognition code depends on the ordering.
133 // If you add a keyword at the beginning or end of this list, make sure 133 // If you add a keyword at the beginning or end of this list, make sure
134 // to update kFirstKeyword and kLastKeyword below. 134 // to update kFirstKeyword and kLastKeyword below.
135 #define DART_KEYWORD_LIST(KW) \ 135 #define DART_KEYWORD_LIST(KW) \
136 KW(kABSTRACT, "abstract", 0, kPseudoKeyword) /* == kFirstKeyword */ \ 136 KW(kABSTRACT, "abstract", 0, kPseudoKeyword) /* == kFirstKeyword */ \
137 KW(kASSERT, "assert", 0, kKeyword) \ 137 KW(kASSERT, "assert", 0, kPseudoKeyword) \
138 KW(kBREAK, "break", 0, kKeyword) \ 138 KW(kBREAK, "break", 0, kKeyword) \
139 KW(kCASE, "case", 0, kKeyword) \ 139 KW(kCASE, "case", 0, kKeyword) \
140 KW(kCATCH, "catch", 0, kKeyword) \ 140 KW(kCATCH, "catch", 0, kKeyword) \
141 KW(kCLASS, "class", 0, kKeyword) \ 141 KW(kCLASS, "class", 0, kKeyword) \
142 KW(kCONST, "const", 0, kKeyword) \ 142 KW(kCONST, "const", 0, kKeyword) \
143 KW(kCONTINUE, "continue", 0, kKeyword) \ 143 KW(kCONTINUE, "continue", 0, kKeyword) \
144 KW(kDEFAULT, "default", 0, kKeyword) \ 144 KW(kDEFAULT, "default", 0, kKeyword) \
145 KW(kDO, "do", 0, kKeyword) \ 145 KW(kDO, "do", 0, kKeyword) \
146 KW(kELSE, "else", 0, kKeyword) \ 146 KW(kELSE, "else", 0, kKeyword) \
147 KW(kEXTENDS, "extends", 0, kKeyword) \ 147 KW(kEXTENDS, "extends", 0, kKeyword) \
(...skipping 14 matching lines...) Expand all
162 KW(kOPERATOR, "operator", 0, kPseudoKeyword) \ 162 KW(kOPERATOR, "operator", 0, kPseudoKeyword) \
163 KW(kRETURN, "return", 0, kKeyword) \ 163 KW(kRETURN, "return", 0, kKeyword) \
164 KW(kSET, "set", 0, kPseudoKeyword) \ 164 KW(kSET, "set", 0, kPseudoKeyword) \
165 KW(kSTATIC, "static", 0, kPseudoKeyword) \ 165 KW(kSTATIC, "static", 0, kPseudoKeyword) \
166 KW(kSUPER, "super", 0, kKeyword) \ 166 KW(kSUPER, "super", 0, kKeyword) \
167 KW(kSWITCH, "switch", 0, kKeyword) \ 167 KW(kSWITCH, "switch", 0, kKeyword) \
168 KW(kTHIS, "this", 0, kKeyword) \ 168 KW(kTHIS, "this", 0, kKeyword) \
169 KW(kTHROW, "throw", 0, kKeyword) \ 169 KW(kTHROW, "throw", 0, kKeyword) \
170 KW(kTRUE, "true", 0, kKeyword) \ 170 KW(kTRUE, "true", 0, kKeyword) \
171 KW(kTRY, "try", 0, kKeyword) \ 171 KW(kTRY, "try", 0, kKeyword) \
172 KW(kTYPEDEF, "typedef", 0, kKeyword) \ 172 KW(kTYPEDEF, "typedef", 0, kPseudoKeyword) \
173 KW(kVAR, "var", 0, kKeyword) \ 173 KW(kVAR, "var", 0, kKeyword) \
174 KW(kVOID, "void", 0, kKeyword) \ 174 KW(kVOID, "void", 0, kKeyword) \
175 KW(kWHILE, "while", 0, kKeyword) /* == kLastKeyword */ 175 KW(kWHILE, "while", 0, kKeyword) /* == kLastKeyword */
176 176
177 177
178 class Token { 178 class Token {
179 public: 179 public:
180 #define T(t, s, p, a) t, 180 #define T(t, s, p, a) t,
181 enum Kind { 181 enum Kind {
182 DART_TOKEN_LIST(T) 182 DART_TOKEN_LIST(T)
(...skipping 25 matching lines...) Expand all
208 } 208 }
209 209
210 static bool IsInstanceofOperator(Kind tok) { 210 static bool IsInstanceofOperator(Kind tok) {
211 return (tok == kIS) || (tok == kISNOT); 211 return (tok == kIS) || (tok == kISNOT);
212 } 212 }
213 213
214 static bool IsPseudoKeyword(Kind tok) { 214 static bool IsPseudoKeyword(Kind tok) {
215 return (Attributes(tok) & kPseudoKeyword) != 0; 215 return (Attributes(tok) & kPseudoKeyword) != 0;
216 } 216 }
217 217
218 static bool IsIdentifier(Kind tok) {
219 return (tok == kIDENT) || IsPseudoKeyword(tok);
220 }
221
218 static const char* Name(Kind tok) { 222 static const char* Name(Kind tok) {
219 ASSERT(tok < kNumTokens); 223 ASSERT(tok < kNumTokens);
220 return name_[tok]; 224 return name_[tok];
221 } 225 }
222 226
223 static const char* Str(Kind tok) { 227 static const char* Str(Kind tok) {
224 ASSERT(tok < kNumTokens); 228 ASSERT(tok < kNumTokens);
225 return tok_str_[tok]; 229 return tok_str_[tok];
226 } 230 }
227 231
(...skipping 22 matching lines...) Expand all
250 static const char* name_[kNumTokens]; 254 static const char* name_[kNumTokens];
251 static const char* tok_str_[kNumTokens]; 255 static const char* tok_str_[kNumTokens];
252 static const uint8_t precedence_[kNumTokens]; 256 static const uint8_t precedence_[kNumTokens];
253 static const Attribute attributes_[kNumTokens]; 257 static const Attribute attributes_[kNumTokens];
254 }; 258 };
255 259
256 260
257 } // namespace dart 261 } // namespace dart
258 262
259 #endif // VM_TOKEN_H_ 263 #endif // VM_TOKEN_H_
OLDNEW
« no previous file with comments | « runtime/vm/parser.cc ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698