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 |
(...skipping 22 matching lines...) Expand all Loading... |
33 * Each BeginGroupToken has a pointer to the token where the group | 33 * Each BeginGroupToken has a pointer to the token where the group |
34 * ends. This field is set when scanning the end group token. | 34 * ends. This field is set when scanning the end group token. |
35 */ | 35 */ |
36 Link<BeginGroupToken> groupingStack = const Link<BeginGroupToken>(); | 36 Link<BeginGroupToken> groupingStack = const Link<BeginGroupToken>(); |
37 | 37 |
38 /** | 38 /** |
39 * Append the given token to the [tail] of the current stream of tokens. | 39 * Append the given token to the [tail] of the current stream of tokens. |
40 */ | 40 */ |
41 void appendToken(Token token) { | 41 void appendToken(Token token) { |
42 tail.next = token; | 42 tail.next = token; |
| 43 tail.next.previousToken = tail; |
43 tail = tail.next; | 44 tail = tail.next; |
44 if (comments != null) { | 45 if (comments != null) { |
45 tail.precedingComments = comments; | 46 tail.precedingComments = comments; |
46 comments = null; | 47 comments = null; |
47 commentsTail = null; | 48 commentsTail = null; |
48 } | 49 } |
49 } | 50 } |
50 | 51 |
51 /** | 52 /** |
52 * Appends a fixed token whose kind and content is determined by [info]. | 53 * Appends a fixed token whose kind and content is determined by [info]. |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 } | 219 } |
219 | 220 |
220 void appendComment(start, bool asciiOnly) { | 221 void appendComment(start, bool asciiOnly) { |
221 if (!includeComments) return; | 222 if (!includeComments) return; |
222 Token newComment = createSubstringToken(COMMENT_INFO, start, asciiOnly); | 223 Token newComment = createSubstringToken(COMMENT_INFO, start, asciiOnly); |
223 if (comments == null) { | 224 if (comments == null) { |
224 comments = newComment; | 225 comments = newComment; |
225 commentsTail = comments; | 226 commentsTail = comments; |
226 } else { | 227 } else { |
227 commentsTail.next = newComment; | 228 commentsTail.next = newComment; |
| 229 commentsTail.next.previousToken = commentsTail; |
228 commentsTail = commentsTail.next; | 230 commentsTail = commentsTail.next; |
229 } | 231 } |
230 } | 232 } |
231 | 233 |
232 void appendErrorToken(ErrorToken token) { | 234 void appendErrorToken(ErrorToken token) { |
233 hasErrors = true; | 235 hasErrors = true; |
234 appendToken(token); | 236 appendToken(token); |
235 } | 237 } |
236 | 238 |
237 void appendSubstringToken(PrecedenceInfo info, int start, bool asciiOnly, | 239 void appendSubstringToken(PrecedenceInfo info, int start, bool asciiOnly, |
(...skipping 25 matching lines...) Expand all Loading... |
263 * something which cannot possibly be part of a type parameter/argument | 265 * something which cannot possibly be part of a type parameter/argument |
264 * list, like the '=' in the above example. | 266 * list, like the '=' in the above example. |
265 */ | 267 */ |
266 void discardOpenLt() { | 268 void discardOpenLt() { |
267 while (!groupingStack.isEmpty && | 269 while (!groupingStack.isEmpty && |
268 identical(groupingStack.head.kind, LT_TOKEN)) { | 270 identical(groupingStack.head.kind, LT_TOKEN)) { |
269 groupingStack = groupingStack.tail; | 271 groupingStack = groupingStack.tail; |
270 } | 272 } |
271 } | 273 } |
272 } | 274 } |
OLD | NEW |