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

Side by Side Diff: pkg/analyzer/lib/src/generated/parser.dart

Issue 2100553003: Token of an empty comment reference should end with EOF. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/parser_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 analyzer.src.generated.parser; 5 library analyzer.src.generated.parser;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import "dart:math" as math; 8 import "dart:math" as math;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 5015 matching lines...) Expand 10 before | Expand all | Expand 10 after
5026 * first character of the reference source. Return the comment reference that 5026 * first character of the reference source. Return the comment reference that
5027 * was parsed, or `null` if no reference could be found. 5027 * was parsed, or `null` if no reference could be found.
5028 * 5028 *
5029 * commentReference ::= 5029 * commentReference ::=
5030 * 'new'? prefixedIdentifier 5030 * 'new'? prefixedIdentifier
5031 */ 5031 */
5032 CommentReference _parseCommentReference( 5032 CommentReference _parseCommentReference(
5033 String referenceSource, int sourceOffset) { 5033 String referenceSource, int sourceOffset) {
5034 // TODO(brianwilkerson) The errors are not getting the right offset/length 5034 // TODO(brianwilkerson) The errors are not getting the right offset/length
5035 // and are being duplicated. 5035 // and are being duplicated.
5036 if (referenceSource.length == 0) {
5037 Token syntheticToken =
5038 new SyntheticStringToken(TokenType.IDENTIFIER, "", sourceOffset);
5039 return new CommentReference(null, new SimpleIdentifier(syntheticToken));
5040 }
5041 try { 5036 try {
5042 BooleanErrorListener listener = new BooleanErrorListener(); 5037 BooleanErrorListener listener = new BooleanErrorListener();
5043 Scanner scanner = new Scanner( 5038 Scanner scanner = new Scanner(
5044 null, new SubSequenceReader(referenceSource, sourceOffset), listener); 5039 null, new SubSequenceReader(referenceSource, sourceOffset), listener);
5045 scanner.setSourceStart(1, 1); 5040 scanner.setSourceStart(1, 1);
5046 Token firstToken = scanner.tokenize(); 5041 Token firstToken = scanner.tokenize();
5047 if (listener.errorReported) { 5042 if (listener.errorReported) {
5048 return null; 5043 return null;
5049 } 5044 }
5045 if (firstToken.type == TokenType.EOF) {
5046 Token syntheticToken =
5047 new SyntheticStringToken(TokenType.IDENTIFIER, "", sourceOffset);
5048 syntheticToken.setNext(firstToken);
5049 return new CommentReference(null, new SimpleIdentifier(syntheticToken));
5050 }
5050 Token newKeyword = null; 5051 Token newKeyword = null;
5051 if (_tokenMatchesKeyword(firstToken, Keyword.NEW)) { 5052 if (_tokenMatchesKeyword(firstToken, Keyword.NEW)) {
5052 newKeyword = firstToken; 5053 newKeyword = firstToken;
5053 firstToken = firstToken.next; 5054 firstToken = firstToken.next;
5054 } 5055 }
5055 if (_tokenMatchesIdentifier(firstToken)) { 5056 if (_tokenMatchesIdentifier(firstToken)) {
5056 Token secondToken = firstToken.next; 5057 Token secondToken = firstToken.next;
5057 Token thirdToken = secondToken.next; 5058 Token thirdToken = secondToken.next;
5058 Token nextToken; 5059 Token nextToken;
5059 Identifier identifier; 5060 Identifier identifier;
(...skipping 5392 matching lines...) Expand 10 before | Expand all | Expand 10 after
10452 */ 10453 */
10453 const ParserErrorCode(String name, String message, [String correction]) 10454 const ParserErrorCode(String name, String message, [String correction])
10454 : super(name, message, correction); 10455 : super(name, message, correction);
10455 10456
10456 @override 10457 @override
10457 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR; 10458 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR;
10458 10459
10459 @override 10460 @override
10460 ErrorType get type => ErrorType.SYNTACTIC_ERROR; 10461 ErrorType get type => ErrorType.SYNTACTIC_ERROR;
10461 } 10462 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/parser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698