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

Side by Side Diff: pkg/front_end/lib/src/fasta/scanner/string_scanner.dart

Issue 2903063003: update lazy assignment operators (Closed)
Patch Set: Created 3 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
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 library dart2js.scanner.string_scanner; 5 library dart2js.scanner.string_scanner;
6 6
7 import '../../scanner/token.dart' show TokenType; 7 import '../../scanner/token.dart' show TokenType;
8 8
9 import 'array_based_scanner.dart' show ArrayBasedScanner; 9 import 'array_based_scanner.dart' show ArrayBasedScanner;
10 10
11 import 'token.dart' show CommentToken, DartDocToken, StringToken; 11 import 'token.dart' show CommentToken, DartDocToken, StringToken;
12 12
13 /** 13 /**
14 * Scanner that reads from a String and creates tokens that points to 14 * Scanner that reads from a String and creates tokens that points to
15 * substrings. 15 * substrings.
16 */ 16 */
17 class StringScanner extends ArrayBasedScanner { 17 class StringScanner extends ArrayBasedScanner {
18 /** The file content. */ 18 /** The file content. */
19 String string; 19 String string;
20 20
21 /** The current offset in [string]. */ 21 /** The current offset in [string]. */
22 int scanOffset = -1; 22 int scanOffset = -1;
23 23
24 StringScanner(String string, 24 StringScanner(String string,
25 {bool includeComments: false, 25 {bool includeComments: false,
26 bool scanGenericMethodComments: false, 26 bool scanGenericMethodComments: false,
27 bool scanLazyAssignmentOperators: false}) 27 bool scanLazyAssignmentOperators: false})
28 : string = ensureZeroTermination(string), 28 : string = ensureZeroTermination(string),
29 super(includeComments, scanGenericMethodComments, 29 super(includeComments, scanGenericMethodComments);
30 scanLazyAssignmentOperators);
31 30
32 static String ensureZeroTermination(String string) { 31 static String ensureZeroTermination(String string) {
33 return (string.isEmpty || string.codeUnitAt(string.length - 1) != 0) 32 return (string.isEmpty || string.codeUnitAt(string.length - 1) != 0)
34 // TODO(lry): abort instead of copying the array, or warn? 33 // TODO(lry): abort instead of copying the array, or warn?
35 ? string + '\x00' 34 ? string + '\x00'
36 : string; 35 : string;
37 } 36 }
38 37
39 int advance() => string.codeUnitAt(++scanOffset); 38 int advance() => string.codeUnitAt(++scanOffset);
40 int peek() => string.codeUnitAt(scanOffset + 1); 39 int peek() => string.codeUnitAt(scanOffset + 1);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 80
82 SubStringScanner(this.baseOffset, String string, 81 SubStringScanner(this.baseOffset, String string,
83 {bool includeComments: false}) 82 {bool includeComments: false})
84 : super(string, includeComments: includeComments); 83 : super(string, includeComments: includeComments);
85 84
86 @override 85 @override
87 void beginToken() { 86 void beginToken() {
88 tokenStart = baseOffset + stringOffset; 87 tokenStart = baseOffset + stringOffset;
89 } 88 }
90 } 89 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/scanner/array_based_scanner.dart ('k') | pkg/front_end/lib/src/fasta/scanner/token_constants.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698