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

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

Issue 2821483003: Revert "Fix more parser bugs" (Closed)
Patch Set: Created 3 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
« 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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 // We know that we have an identifier, and need to see whether it might be 535 // We know that we have an identifier, and need to see whether it might be
536 // a type name. 536 // a type name.
537 if (_currentToken.type != TokenType.IDENTIFIER) { 537 if (_currentToken.type != TokenType.IDENTIFIER) {
538 allowAdditionalTokens = false; 538 allowAdditionalTokens = false;
539 } 539 }
540 Token token = skipTypeName(_currentToken); 540 Token token = skipTypeName(_currentToken);
541 if (token == null) { 541 if (token == null) {
542 // There was no type name, so this can't be a declaration. 542 // There was no type name, so this can't be a declaration.
543 return false; 543 return false;
544 } 544 }
545 while (_atGenericFunctionTypeAfterReturnType(token)) { 545 if (_atGenericFunctionTypeAfterReturnType(token)) {
546 token = skipGenericFunctionTypeAfterReturnType(token); 546 token = skipGenericFunctionTypeAfterReturnType(token);
547 if (token == null) { 547 if (token == null) {
548 // There was no type name, so this can't be a declaration. 548 // There was no type name, so this can't be a declaration.
549 return false; 549 return false;
550 } 550 }
551 } 551 }
552 if (token.type != TokenType.IDENTIFIER) { 552 if (token.type != TokenType.IDENTIFIER) {
553 allowAdditionalTokens = false; 553 allowAdditionalTokens = false;
554 } 554 }
555 token = skipSimpleIdentifier(token); 555 token = skipSimpleIdentifier(token);
(...skipping 3498 matching lines...) Expand 10 before | Expand all | Expand 10 after
4054 Token next = _currentToken.next; 4054 Token next = _currentToken.next;
4055 if (_matchesIdentifier() && 4055 if (_matchesIdentifier() &&
4056 next.matchesAny(const <TokenType>[ 4056 next.matchesAny(const <TokenType>[
4057 TokenType.OPEN_PAREN, 4057 TokenType.OPEN_PAREN,
4058 TokenType.OPEN_CURLY_BRACKET, 4058 TokenType.OPEN_CURLY_BRACKET,
4059 TokenType.FUNCTION, 4059 TokenType.FUNCTION,
4060 TokenType.LT 4060 TokenType.LT
4061 ])) { 4061 ])) {
4062 return _parseFunctionDeclarationStatementAfterReturnType( 4062 return _parseFunctionDeclarationStatementAfterReturnType(
4063 commentAndMetadata, returnType); 4063 commentAndMetadata, returnType);
4064 } else if (_matchesIdentifier() && 4064 } else {
4065 next.matchesAny(const <TokenType>[ 4065 //
4066 // We have found an error of some kind. Try to recover.
4067 //
4068 if (_matchesIdentifier()) {
4069 if (next.matchesAny(const <TokenType>[
4066 TokenType.EQ, 4070 TokenType.EQ,
4067 TokenType.COMMA, 4071 TokenType.COMMA,
4068 TokenType.SEMICOLON 4072 TokenType.SEMICOLON
4069 ])) { 4073 ])) {
4070 if (returnType is! GenericFunctionType) { 4074 //
4071 _reportErrorForNode(ParserErrorCode.VOID_VARIABLE, returnType); 4075 // We appear to have a variable declaration with a type of "void".
4072 } 4076 //
4073 return _parseVariableDeclarationStatementAfterType( 4077 _reportErrorForNode(ParserErrorCode.VOID_VARIABLE, returnType);
4074 commentAndMetadata, null, returnType); 4078 return parseVariableDeclarationStatementAfterMetadata(
4075 } else { 4079 commentAndMetadata);
4076 // 4080 }
4077 // We have found an error of some kind. Try to recover. 4081 } else if (_matches(TokenType.CLOSE_CURLY_BRACKET)) {
4078 //
4079 if (_matches(TokenType.CLOSE_CURLY_BRACKET)) {
4080 // 4082 //
4081 // We appear to have found an incomplete statement at the end of a 4083 // We appear to have found an incomplete statement at the end of a
4082 // block. Parse it as a variable declaration. 4084 // block. Parse it as a variable declaration.
4083 // 4085 //
4084 return _parseVariableDeclarationStatementAfterType( 4086 return _parseVariableDeclarationStatementAfterType(
4085 commentAndMetadata, null, returnType); 4087 commentAndMetadata, null, returnType);
4086 } 4088 }
4087 _reportErrorForCurrentToken(ParserErrorCode.MISSING_STATEMENT); 4089 _reportErrorForCurrentToken(ParserErrorCode.MISSING_STATEMENT);
4088 // TODO(brianwilkerson) Recover from this error. 4090 // TODO(brianwilkerson) Recover from this error.
4089 return astFactory 4091 return astFactory
(...skipping 4470 matching lines...) Expand 10 before | Expand all | Expand 10 after
8560 } 8562 }
8561 if (modifiers.finalKeyword != null) { 8563 if (modifiers.finalKeyword != null) {
8562 _reportErrorForToken( 8564 _reportErrorForToken(
8563 ParserErrorCode.FINAL_TYPEDEF, modifiers.finalKeyword); 8565 ParserErrorCode.FINAL_TYPEDEF, modifiers.finalKeyword);
8564 } 8566 }
8565 if (modifiers.varKeyword != null) { 8567 if (modifiers.varKeyword != null) {
8566 _reportErrorForToken(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword); 8568 _reportErrorForToken(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword);
8567 } 8569 }
8568 } 8570 }
8569 } 8571 }
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