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

Side by Side Diff: utils/css/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/css/tokenizer_base.dart ('k') | utils/peg/pegparser.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; // TODO(terry): Must match base 10 static const int END_OF_FILE = 1; // TODO(terry): Must match base
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 // Uniquely synthesized tokens for CSS. 87 // Uniquely synthesized tokens for CSS.
88 static const int SELECTOR_EXPRESSION = 512; 88 static const int SELECTOR_EXPRESSION = 512;
89 static const int COMBINATOR_NONE = 513; 89 static const int COMBINATOR_NONE = 513;
90 static const int COMBINATOR_DESCENDANT = 514; // Space combinator 90 static const int COMBINATOR_DESCENDANT = 514; // Space combinator
91 static const int COMBINATOR_PLUS = 515; // + combinator 91 static const int COMBINATOR_PLUS = 515; // + combinator
92 static const int COMBINATOR_GREATER = 516; // > combinator 92 static const int COMBINATOR_GREATER = 516; // > combinator
93 static const int COMBINATOR_TILDE = 517; // ~ combinator 93 static const int COMBINATOR_TILDE = 517; // ~ combinator
94 94
95 static const int UNARY_OP_NONE = 518; // No unary operator present. 95 static const int UNARY_OP_NONE = 518; // No unary operator present.
96 96
97 // Attribute match types: 97 // Attribute match types:
98 static const int INCLUDES = 530; // '~=' 98 static const int INCLUDES = 530; // '~='
99 static const int DASH_MATCH = 531; // '|=' 99 static const int DASH_MATCH = 531; // '|='
100 static const int PREFIX_MATCH = 532; // '^=' 100 static const int PREFIX_MATCH = 532; // '^='
101 static const int SUFFIX_MATCH = 533; // '$=' 101 static const int SUFFIX_MATCH = 533; // '$='
102 static const int SUBSTRING_MATCH = 534; // '*=' 102 static const int SUBSTRING_MATCH = 534; // '*='
103 static const int NO_MATCH = 535; // No operator. 103 static const int NO_MATCH = 535; // No operator.
104 104
105 // Unit types: 105 // Unit types:
106 static const int UNIT_EM = 600; 106 static const int UNIT_EM = 600;
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 * Return the token that matches the unit ident found. 376 * Return the token that matches the unit ident found.
377 */ 377 */
378 static int matchList(var identList, String tokenField, String text, 378 static int matchList(var identList, String tokenField, String text,
379 int offset, int length) { 379 int offset, int length) {
380 for (final entry in identList) { 380 for (final entry in identList) {
381 String ident = entry['value']; 381 String ident = entry['value'];
382 if (length == ident.length) { 382 if (length == ident.length) {
383 int idx = offset; 383 int idx = offset;
384 bool match = true; 384 bool match = true;
385 for (int identIdx = 0; identIdx < ident.length; identIdx++) { 385 for (int identIdx = 0; identIdx < ident.length; identIdx++) {
386 int identChar = ident.charCodeAt(identIdx); 386 int identChar = ident.codeUnitAt(identIdx);
387 int char = text.charCodeAt(idx++); 387 int char = text.codeUnitAt(idx++);
388 // Compare lowercase to lowercase then check if char is uppercase. 388 // Compare lowercase to lowercase then check if char is uppercase.
389 match = match && (char == identChar || 389 match = match && (char == identChar ||
390 ((char >= ASCII_UPPER_A && char <= ASCII_UPPER_Z) && 390 ((char >= ASCII_UPPER_A && char <= ASCII_UPPER_Z) &&
391 (char + 32) == identChar)); 391 (char + 32) == identChar));
392 if (!match) { 392 if (!match) {
393 break; 393 break;
394 } 394 }
395 } 395 }
396 396
397 if (match) { 397 if (match) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 * value as decimal number. 441 * value as decimal number.
442 */ 442 */
443 static int matchColorName(String text) { 443 static int matchColorName(String text) {
444 int length = text.length; 444 int length = text.length;
445 for (final entry in _EXTENDED_COLOR_NAMES) { 445 for (final entry in _EXTENDED_COLOR_NAMES) {
446 String ident = entry['name']; 446 String ident = entry['name'];
447 if (length == ident.length) { 447 if (length == ident.length) {
448 int idx = 0; 448 int idx = 0;
449 bool match = true; 449 bool match = true;
450 for (int identIdx = 0; identIdx < ident.length; identIdx++) { 450 for (int identIdx = 0; identIdx < ident.length; identIdx++) {
451 int identChar = ident.charCodeAt(identIdx); 451 int identChar = ident.codeUnitAt(identIdx);
452 int char = text.charCodeAt(idx++); 452 int char = text.codeUnitAt(idx++);
453 // Compare lowercase to lowercase then check if char is uppercase. 453 // Compare lowercase to lowercase then check if char is uppercase.
454 match = match && (char == identChar || 454 match = match && (char == identChar ||
455 ((char >= ASCII_UPPER_A && char <= ASCII_UPPER_Z) && 455 ((char >= ASCII_UPPER_A && char <= ASCII_UPPER_Z) &&
456 (char + 32) == identChar)); 456 (char + 32) == identChar));
457 if (!match) { 457 if (!match) {
458 break; 458 break;
459 } 459 }
460 } 460 }
461 461
462 if (match) { 462 if (match) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 throw "Unknown TOKEN"; 538 throw "Unknown TOKEN";
539 } 539 }
540 } 540 }
541 541
542 TokenKind() { 542 TokenKind() {
543 tokens = []; 543 tokens = [];
544 544
545 // All tokens must be in TokenKind order. 545 // All tokens must be in TokenKind order.
546 tokens.add(-1); // TokenKind.UNUSED 546 tokens.add(-1); // TokenKind.UNUSED
547 tokens.add(0); // TokenKind.END_OF_FILE match base 547 tokens.add(0); // TokenKind.END_OF_FILE match base
548 tokens.add(TokenKind.kindToString(TokenKind.LPAREN).charCodeAt(0)); 548 tokens.add(TokenKind.kindToString(TokenKind.LPAREN).codeUnitAt(0));
549 tokens.add(TokenKind.kindToString(TokenKind.RPAREN).charCodeAt(0)); 549 tokens.add(TokenKind.kindToString(TokenKind.RPAREN).codeUnitAt(0));
550 tokens.add(TokenKind.kindToString(TokenKind.LBRACK).charCodeAt(0)); 550 tokens.add(TokenKind.kindToString(TokenKind.LBRACK).codeUnitAt(0));
551 tokens.add(TokenKind.kindToString(TokenKind.RBRACK).charCodeAt(0)); 551 tokens.add(TokenKind.kindToString(TokenKind.RBRACK).codeUnitAt(0));
552 tokens.add(TokenKind.kindToString(TokenKind.LBRACE).charCodeAt(0)); 552 tokens.add(TokenKind.kindToString(TokenKind.LBRACE).codeUnitAt(0));
553 tokens.add(TokenKind.kindToString(TokenKind.RBRACE).charCodeAt(0)); 553 tokens.add(TokenKind.kindToString(TokenKind.RBRACE).codeUnitAt(0));
554 tokens.add(TokenKind.kindToString(TokenKind.DOT).charCodeAt(0)); 554 tokens.add(TokenKind.kindToString(TokenKind.DOT).codeUnitAt(0));
555 tokens.add(TokenKind.kindToString(TokenKind.SEMICOLON).charCodeAt(0)); 555 tokens.add(TokenKind.kindToString(TokenKind.SEMICOLON).codeUnitAt(0));
556 tokens.add(TokenKind.kindToString(TokenKind.AT).charCodeAt(0)); 556 tokens.add(TokenKind.kindToString(TokenKind.AT).codeUnitAt(0));
557 tokens.add(TokenKind.kindToString(TokenKind.HASH).charCodeAt(0)); 557 tokens.add(TokenKind.kindToString(TokenKind.HASH).codeUnitAt(0));
558 tokens.add(TokenKind.kindToString(TokenKind.PLUS).charCodeAt(0)); 558 tokens.add(TokenKind.kindToString(TokenKind.PLUS).codeUnitAt(0));
559 tokens.add(TokenKind.kindToString(TokenKind.GREATER).charCodeAt(0)); 559 tokens.add(TokenKind.kindToString(TokenKind.GREATER).codeUnitAt(0));
560 tokens.add(TokenKind.kindToString(TokenKind.TILDE).charCodeAt(0)); 560 tokens.add(TokenKind.kindToString(TokenKind.TILDE).codeUnitAt(0));
561 tokens.add(TokenKind.kindToString(TokenKind.ASTERISK).charCodeAt(0)); 561 tokens.add(TokenKind.kindToString(TokenKind.ASTERISK).codeUnitAt(0));
562 tokens.add(TokenKind.kindToString(TokenKind.NAMESPACE).charCodeAt(0)); 562 tokens.add(TokenKind.kindToString(TokenKind.NAMESPACE).codeUnitAt(0));
563 tokens.add(TokenKind.kindToString(TokenKind.COLON).charCodeAt(0)); 563 tokens.add(TokenKind.kindToString(TokenKind.COLON).codeUnitAt(0));
564 tokens.add(TokenKind.kindToString(TokenKind.PRIVATE_NAME).charCodeAt(0)); 564 tokens.add(TokenKind.kindToString(TokenKind.PRIVATE_NAME).codeUnitAt(0));
565 tokens.add(TokenKind.kindToString(TokenKind.COMMA).charCodeAt(0)); 565 tokens.add(TokenKind.kindToString(TokenKind.COMMA).codeUnitAt(0));
566 tokens.add(TokenKind.kindToString(TokenKind.SPACE).charCodeAt(0)); 566 tokens.add(TokenKind.kindToString(TokenKind.SPACE).codeUnitAt(0));
567 tokens.add(TokenKind.kindToString(TokenKind.TAB).charCodeAt(0)); 567 tokens.add(TokenKind.kindToString(TokenKind.TAB).codeUnitAt(0));
568 tokens.add(TokenKind.kindToString(TokenKind.NEWLINE).charCodeAt(0)); 568 tokens.add(TokenKind.kindToString(TokenKind.NEWLINE).codeUnitAt(0));
569 tokens.add(TokenKind.kindToString(TokenKind.RETURN).charCodeAt(0)); 569 tokens.add(TokenKind.kindToString(TokenKind.RETURN).codeUnitAt(0));
570 tokens.add(TokenKind.kindToString(TokenKind.PERCENT).charCodeAt(0)); 570 tokens.add(TokenKind.kindToString(TokenKind.PERCENT).codeUnitAt(0));
571 tokens.add(TokenKind.kindToString(TokenKind.SINGLE_QUOTE).charCodeAt(0)); 571 tokens.add(TokenKind.kindToString(TokenKind.SINGLE_QUOTE).codeUnitAt(0));
572 tokens.add(TokenKind.kindToString(TokenKind.DOUBLE_QUOTE).charCodeAt(0)); 572 tokens.add(TokenKind.kindToString(TokenKind.DOUBLE_QUOTE).codeUnitAt(0));
573 tokens.add(TokenKind.kindToString(TokenKind.SLASH).charCodeAt(0)); 573 tokens.add(TokenKind.kindToString(TokenKind.SLASH).codeUnitAt(0));
574 tokens.add(TokenKind.kindToString(TokenKind.EQUALS).charCodeAt(0)); 574 tokens.add(TokenKind.kindToString(TokenKind.EQUALS).codeUnitAt(0));
575 tokens.add(TokenKind.kindToString(TokenKind.OR).charCodeAt(0)); 575 tokens.add(TokenKind.kindToString(TokenKind.OR).codeUnitAt(0));
576 tokens.add(TokenKind.kindToString(TokenKind.CARET).charCodeAt(0)); 576 tokens.add(TokenKind.kindToString(TokenKind.CARET).codeUnitAt(0));
577 tokens.add(TokenKind.kindToString(TokenKind.DOLLAR).charCodeAt(0)); 577 tokens.add(TokenKind.kindToString(TokenKind.DOLLAR).codeUnitAt(0));
578 tokens.add(TokenKind.kindToString(TokenKind.LESS).charCodeAt(0)); 578 tokens.add(TokenKind.kindToString(TokenKind.LESS).codeUnitAt(0));
579 tokens.add(TokenKind.kindToString(TokenKind.BANG).charCodeAt(0)); 579 tokens.add(TokenKind.kindToString(TokenKind.BANG).codeUnitAt(0));
580 tokens.add(TokenKind.kindToString(TokenKind.MINUS).charCodeAt(0)); 580 tokens.add(TokenKind.kindToString(TokenKind.MINUS).codeUnitAt(0));
581 581
582 assert(tokens.length == TokenKind.END_TOKENS); 582 assert(tokens.length == TokenKind.END_TOKENS);
583 } 583 }
584 584
585 static bool isIdentifier(int kind) { 585 static bool isIdentifier(int kind) {
586 return kind == IDENTIFIER ; 586 return kind == IDENTIFIER ;
587 } 587 }
588 588
589 } 589 }
590 590
591 class NoColorMatchException implements Exception { 591 class NoColorMatchException implements Exception {
592 String _colorName; 592 String _colorName;
593 NoColorMatchException(this._colorName); 593 NoColorMatchException(this._colorName);
594 594
595 String get name => _colorName; 595 String get name => _colorName;
596 } 596 }
OLDNEW
« no previous file with comments | « utils/css/tokenizer_base.dart ('k') | utils/peg/pegparser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698