OLD | NEW |
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 fasta.scanner.array_based_scanner; | 5 library fasta.scanner.array_based_scanner; |
6 | 6 |
7 import 'error_token.dart' show ErrorToken; | 7 import 'error_token.dart' show ErrorToken; |
8 | 8 |
9 import 'keyword.dart' show Keyword; | 9 import 'keyword.dart' show Keyword; |
10 | 10 |
11 import 'precedence.dart' show COMMENT_INFO, EOF_INFO, PrecedenceInfo; | 11 import 'precedence.dart' show COMMENT_INFO, EOF_INFO, PrecedenceInfo; |
12 | 12 |
13 import 'token.dart' | 13 import 'token.dart' |
14 show BeginGroupToken, KeywordToken, StringToken, SymbolToken, Token; | 14 show BeginGroupToken, KeywordToken, StringToken, SymbolToken, Token; |
15 | 15 |
16 import 'token_constants.dart' | 16 import 'token_constants.dart' |
17 show LT_TOKEN, OPEN_CURLY_BRACKET_TOKEN, STRING_INTERPOLATION_TOKEN; | 17 show |
| 18 LT_TOKEN, |
| 19 OPEN_CURLY_BRACKET_TOKEN, |
| 20 OPEN_PAREN_TOKEN, |
| 21 STRING_INTERPOLATION_TOKEN; |
18 | 22 |
19 import 'characters.dart' show $LF, $STX; | 23 import 'characters.dart' show $LF, $STX; |
20 | 24 |
21 import 'abstract_scanner.dart' show AbstractScanner; | 25 import 'abstract_scanner.dart' show AbstractScanner; |
22 | 26 |
23 import '../util/link.dart' show Link; | 27 import '../util/link.dart' show Link; |
24 | 28 |
25 abstract class ArrayBasedScanner extends AbstractScanner { | 29 abstract class ArrayBasedScanner extends AbstractScanner { |
26 bool hasErrors = false; | 30 bool hasErrors = false; |
27 | 31 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 } | 129 } |
126 | 130 |
127 /** | 131 /** |
128 * Appends a token that begins a new group, represented by [info]. | 132 * Appends a token that begins a new group, represented by [info]. |
129 * Group begin tokens are '{', '(', '[' and '${'. | 133 * Group begin tokens are '{', '(', '[' and '${'. |
130 */ | 134 */ |
131 void appendBeginGroup(PrecedenceInfo info) { | 135 void appendBeginGroup(PrecedenceInfo info) { |
132 Token token = new BeginGroupToken(info, tokenStart); | 136 Token token = new BeginGroupToken(info, tokenStart); |
133 appendToken(token); | 137 appendToken(token); |
134 | 138 |
135 // { ( [ ${ cannot appear inside a type parameters / arguments. | 139 // { [ ${ cannot appear inside a type parameters / arguments. |
136 if (!identical(info.kind, LT_TOKEN)) discardOpenLt(); | 140 if (!identical(info.kind, LT_TOKEN) && |
| 141 !identical(info.kind, OPEN_PAREN_TOKEN)) { |
| 142 discardOpenLt(); |
| 143 } |
137 groupingStack = groupingStack.prepend(token); | 144 groupingStack = groupingStack.prepend(token); |
138 } | 145 } |
139 | 146 |
140 /** | 147 /** |
141 * Appends a token that begins an end group, represented by [info]. | 148 * Appends a token that begins an end group, represented by [info]. |
142 * It handles the group end tokens '}', ')' and ']'. The tokens '>' and | 149 * It handles the group end tokens '}', ')' and ']'. The tokens '>' and |
143 * '>>' are handled separately bo [appendGt] and [appendGtGt]. | 150 * '>>' are handled separately bo [appendGt] and [appendGtGt]. |
144 */ | 151 */ |
145 int appendEndGroup(PrecedenceInfo info, int openKind) { | 152 int appendEndGroup(PrecedenceInfo info, int openKind) { |
146 assert(!identical(openKind, LT_TOKEN)); // openKind is < for > and >> | 153 assert(!identical(openKind, LT_TOKEN)); // openKind is < for > and >> |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 * something which cannot possibly be part of a type parameter/argument | 272 * something which cannot possibly be part of a type parameter/argument |
266 * list, like the '=' in the above example. | 273 * list, like the '=' in the above example. |
267 */ | 274 */ |
268 void discardOpenLt() { | 275 void discardOpenLt() { |
269 while (!groupingStack.isEmpty && | 276 while (!groupingStack.isEmpty && |
270 identical(groupingStack.head.kind, LT_TOKEN)) { | 277 identical(groupingStack.head.kind, LT_TOKEN)) { |
271 groupingStack = groupingStack.tail; | 278 groupingStack = groupingStack.tail; |
272 } | 279 } |
273 } | 280 } |
274 } | 281 } |
OLD | NEW |