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

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

Issue 2763833002: fasta.CommentToken implement analyzer.CommentToken (Closed)
Patch Set: merge Created 3 years, 9 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 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 EOF_INFO, PrecedenceInfo; 11 import 'precedence.dart' show EOF_INFO, PrecedenceInfo;
12 12
13 import 'token.dart' 13 import 'token.dart'
14 show BeginGroupToken, KeywordToken, StringToken, SymbolToken, Token; 14 show
15 BeginGroupToken,
16 CommentToken,
17 DartDocToken,
18 KeywordToken,
19 StringToken,
20 SymbolToken,
21 Token;
15 22
16 import 'token_constants.dart' 23 import 'token_constants.dart'
17 show 24 show
18 LT_TOKEN, 25 LT_TOKEN,
19 OPEN_CURLY_BRACKET_TOKEN, 26 OPEN_CURLY_BRACKET_TOKEN,
20 OPEN_PAREN_TOKEN, 27 OPEN_PAREN_TOKEN,
21 STRING_INTERPOLATION_TOKEN; 28 STRING_INTERPOLATION_TOKEN;
22 29
23 import 'characters.dart' show $LF, $STX; 30 import 'characters.dart' show $LF, $STX;
24 31
(...skipping 15 matching lines...) Expand all
40 Link<BeginGroupToken> groupingStack = const Link<BeginGroupToken>(); 47 Link<BeginGroupToken> groupingStack = const Link<BeginGroupToken>();
41 48
42 /** 49 /**
43 * Append the given token to the [tail] of the current stream of tokens. 50 * Append the given token to the [tail] of the current stream of tokens.
44 */ 51 */
45 void appendToken(Token token) { 52 void appendToken(Token token) {
46 tail.next = token; 53 tail.next = token;
47 tail.next.previousToken = tail; 54 tail.next.previousToken = tail;
48 tail = tail.next; 55 tail = tail.next;
49 if (comments != null) { 56 if (comments != null) {
50 tail.precedingComments = comments; 57 tail.precedingCommentTokens = comments;
51 comments = null; 58 comments = null;
52 commentsTail = null; 59 commentsTail = null;
53 } 60 }
54 } 61 }
55 62
56 /** 63 /**
57 * Appends a fixed token whose kind and content is determined by [info]. 64 * Appends a fixed token whose kind and content is determined by [info].
58 * Appends an *operator* token from [info]. 65 * Appends an *operator* token from [info].
59 * 66 *
60 * An operator token represent operators like ':', '.', ';', '&&', '==', '--', 67 * An operator token represent operators like ':', '.', ';', '&&', '==', '--',
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 227 }
221 if (groupingStack.isEmpty) return; 228 if (groupingStack.isEmpty) return;
222 if (identical(groupingStack.head.kind, LT_TOKEN)) { 229 if (identical(groupingStack.head.kind, LT_TOKEN)) {
223 groupingStack.head.endGroup = tail; 230 groupingStack.head.endGroup = tail;
224 groupingStack = groupingStack.tail; 231 groupingStack = groupingStack.tail;
225 } 232 }
226 } 233 }
227 234
228 void appendComment(start, PrecedenceInfo info, bool asciiOnly) { 235 void appendComment(start, PrecedenceInfo info, bool asciiOnly) {
229 if (!includeComments) return; 236 if (!includeComments) return;
230 Token newComment = createSubstringToken(info, start, asciiOnly); 237 Token newComment = createCommentToken(info, start, asciiOnly);
238 _appendToCommentStream(newComment);
239 }
240
241 void appendDartDoc(start, PrecedenceInfo info, bool asciiOnly) {
242 if (!includeComments) return;
243 Token newComment = createDartDocToken(info, start, asciiOnly);
244 _appendToCommentStream(newComment);
245 }
246
247 void _appendToCommentStream(Token newComment) {
231 if (comments == null) { 248 if (comments == null) {
232 comments = newComment; 249 comments = newComment;
233 commentsTail = comments; 250 commentsTail = comments;
234 } else { 251 } else {
235 commentsTail.next = newComment; 252 commentsTail.next = newComment;
236 commentsTail.next.previousToken = commentsTail; 253 commentsTail.next.previousToken = commentsTail;
237 commentsTail = commentsTail.next; 254 commentsTail = commentsTail.next;
238 } 255 }
239 } 256 }
240 257
(...skipping 14 matching lines...) Expand all
255 * substring string [5,9). 272 * substring string [5,9).
256 * 273 *
257 * Note that [extraOffset] can only be used if the covered character(s) are 274 * Note that [extraOffset] can only be used if the covered character(s) are
258 * known to be ASCII. 275 * known to be ASCII.
259 */ 276 */
260 StringToken createSubstringToken( 277 StringToken createSubstringToken(
261 PrecedenceInfo info, int start, bool asciiOnly, 278 PrecedenceInfo info, int start, bool asciiOnly,
262 [int extraOffset = 0]); 279 [int extraOffset = 0]);
263 280
264 /** 281 /**
282 * Returns a new comment from the scan offset [start] to the current
283 * [scanOffset] plus the [extraOffset]. For example, if the current
284 * scanOffset is 10, then [appendSubstringToken(5, -1)] will append the
285 * substring string [5,9).
286 *
287 * Note that [extraOffset] can only be used if the covered character(s) are
288 * known to be ASCII.
289 */
290 CommentToken createCommentToken(
291 PrecedenceInfo info, int start, bool asciiOnly,
292 [int extraOffset = 0]);
293
294 /**
295 * Returns a new dartdoc from the scan offset [start] to the current
296 * [scanOffset] plus the [extraOffset]. For example, if the current
297 * scanOffset is 10, then [appendSubstringToken(5, -1)] will append the
298 * substring string [5,9).
299 *
300 * Note that [extraOffset] can only be used if the covered character(s) are
301 * known to be ASCII.
302 */
303 DartDocToken createDartDocToken(
304 PrecedenceInfo info, int start, bool asciiOnly,
305 [int extraOffset = 0]);
306
307 /**
265 * This method is called to discard '<' from the "grouping" stack. 308 * This method is called to discard '<' from the "grouping" stack.
266 * 309 *
267 * [PartialParser.skipExpression] relies on the fact that we do not 310 * [PartialParser.skipExpression] relies on the fact that we do not
268 * create groups for stuff like: 311 * create groups for stuff like:
269 * [:a = b < c, d = e > f:]. 312 * [:a = b < c, d = e > f:].
270 * 313 *
271 * In other words, this method is called when the scanner recognizes 314 * In other words, this method is called when the scanner recognizes
272 * something which cannot possibly be part of a type parameter/argument 315 * something which cannot possibly be part of a type parameter/argument
273 * list, like the '=' in the above example. 316 * list, like the '=' in the above example.
274 */ 317 */
275 void discardOpenLt() { 318 void discardOpenLt() {
276 while (!groupingStack.isEmpty && 319 while (!groupingStack.isEmpty &&
277 identical(groupingStack.head.kind, LT_TOKEN)) { 320 identical(groupingStack.head.kind, LT_TOKEN)) {
278 groupingStack = groupingStack.tail; 321 groupingStack = groupingStack.tail;
279 } 322 }
280 } 323 }
281 } 324 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart ('k') | pkg/front_end/lib/src/fasta/scanner/string_scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698