| Index: pkg/dart_scanner/lib/src/array_based_scanner.dart
|
| diff --git a/pkg/dart_scanner/lib/src/array_based_scanner.dart b/pkg/dart_scanner/lib/src/array_based_scanner.dart
|
| index edd22ae279658d8277245871db5f1d8b6da066c0..e8120069e874c003222eef80ce14168624c6bdf8 100644
|
| --- a/pkg/dart_scanner/lib/src/array_based_scanner.dart
|
| +++ b/pkg/dart_scanner/lib/src/array_based_scanner.dart
|
| @@ -2,24 +2,41 @@
|
| // 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.array_based;
|
| -
|
| -import '../io/source_file.dart' show SourceFile;
|
| -import '../tokens/keyword.dart' show Keyword;
|
| -import '../tokens/precedence.dart' show PrecedenceInfo;
|
| -import '../tokens/precedence_constants.dart' as Precedence
|
| - show COMMENT_INFO, EOF_INFO;
|
| -import '../tokens/token.dart'
|
| - show BeginGroupToken, ErrorToken, KeywordToken, SymbolToken, Token;
|
| -import '../tokens/token_constants.dart' as Tokens
|
| - show LT_TOKEN, OPEN_CURLY_BRACKET_TOKEN, STRING_INTERPOLATION_TOKEN;
|
| -import '../util/characters.dart' show $LF, $STX;
|
| -import '../util/util.dart' show Link;
|
| -import 'scanner.dart' show AbstractScanner;
|
| +library scanner.array_based_scanner;
|
| +
|
| +import 'keyword.dart' show
|
| + Keyword;
|
| +
|
| +import 'precedence.dart' show
|
| + COMMENT_INFO,
|
| + EOF_INFO,
|
| + PrecedenceInfo;
|
| +
|
| +import 'token.dart' show
|
| + BeginGroupToken,
|
| + ErrorToken,
|
| + KeywordToken,
|
| + SymbolToken,
|
| + Token;
|
| +
|
| +import 'token_constants.dart' show
|
| + LT_TOKEN,
|
| + OPEN_CURLY_BRACKET_TOKEN,
|
| + STRING_INTERPOLATION_TOKEN;
|
| +
|
| +import 'characters.dart' show
|
| + $LF,
|
| + $STX;
|
| +
|
| +import 'abstract_scanner.dart' show
|
| + AbstractScanner;
|
| +
|
| +import 'package:link/link.dart' show
|
| + Link;
|
|
|
| abstract class ArrayBasedScanner extends AbstractScanner {
|
| - ArrayBasedScanner(SourceFile file, bool includeComments)
|
| - : super(file, includeComments);
|
| + ArrayBasedScanner(bool includeComments)
|
| + : super(includeComments);
|
|
|
| /**
|
| * The stack of open groups, e.g [: { ... ( .. :]
|
| @@ -77,7 +94,7 @@ abstract class ArrayBasedScanner extends AbstractScanner {
|
| unmatchedBeginGroup(groupingStack.head);
|
| groupingStack = groupingStack.tail;
|
| }
|
| - tail.next = new SymbolToken(Precedence.EOF_INFO, tokenStart);
|
| + tail.next = new SymbolToken(EOF_INFO, tokenStart);
|
| tail = tail.next;
|
| // EOF points to itself so there's always infinite look-ahead.
|
| tail.next = tail;
|
| @@ -91,7 +108,7 @@ abstract class ArrayBasedScanner extends AbstractScanner {
|
| * [lineStarts] map.
|
| */
|
| void appendWhiteSpace(int next) {
|
| - if (next == $LF && file != null) {
|
| + if (next == $LF) {
|
| lineStarts.add(stringOffset + 1); // +1, the line starts after the $LF.
|
| }
|
| }
|
| @@ -103,9 +120,7 @@ abstract class ArrayBasedScanner extends AbstractScanner {
|
| * [lineStarts] map.
|
| */
|
| void lineFeedInMultiline() {
|
| - if (file != null) {
|
| - lineStarts.add(stringOffset + 1);
|
| - }
|
| + lineStarts.add(stringOffset + 1);
|
| }
|
|
|
| /**
|
| @@ -118,7 +133,7 @@ abstract class ArrayBasedScanner extends AbstractScanner {
|
| tail = tail.next;
|
|
|
| // { ( [ ${ cannot appear inside a type parameters / arguments.
|
| - if (!identical(info.kind, Tokens.LT_TOKEN)) discardOpenLt();
|
| + if (!identical(info.kind, LT_TOKEN)) discardOpenLt();
|
| groupingStack = groupingStack.prepend(token);
|
| }
|
|
|
| @@ -128,7 +143,7 @@ abstract class ArrayBasedScanner extends AbstractScanner {
|
| * '>>' are handled separately bo [appendGt] and [appendGtGt].
|
| */
|
| int appendEndGroup(PrecedenceInfo info, int openKind) {
|
| - assert(!identical(openKind, Tokens.LT_TOKEN)); // openKind is < for > and >>
|
| + assert(!identical(openKind, LT_TOKEN)); // openKind is < for > and >>
|
| discardBeginGroupUntil(openKind);
|
| appendPrecedenceToken(info);
|
| Token close = tail;
|
| @@ -137,8 +152,8 @@ abstract class ArrayBasedScanner extends AbstractScanner {
|
| }
|
| BeginGroupToken begin = groupingStack.head;
|
| if (!identical(begin.kind, openKind)) {
|
| - assert(begin.kind == Tokens.STRING_INTERPOLATION_TOKEN &&
|
| - openKind == Tokens.OPEN_CURLY_BRACKET_TOKEN);
|
| + assert(begin.kind == STRING_INTERPOLATION_TOKEN &&
|
| + openKind == OPEN_CURLY_BRACKET_TOKEN);
|
| // We're ending an interpolated expression.
|
| begin.endGroup = close;
|
| groupingStack = groupingStack.tail;
|
| @@ -162,8 +177,8 @@ abstract class ArrayBasedScanner extends AbstractScanner {
|
| if (groupingStack.isEmpty) return;
|
| BeginGroupToken begin = groupingStack.head;
|
| if (openKind == begin.kind) return;
|
| - if (openKind == Tokens.OPEN_CURLY_BRACKET_TOKEN &&
|
| - begin.kind == Tokens.STRING_INTERPOLATION_TOKEN) return;
|
| + if (openKind == OPEN_CURLY_BRACKET_TOKEN &&
|
| + begin.kind == STRING_INTERPOLATION_TOKEN) return;
|
| unmatchedBeginGroup(begin);
|
| groupingStack = groupingStack.tail;
|
| }
|
| @@ -177,7 +192,7 @@ abstract class ArrayBasedScanner extends AbstractScanner {
|
| void appendGt(PrecedenceInfo info) {
|
| appendPrecedenceToken(info);
|
| if (groupingStack.isEmpty) return;
|
| - if (identical(groupingStack.head.kind, Tokens.LT_TOKEN)) {
|
| + if (identical(groupingStack.head.kind, LT_TOKEN)) {
|
| groupingStack.head.endGroup = tail;
|
| groupingStack = groupingStack.tail;
|
| }
|
| @@ -191,13 +206,13 @@ abstract class ArrayBasedScanner extends AbstractScanner {
|
| void appendGtGt(PrecedenceInfo info) {
|
| appendPrecedenceToken(info);
|
| if (groupingStack.isEmpty) return;
|
| - if (identical(groupingStack.head.kind, Tokens.LT_TOKEN)) {
|
| + if (identical(groupingStack.head.kind, LT_TOKEN)) {
|
| // Don't assign endGroup: in "T<U<V>>", the '>>' token closes the outer
|
| // '<', the inner '<' is left without endGroup.
|
| groupingStack = groupingStack.tail;
|
| }
|
| if (groupingStack.isEmpty) return;
|
| - if (identical(groupingStack.head.kind, Tokens.LT_TOKEN)) {
|
| + if (identical(groupingStack.head.kind, LT_TOKEN)) {
|
| groupingStack.head.endGroup = tail;
|
| groupingStack = groupingStack.tail;
|
| }
|
| @@ -205,7 +220,7 @@ abstract class ArrayBasedScanner extends AbstractScanner {
|
|
|
| void appendComment(start, bool asciiOnly) {
|
| if (!includeComments) return;
|
| - appendSubstringToken(Precedence.COMMENT_INFO, start, asciiOnly);
|
| + appendSubstringToken(COMMENT_INFO, start, asciiOnly);
|
| }
|
|
|
| void appendErrorToken(ErrorToken token) {
|
| @@ -226,7 +241,7 @@ abstract class ArrayBasedScanner extends AbstractScanner {
|
| */
|
| void discardOpenLt() {
|
| while (!groupingStack.isEmpty &&
|
| - identical(groupingStack.head.kind, Tokens.LT_TOKEN)) {
|
| + identical(groupingStack.head.kind, LT_TOKEN)) {
|
| groupingStack = groupingStack.tail;
|
| }
|
| }
|
|
|