| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 analyzer.src.dart.scanner.scanner; | 5 library analyzer.src.dart.scanner.scanner; |
| 6 | 6 |
| 7 import 'package:analyzer/error/error.dart'; | 7 import 'package:analyzer/error/error.dart'; |
| 8 import 'package:analyzer/error/listener.dart'; | 8 import 'package:analyzer/error/listener.dart'; |
| 9 import 'package:analyzer/src/dart/error/syntactic_errors.dart'; | 9 import 'package:analyzer/src/dart/error/syntactic_errors.dart'; |
| 10 import 'package:analyzer/src/dart/scanner/reader.dart'; | 10 import 'package:analyzer/src/dart/scanner/reader.dart'; |
| 11 import 'package:analyzer/src/generated/source.dart'; | 11 import 'package:analyzer/src/generated/source.dart'; |
| 12 import 'package:front_end/src/fasta/scanner.dart' as fasta; | 12 import 'package:front_end/src/fasta/scanner.dart' as fasta; |
| 13 import 'package:front_end/src/fasta/scanner/precedence.dart' as fasta; | |
| 14 import 'package:front_end/src/scanner/errors.dart' show translateErrorToken; | 13 import 'package:front_end/src/scanner/errors.dart' show translateErrorToken; |
| 15 import 'package:front_end/src/scanner/scanner.dart' as fe; | 14 import 'package:front_end/src/scanner/scanner.dart' as fe; |
| 16 import 'package:front_end/src/scanner/token.dart' show Token; | 15 import 'package:front_end/src/scanner/token.dart' show Token, TokenType; |
| 17 | 16 |
| 18 export 'package:analyzer/src/dart/error/syntactic_errors.dart'; | 17 export 'package:analyzer/src/dart/error/syntactic_errors.dart'; |
| 19 export 'package:front_end/src/scanner/scanner.dart' show KeywordState; | 18 export 'package:front_end/src/scanner/scanner.dart' show KeywordState; |
| 20 | 19 |
| 21 /** | 20 /** |
| 22 * The class `Scanner` implements a scanner for Dart code. | 21 * The class `Scanner` implements a scanner for Dart code. |
| 23 * | 22 * |
| 24 * The lexical structure of Dart is ambiguous without knowledge of the context | 23 * The lexical structure of Dart is ambiguous without knowledge of the context |
| 25 * in which a token is being scanned. For example, without context we cannot | 24 * in which a token is being scanned. For example, without context we cannot |
| 26 * determine whether source of the form "<<" should be scanned as a single | 25 * determine whether source of the form "<<" should be scanned as a single |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 throw 'No generic method comment support in Fasta'; | 148 throw 'No generic method comment support in Fasta'; |
| 150 } | 149 } |
| 151 fasta.ScannerResult result = | 150 fasta.ScannerResult result = |
| 152 fasta.scanString(_contents, includeComments: _preserveComments); | 151 fasta.scanString(_contents, includeComments: _preserveComments); |
| 153 // fasta pretends there is an additional line at EOF | 152 // fasta pretends there is an additional line at EOF |
| 154 lineStarts | 153 lineStarts |
| 155 .addAll(result.lineStarts.sublist(1, result.lineStarts.length - 1)); | 154 .addAll(result.lineStarts.sublist(1, result.lineStarts.length - 1)); |
| 156 fasta.Token token = result.tokens; | 155 fasta.Token token = result.tokens; |
| 157 // The default recovery strategy used by scanString | 156 // The default recovery strategy used by scanString |
| 158 // places all error tokens at the head of the stream. | 157 // places all error tokens at the head of the stream. |
| 159 while (token.info == fasta.BAD_INPUT_INFO) { | 158 while (token.info == TokenType.BAD_INPUT) { |
| 160 translateErrorToken(token, reportError); | 159 translateErrorToken(token, reportError); |
| 161 token = token.next; | 160 token = token.next; |
| 162 } | 161 } |
| 163 firstToken = token; | 162 firstToken = token; |
| 164 return firstToken; | 163 return firstToken; |
| 165 } | 164 } |
| 166 | 165 |
| 167 @override | 166 @override |
| 168 set preserveComments(bool preserveComments) { | 167 set preserveComments(bool preserveComments) { |
| 169 this._preserveComments = preserveComments; | 168 this._preserveComments = preserveComments; |
| 170 } | 169 } |
| 171 } | 170 } |
| OLD | NEW |