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

Side by Side Diff: pkg/dart_scanner/lib/scanner.dart

Issue 2631503002: Modify scanner and parser to be standalone packages. (Closed)
Patch Set: Created 3 years, 11 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
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698