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

Side by Side Diff: pkg/compiler/lib/src/scanner/array_based_scanner.dart

Issue 1859343004: dartfmt pkg/compiler (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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 file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart2js.scanner.array_based; 5 library dart2js.scanner.array_based;
6 6
7 import '../io/source_file.dart' show 7 import '../io/source_file.dart' show SourceFile;
8 SourceFile; 8 import '../tokens/keyword.dart' show Keyword;
9 import '../tokens/keyword.dart' show 9 import '../tokens/precedence.dart' show PrecedenceInfo;
10 Keyword; 10 import '../tokens/precedence_constants.dart' as Precedence
11 import '../tokens/precedence.dart' show 11 show COMMENT_INFO, EOF_INFO;
12 PrecedenceInfo; 12 import '../tokens/token.dart'
13 import '../tokens/precedence_constants.dart' as Precedence show 13 show BeginGroupToken, ErrorToken, KeywordToken, SymbolToken, Token;
14 COMMENT_INFO, 14 import '../tokens/token_constants.dart' as Tokens
15 EOF_INFO; 15 show LT_TOKEN, OPEN_CURLY_BRACKET_TOKEN, STRING_INTERPOLATION_TOKEN;
16 import '../tokens/token.dart' show 16 import '../util/characters.dart' show $LF, $STX;
17 BeginGroupToken, 17 import '../util/util.dart' show Link;
18 ErrorToken,
19 KeywordToken,
20 SymbolToken,
21 Token;
22 import '../tokens/token_constants.dart' as Tokens show
23 LT_TOKEN,
24 OPEN_CURLY_BRACKET_TOKEN,
25 STRING_INTERPOLATION_TOKEN;
26 import '../util/characters.dart' show
27 $LF,
28 $STX;
29 import '../util/util.dart' show
30 Link;
31 18
32 import 'scanner.dart' show 19 import 'scanner.dart' show AbstractScanner;
33 AbstractScanner;
34 20
35 abstract class ArrayBasedScanner extends AbstractScanner { 21 abstract class ArrayBasedScanner extends AbstractScanner {
36 ArrayBasedScanner(SourceFile file, bool includeComments) 22 ArrayBasedScanner(SourceFile file, bool includeComments)
37 : super(file, includeComments); 23 : super(file, includeComments);
38 24
39 /** 25 /**
40 * The stack of open groups, e.g [: { ... ( .. :] 26 * The stack of open groups, e.g [: { ... ( .. :]
41 * Each BeginGroupToken has a pointer to the token where the group 27 * Each BeginGroupToken has a pointer to the token where the group
42 * ends. This field is set when scanning the end group token. 28 * ends. This field is set when scanning the end group token.
43 */ 29 */
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 assert(!identical(openKind, Tokens.LT_TOKEN)); // openKind is < for > and >> 132 assert(!identical(openKind, Tokens.LT_TOKEN)); // openKind is < for > and >>
147 discardBeginGroupUntil(openKind); 133 discardBeginGroupUntil(openKind);
148 appendPrecedenceToken(info); 134 appendPrecedenceToken(info);
149 Token close = tail; 135 Token close = tail;
150 if (groupingStack.isEmpty) { 136 if (groupingStack.isEmpty) {
151 return advance(); 137 return advance();
152 } 138 }
153 BeginGroupToken begin = groupingStack.head; 139 BeginGroupToken begin = groupingStack.head;
154 if (!identical(begin.kind, openKind)) { 140 if (!identical(begin.kind, openKind)) {
155 assert(begin.kind == Tokens.STRING_INTERPOLATION_TOKEN && 141 assert(begin.kind == Tokens.STRING_INTERPOLATION_TOKEN &&
156 openKind == Tokens.OPEN_CURLY_BRACKET_TOKEN); 142 openKind == Tokens.OPEN_CURLY_BRACKET_TOKEN);
157 // We're ending an interpolated expression. 143 // We're ending an interpolated expression.
158 begin.endGroup = close; 144 begin.endGroup = close;
159 groupingStack = groupingStack.tail; 145 groupingStack = groupingStack.tail;
160 // Using "start-of-text" to signal that we're back in string 146 // Using "start-of-text" to signal that we're back in string
161 // scanning mode. 147 // scanning mode.
162 return $STX; 148 return $STX;
163 } 149 }
164 begin.endGroup = close; 150 begin.endGroup = close;
165 groupingStack = groupingStack.tail; 151 groupingStack = groupingStack.tail;
166 return advance(); 152 return advance();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 * 219 *
234 * [PartialParser.skipExpression] relies on the fact that we do not 220 * [PartialParser.skipExpression] relies on the fact that we do not
235 * create groups for stuff like: 221 * create groups for stuff like:
236 * [:a = b < c, d = e > f:]. 222 * [:a = b < c, d = e > f:].
237 * 223 *
238 * In other words, this method is called when the scanner recognizes 224 * In other words, this method is called when the scanner recognizes
239 * something which cannot possibly be part of a type parameter/argument 225 * something which cannot possibly be part of a type parameter/argument
240 * list, like the '=' in the above example. 226 * list, like the '=' in the above example.
241 */ 227 */
242 void discardOpenLt() { 228 void discardOpenLt() {
243 while (!groupingStack.isEmpty 229 while (!groupingStack.isEmpty &&
244 && identical(groupingStack.head.kind, Tokens.LT_TOKEN)) { 230 identical(groupingStack.head.kind, Tokens.LT_TOKEN)) {
245 groupingStack = groupingStack.tail; 231 groupingStack = groupingStack.tail;
246 } 232 }
247 } 233 }
248 } 234 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/variables.dart ('k') | pkg/compiler/lib/src/scanner/scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698