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

Unified Diff: pkg/dart_scanner/lib/src/abstract_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/src/abstract_scanner.dart
diff --git a/pkg/dart_scanner/lib/src/abstract_scanner.dart b/pkg/dart_scanner/lib/src/abstract_scanner.dart
index f0698611482b302293d982b6bccd4f5b91af214a..7d5dc1605d79409b3a8edfe6aeb6d9cc100d6486 100644
--- a/pkg/dart_scanner/lib/src/abstract_scanner.dart
+++ b/pkg/dart_scanner/lib/src/abstract_scanner.dart
@@ -2,29 +2,30 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-library dart2js.scanner;
-
-import '../io/source_file.dart' show SourceFile, Utf8BytesSourceFile;
-import '../tokens/keyword.dart' show Keyword, KeywordState;
-import '../tokens/precedence.dart';
-import '../tokens/precedence_constants.dart';
-import '../tokens/token.dart';
-import '../tokens/token_constants.dart';
-import '../util/characters.dart';
-import 'string_scanner.dart' show StringScanner;
-import 'utf8_bytes_scanner.dart' show Utf8BytesScanner;
-
-abstract class Scanner {
- Token tokenize();
-
- factory Scanner(SourceFile file, {bool includeComments: false}) {
- if (file is Utf8BytesSourceFile) {
- return new Utf8BytesScanner(file, includeComments: includeComments);
- } else {
- return new StringScanner(file, includeComments: includeComments);
- }
- }
-}
+library scanner.abstract_scanner;
+
+import '../scanner.dart' show
+ Scanner;
+
+import 'keyword.dart' show
+ KeywordState,
+ Keyword;
+
+import 'precedence.dart';
+
+import 'token.dart' show
+ BadInputToken,
+ BeginGroupToken,
+ ErrorToken,
+ KeywordToken,
+ SymbolToken,
+ Token,
+ UnmatchedToken,
+ UnterminatedToken;
+
+import 'token_constants.dart';
+
+import 'characters.dart';
abstract class AbstractScanner implements Scanner {
// TODO(ahe): Move this class to implementation.
@@ -54,16 +55,9 @@ abstract class AbstractScanner implements Scanner {
*/
Token tail;
- /**
- * The source file that is being scanned. This field can be [:null:].
- * If the source file is available, the scanner assigns its [:lineStarts:] and
- * [:length:] fields at the end of [tokenize].
- */
- final SourceFile file;
-
final List<int> lineStarts = <int>[0];
- AbstractScanner(this.file, this.includeComments) {
+ AbstractScanner(this.includeComments) {
this.tail = this.tokens;
}
@@ -214,12 +208,8 @@ abstract class AbstractScanner implements Scanner {
}
}
- if (file != null) {
- file.length = stringOffset;
- // One additional line start at the end, see [SourceFile.lineStarts].
- lineStarts.add(stringOffset + 1);
- file.lineStarts = lineStarts;
- }
+ // Always pretend that there's a line at the end of the file.
+ lineStarts.add(stringOffset + 1);
return firstToken();
}
@@ -635,7 +625,6 @@ abstract class AbstractScanner implements Scanner {
return next;
}
}
- return null;
}
int tokenizeHexOrNumber(int next) {
@@ -665,7 +654,6 @@ abstract class AbstractScanner implements Scanner {
return next;
}
}
- return null;
}
int tokenizeDotsOrNumber(int next) {
@@ -761,7 +749,6 @@ abstract class AbstractScanner implements Scanner {
return next;
}
}
- return null;
}
int tokenizeMultiLineComment(int next, int start) {

Powered by Google App Engine
This is Rietveld 408576698