OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 library fasta.scanner; | 5 library fasta.scanner; |
6 | 6 |
7 import 'dart:convert' show UNICODE_REPLACEMENT_CHARACTER_RUNE, UTF8; | 7 import 'dart:convert' show UNICODE_REPLACEMENT_CHARACTER_RUNE, UTF8; |
8 | 8 |
9 import '../scanner/token.dart' show Token; | 9 import '../scanner/token.dart' show Token; |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 includeComments: includeComments, | 70 includeComments: includeComments, |
71 scanGenericMethodComments: scanGenericMethodComments); | 71 scanGenericMethodComments: scanGenericMethodComments); |
72 return _tokenizeAndRecover(scanner, recover, bytes: bytes); | 72 return _tokenizeAndRecover(scanner, recover, bytes: bytes); |
73 } | 73 } |
74 | 74 |
75 /// Scan/tokenize the given [source]. | 75 /// Scan/tokenize the given [source]. |
76 /// If [recover] is null, then the [defaultRecoveryStrategy] is used. | 76 /// If [recover] is null, then the [defaultRecoveryStrategy] is used. |
77 ScannerResult scanString(String source, | 77 ScannerResult scanString(String source, |
78 {bool includeComments: false, | 78 {bool includeComments: false, |
79 bool scanGenericMethodComments: false, | 79 bool scanGenericMethodComments: false, |
| 80 bool scanLazyAssignmentOperators: false, |
80 Recover recover}) { | 81 Recover recover}) { |
81 assert(source != null, 'source must not be null'); | 82 assert(source != null, 'source must not be null'); |
82 StringScanner scanner = new StringScanner(source, | 83 StringScanner scanner = new StringScanner(source, |
83 includeComments: includeComments, | 84 includeComments: includeComments, |
84 scanGenericMethodComments: scanGenericMethodComments); | 85 scanGenericMethodComments: scanGenericMethodComments, |
| 86 scanLazyAssignmentOperators: scanLazyAssignmentOperators); |
85 return _tokenizeAndRecover(scanner, recover, source: source); | 87 return _tokenizeAndRecover(scanner, recover, source: source); |
86 } | 88 } |
87 | 89 |
88 ScannerResult _tokenizeAndRecover(Scanner scanner, Recover recover, | 90 ScannerResult _tokenizeAndRecover(Scanner scanner, Recover recover, |
89 {List<int> bytes, String source}) { | 91 {List<int> bytes, String source}) { |
90 Token tokens = scanner.tokenize(); | 92 Token tokens = scanner.tokenize(); |
91 if (scanner.hasErrors) { | 93 if (scanner.hasErrors) { |
92 if (bytes == null) bytes = UTF8.encode(source); | 94 if (bytes == null) bytes = UTF8.encode(source); |
93 recover ??= defaultRecoveryStrategy; | 95 recover ??= defaultRecoveryStrategy; |
94 tokens = recover(bytes, tokens, scanner.lineStarts); | 96 tokens = recover(bytes, tokens, scanner.lineStarts); |
95 } | 97 } |
96 return new ScannerResult(tokens, scanner.lineStarts, scanner.hasErrors); | 98 return new ScannerResult(tokens, scanner.lineStarts, scanner.hasErrors); |
97 } | 99 } |
OLD | NEW |