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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: pkg/dart_scanner/lib/scanner.dart
diff --git a/pkg/dart_scanner/lib/scanner.dart b/pkg/dart_scanner/lib/scanner.dart
new file mode 100644
index 0000000000000000000000000000000000000000..fa6ae41f2ad706986f36254180eac2fa702def55
--- /dev/null
+++ b/pkg/dart_scanner/lib/scanner.dart
@@ -0,0 +1,30 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE.md file.
+
+import 'src/token.dart' show
+ Token;
+
+import 'src/utf8_bytes_scanner.dart' show
+ Utf8BytesScanner;
+
+abstract class Scanner {
+ List<int> get lineStarts;
+ Token tokenize();
+}
+
+class ScannerResult {
+ final Token tokens;
+ final List<int> lineStarts;
+
+ ScannerResult(this.tokens, this.lineStarts);
+}
+
+ScannerResult scan(List<int> bytes, {bool includeComments: false}) {
+ if (bytes.last != 0) {
+ throw new ArgumentError("[bytes]: the last byte must be null.");
+ }
+ Scanner scanner =
+ new Utf8BytesScanner(bytes, includeComments: includeComments);
+ return new ScannerResult(scanner.tokenize(), scanner.lineStarts);
+}

Powered by Google App Engine
This is Rietveld 408576698