OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 |
| 5 import 'src/token.dart' show |
| 6 Token; |
| 7 |
| 8 import 'src/utf8_bytes_scanner.dart' show |
| 9 Utf8BytesScanner; |
| 10 |
| 11 abstract class Scanner { |
| 12 List<int> get lineStarts; |
| 13 Token tokenize(); |
| 14 } |
| 15 |
| 16 class ScannerResult { |
| 17 final Token tokens; |
| 18 final List<int> lineStarts; |
| 19 |
| 20 ScannerResult(this.tokens, this.lineStarts); |
| 21 } |
| 22 |
| 23 ScannerResult scan(List<int> bytes, {bool includeComments: false}) { |
| 24 if (bytes.last != 0) { |
| 25 throw new ArgumentError("[bytes]: the last byte must be null."); |
| 26 } |
| 27 Scanner scanner = |
| 28 new Utf8BytesScanner(bytes, includeComments: includeComments); |
| 29 return new ScannerResult(scanner.tokenize(), scanner.lineStarts); |
| 30 } |
OLD | NEW |