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

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

Issue 10539021: Scanner can include comments in the token stream. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: String interpolation identifier used new token Created 8 years, 6 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) 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 /** 5 /**
6 * Scanner that reads from a String and creates tokens that points to 6 * Scanner that reads from a String and creates tokens that points to
7 * substrings. 7 * substrings.
8 */ 8 */
9 class StringScanner extends ArrayBasedScanner<SourceString> { 9 class StringScanner extends ArrayBasedScanner<SourceString> {
10 final String string; 10 final String string;
11 11
12 StringScanner(String this.string) : super(); 12 StringScanner(String this.string, [bool includeComments = false])
13 : super(includeComments);
13 14
14 int nextByte() => charAt(++byteOffset); 15 int nextByte() => charAt(++byteOffset);
15 16
16 int peek() => charAt(byteOffset + 1); 17 int peek() => charAt(byteOffset + 1);
17 18
18 int charAt(index) 19 int charAt(index)
19 => (string.length > index) ? string.charCodeAt(index) : $EOF; 20 => (string.length > index) ? string.charCodeAt(index) : $EOF;
20 21
21 SourceString asciiString(int start, int offset) { 22 SourceString asciiString(int start, int offset) {
22 return new SubstringWrapper(string, start, byteOffset + offset); 23 return new SubstringWrapper(string, start, byteOffset + offset);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 assert(0 <= terminal); 66 assert(0 <= terminal);
66 assert(initial + terminal <= internalString.length); 67 assert(initial + terminal <= internalString.length);
67 return new SubstringWrapper(internalString, 68 return new SubstringWrapper(internalString,
68 begin + initial, end - terminal); 69 begin + initial, end - terminal);
69 } 70 }
70 71
71 bool isEmpty() => begin == end; 72 bool isEmpty() => begin == end;
72 73
73 bool isPrivate() => !isEmpty() && internalString.charCodeAt(begin) === $_; 74 bool isPrivate() => !isEmpty() && internalString.charCodeAt(begin) === $_;
74 } 75 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698