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

Side by Side Diff: utils/template/tokenkind.dart

Issue 12282038: Remove deprecated string features. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge to head Created 7 years, 9 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 | « utils/template/tokenizer_base.dart ('k') | utils/testrunner/layout_test_controller.dart » ('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) 2011, 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 // TODO(terry): Need to be consistent with tokens either they're ASCII tokens 5 // TODO(terry): Need to be consistent with tokens either they're ASCII tokens
6 // e.g., ASTERISK or they're CSS e.g., PSEUDO, COMBINATOR_*. 6 // e.g., ASTERISK or they're CSS e.g., PSEUDO, COMBINATOR_*.
7 class TokenKind { 7 class TokenKind {
8 // Common shared tokens used in TokenizerBase. 8 // Common shared tokens used in TokenizerBase.
9 static const int UNUSED = 0; // Unused place holder... 9 static const int UNUSED = 0; // Unused place holder...
10 static const int END_OF_FILE = 1; 10 static const int END_OF_FILE = 1;
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 * Return the token that matches the unit ident found. 305 * Return the token that matches the unit ident found.
306 */ 306 */
307 static int matchList(var identList, String tokenField, String text, 307 static int matchList(var identList, String tokenField, String text,
308 int offset, int length) { 308 int offset, int length) {
309 for (final entry in identList) { 309 for (final entry in identList) {
310 String ident = entry['value']; 310 String ident = entry['value'];
311 if (length == ident.length) { 311 if (length == ident.length) {
312 int idx = offset; 312 int idx = offset;
313 bool match = true; 313 bool match = true;
314 for (int identIdx = 0; identIdx < ident.length; identIdx++) { 314 for (int identIdx = 0; identIdx < ident.length; identIdx++) {
315 int identChar = ident.charCodeAt(identIdx); 315 int identChar = ident.codeUnitAt(identIdx);
316 int char = text.charCodeAt(idx++); 316 int char = text.codeUnitAt(idx++);
317 // Compare lowercase to lowercase then check if char is uppercase. 317 // Compare lowercase to lowercase then check if char is uppercase.
318 match = match && (char == identChar || 318 match = match && (char == identChar ||
319 ((char >= ASCII_UPPER_A && char <= ASCII_UPPER_Z) && 319 ((char >= ASCII_UPPER_A && char <= ASCII_UPPER_Z) &&
320 (char + 32) == identChar)); 320 (char + 32) == identChar));
321 if (!match) { 321 if (!match) {
322 break; 322 break;
323 } 323 }
324 } 324 }
325 325
326 if (match) { 326 if (match) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 throw "Unknown TOKEN"; 418 throw "Unknown TOKEN";
419 } 419 }
420 } 420 }
421 421
422 TokenKind() { 422 TokenKind() {
423 tokens = []; 423 tokens = [];
424 424
425 // All tokens must be in TokenKind order. 425 // All tokens must be in TokenKind order.
426 tokens.add(-1); // TokenKind.UNUSED 426 tokens.add(-1); // TokenKind.UNUSED
427 tokens.add(0); // TokenKind.END_OF_FILE match base 427 tokens.add(0); // TokenKind.END_OF_FILE match base
428 tokens.add(TokenKind.kindToString(TokenKind.LPAREN).charCodeAt(0)); 428 tokens.add(TokenKind.kindToString(TokenKind.LPAREN).codeUnitAt(0));
429 tokens.add(TokenKind.kindToString(TokenKind.RPAREN).charCodeAt(0)); 429 tokens.add(TokenKind.kindToString(TokenKind.RPAREN).codeUnitAt(0));
430 tokens.add(TokenKind.kindToString(TokenKind.LBRACK).charCodeAt(0)); 430 tokens.add(TokenKind.kindToString(TokenKind.LBRACK).codeUnitAt(0));
431 tokens.add(TokenKind.kindToString(TokenKind.RBRACK).charCodeAt(0)); 431 tokens.add(TokenKind.kindToString(TokenKind.RBRACK).codeUnitAt(0));
432 tokens.add(TokenKind.kindToString(TokenKind.LBRACE).charCodeAt(0)); 432 tokens.add(TokenKind.kindToString(TokenKind.LBRACE).codeUnitAt(0));
433 tokens.add(TokenKind.kindToString(TokenKind.RBRACE).charCodeAt(0)); 433 tokens.add(TokenKind.kindToString(TokenKind.RBRACE).codeUnitAt(0));
434 tokens.add(TokenKind.kindToString(TokenKind.DOT).charCodeAt(0)); 434 tokens.add(TokenKind.kindToString(TokenKind.DOT).codeUnitAt(0));
435 tokens.add(TokenKind.kindToString(TokenKind.SEMICOLON).charCodeAt(0)); 435 tokens.add(TokenKind.kindToString(TokenKind.SEMICOLON).codeUnitAt(0));
436 tokens.add(TokenKind.kindToString(TokenKind.SPACE).charCodeAt(0)); 436 tokens.add(TokenKind.kindToString(TokenKind.SPACE).codeUnitAt(0));
437 tokens.add(TokenKind.kindToString(TokenKind.TAB).charCodeAt(0)); 437 tokens.add(TokenKind.kindToString(TokenKind.TAB).codeUnitAt(0));
438 tokens.add(TokenKind.kindToString(TokenKind.NEWLINE).charCodeAt(0)); 438 tokens.add(TokenKind.kindToString(TokenKind.NEWLINE).codeUnitAt(0));
439 tokens.add(TokenKind.kindToString(TokenKind.RETURN).charCodeAt(0)); 439 tokens.add(TokenKind.kindToString(TokenKind.RETURN).codeUnitAt(0));
440 tokens.add(TokenKind.kindToString(TokenKind.COMMA).charCodeAt(0)); 440 tokens.add(TokenKind.kindToString(TokenKind.COMMA).codeUnitAt(0));
441 tokens.add(TokenKind.kindToString(TokenKind.LESS_THAN).charCodeAt(0)); 441 tokens.add(TokenKind.kindToString(TokenKind.LESS_THAN).codeUnitAt(0));
442 tokens.add(TokenKind.kindToString(TokenKind.GREATER_THAN).charCodeAt(0)); 442 tokens.add(TokenKind.kindToString(TokenKind.GREATER_THAN).codeUnitAt(0));
443 tokens.add(TokenKind.kindToString(TokenKind.SLASH).charCodeAt(0)); 443 tokens.add(TokenKind.kindToString(TokenKind.SLASH).codeUnitAt(0));
444 tokens.add(TokenKind.kindToString(TokenKind.DOLLAR).charCodeAt(0)); 444 tokens.add(TokenKind.kindToString(TokenKind.DOLLAR).codeUnitAt(0));
445 tokens.add(TokenKind.kindToString(TokenKind.HASH).charCodeAt(0)); 445 tokens.add(TokenKind.kindToString(TokenKind.HASH).codeUnitAt(0));
446 tokens.add(TokenKind.kindToString(TokenKind.MINUS).charCodeAt(0)); 446 tokens.add(TokenKind.kindToString(TokenKind.MINUS).codeUnitAt(0));
447 tokens.add(TokenKind.kindToString(TokenKind.EQUAL).charCodeAt(0)); 447 tokens.add(TokenKind.kindToString(TokenKind.EQUAL).codeUnitAt(0));
448 tokens.add(TokenKind.kindToString(TokenKind.DOUBLE_QUOTE).charCodeAt(0)); 448 tokens.add(TokenKind.kindToString(TokenKind.DOUBLE_QUOTE).codeUnitAt(0));
449 tokens.add(TokenKind.kindToString(TokenKind.SINGLE_QUOTE).charCodeAt(0)); 449 tokens.add(TokenKind.kindToString(TokenKind.SINGLE_QUOTE).codeUnitAt(0));
450 tokens.add(TokenKind.kindToString(TokenKind.ASTERISK).charCodeAt(0)); 450 tokens.add(TokenKind.kindToString(TokenKind.ASTERISK).codeUnitAt(0));
451 451
452 assert(tokens.length == TokenKind.END_TOKENS); 452 assert(tokens.length == TokenKind.END_TOKENS);
453 } 453 }
454 454
455 static bool isIdentifier(int kind) { 455 static bool isIdentifier(int kind) {
456 return kind == IDENTIFIER; 456 return kind == IDENTIFIER;
457 } 457 }
458 } 458 }
459 459
460 class NoElementMatchException implements Exception { 460 class NoElementMatchException implements Exception {
461 String _tagName; 461 String _tagName;
462 NoElementMatchException(this._tagName); 462 NoElementMatchException(this._tagName);
463 463
464 String get name => _tagName; 464 String get name => _tagName;
465 } 465 }
OLDNEW
« no previous file with comments | « utils/template/tokenizer_base.dart ('k') | utils/testrunner/layout_test_controller.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698