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

Side by Side Diff: lib/compiler/implementation/scanner/scanner.dart

Issue 10920066: issue 4817 fixed. Implemented raw strings with 'r' instead of '@' for dart2js (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased, weird problem with patch in string_interpolation_test.dart hopefully fixed Created 8 years, 3 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
OLDNEW
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 interface Scanner { 5 interface Scanner {
6 Token tokenize(); 6 Token tokenize();
7 } 7 }
8 8
9 /** 9 /**
10 * Common base class for a Dart scanner. 10 * Common base class for a Dart scanner.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 return firstToken(); 99 return firstToken();
100 } 100 }
101 101
102 int bigSwitch(int next) { 102 int bigSwitch(int next) {
103 beginToken(); 103 beginToken();
104 if (next === $TAB || next === $LF || next === $CR || next === $SPACE) { 104 if (next === $TAB || next === $LF || next === $CR || next === $SPACE) {
105 appendWhiteSpace(next); 105 appendWhiteSpace(next);
106 return advance(); 106 return advance();
107 } 107 }
108 108
109 if ($r === next) {
110 return tokenizeRawStringKeywordOrIdentifier(next, true);
111 }
112
109 if ($a <= next && next <= $z) { 113 if ($a <= next && next <= $z) {
110 return tokenizeKeywordOrIdentifier(next, true); 114 return tokenizeKeywordOrIdentifier(next, true);
111 } 115 }
112 116
113 if (($A <= next && next <= $Z) || next === $_ || next === $$) { 117 if (($A <= next && next <= $Z) || next === $_ || next === $$) {
114 return tokenizeIdentifier(next, byteOffset, true); 118 return tokenizeIdentifier(next, byteOffset, true);
115 } 119 }
116 120
117 if (next === $LT) { 121 if (next === $LT) {
118 return tokenizeLessThan(next); 122 return tokenizeLessThan(next);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 227
224 if (next === $CLOSE_CURLY_BRACKET) { 228 if (next === $CLOSE_CURLY_BRACKET) {
225 return appendEndGroup(CLOSE_CURLY_BRACKET_INFO, "}", 229 return appendEndGroup(CLOSE_CURLY_BRACKET_INFO, "}",
226 OPEN_CURLY_BRACKET_TOKEN); 230 OPEN_CURLY_BRACKET_TOKEN);
227 } 231 }
228 232
229 if (next === $SLASH) { 233 if (next === $SLASH) {
230 return tokenizeSlashOrComment(next); 234 return tokenizeSlashOrComment(next);
231 } 235 }
232 236
237 // TODO(aprelev@gmail.com) Remove deprecated raw string literals
233 if (next === $AT) { 238 if (next === $AT) {
234 return tokenizeAtOrRawString(next); 239 return tokenizeAtOrRawString(next);
235 } 240 }
236 241
237 if (next === $DQ || next === $SQ) { 242 if (next === $DQ || next === $SQ) {
238 return tokenizeString(next, byteOffset, false); 243 return tokenizeString(next, byteOffset, false);
239 } 244 }
240 245
241 if (next === $PERIOD) { 246 if (next === $PERIOD) {
242 return tokenizeDotsOrNumber(next); 247 return tokenizeDotsOrNumber(next);
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 if ($STAR === next) { 618 if ($STAR === next) {
614 next = advance(); 619 next = advance();
615 ++nesting; 620 ++nesting;
616 } 621 }
617 } else { 622 } else {
618 next = advance(); 623 next = advance();
619 } 624 }
620 } 625 }
621 } 626 }
622 627
628 int tokenizeRawStringKeywordOrIdentifier(int next, bool allowDollar) {
ahe 2012/09/11 06:04:34 allowDollar is always true. The parameter is not n
aam-me 2012/09/12 02:12:38 Done.
629 int nextnext = peek();
630 if (nextnext === $DQ || nextnext === $SQ) {
631 int start = byteOffset;
632 next = advance();
633 return tokenizeString(next, start, true);
634 }
635 return tokenizeKeywordOrIdentifier(next, allowDollar);
636 }
637
623 int tokenizeKeywordOrIdentifier(int next, bool allowDollar) { 638 int tokenizeKeywordOrIdentifier(int next, bool allowDollar) {
624 KeywordState state = KeywordState.KEYWORD_STATE; 639 KeywordState state = KeywordState.KEYWORD_STATE;
625 int start = byteOffset; 640 int start = byteOffset;
626 while (state !== null && $a <= next && next <= $z) { 641 while (state !== null && $a <= next && next <= $z) {
627 state = state.next(next); 642 state = state.next(next);
628 next = advance(); 643 next = advance();
629 } 644 }
630 if (state === null || state.keyword === null) { 645 if (state === null || state.keyword === null) {
631 return tokenizeIdentifier(next, start, allowDollar); 646 return tokenizeIdentifier(next, start, allowDollar);
632 } 647 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 charOffset); 842 charOffset);
828 } 843 }
829 } 844 }
830 845
831 class MalformedInputException { 846 class MalformedInputException {
832 final String message; 847 final String message;
833 final position; 848 final position;
834 MalformedInputException(this.message, this.position); 849 MalformedInputException(this.message, this.position);
835 toString() => message; 850 toString() => message;
836 } 851 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/string_validator.dart » ('j') | lib/compiler/implementation/string_validator.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698