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

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

Issue 2817873003: 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 if (_atGenericFunctionTypeAfterReturnType(token)) { 545 while (_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() &&
4065 next.matchesAny(const <TokenType>[
4066 TokenType.EQ,
4067 TokenType.COMMA,
4068 TokenType.SEMICOLON
4069 ])) {
4070 if (returnType is! GenericFunctionType) {
4071 _reportErrorForNode(ParserErrorCode.VOID_VARIABLE, returnType);
4072 }
4073 return _parseVariableDeclarationStatementAfterType(
4074 commentAndMetadata, null, returnType);
4064 } else { 4075 } else {
4065 // 4076 //
4066 // We have found an error of some kind. Try to recover. 4077 // We have found an error of some kind. Try to recover.
4067 // 4078 //
4068 if (_matchesIdentifier()) { 4079 if (_matches(TokenType.CLOSE_CURLY_BRACKET)) {
4069 if (next.matchesAny(const <TokenType>[
4070 TokenType.EQ,
4071 TokenType.COMMA,
4072 TokenType.SEMICOLON
4073 ])) {
4074 //
4075 // We appear to have a variable declaration with a type of "void".
4076 //
4077 _reportErrorForNode(ParserErrorCode.VOID_VARIABLE, returnType);
4078 return parseVariableDeclarationStatementAfterMetadata(
4079 commentAndMetadata);
4080 }
4081 } else if (_matches(TokenType.CLOSE_CURLY_BRACKET)) {
4082 // 4080 //
4083 // We appear to have found an incomplete statement at the end of a 4081 // We appear to have found an incomplete statement at the end of a
4084 // block. Parse it as a variable declaration. 4082 // block. Parse it as a variable declaration.
4085 // 4083 //
4086 return _parseVariableDeclarationStatementAfterType( 4084 return _parseVariableDeclarationStatementAfterType(
4087 commentAndMetadata, null, returnType); 4085 commentAndMetadata, null, returnType);
4088 } 4086 }
4089 _reportErrorForCurrentToken(ParserErrorCode.MISSING_STATEMENT); 4087 _reportErrorForCurrentToken(ParserErrorCode.MISSING_STATEMENT);
4090 // TODO(brianwilkerson) Recover from this error. 4088 // TODO(brianwilkerson) Recover from this error.
4091 return astFactory 4089 return astFactory
(...skipping 4470 matching lines...) Expand 10 before | Expand all | Expand 10 after
8562 } 8560 }
8563 if (modifiers.finalKeyword != null) { 8561 if (modifiers.finalKeyword != null) {
8564 _reportErrorForToken( 8562 _reportErrorForToken(
8565 ParserErrorCode.FINAL_TYPEDEF, modifiers.finalKeyword); 8563 ParserErrorCode.FINAL_TYPEDEF, modifiers.finalKeyword);
8566 } 8564 }
8567 if (modifiers.varKeyword != null) { 8565 if (modifiers.varKeyword != null) {
8568 _reportErrorForToken(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword); 8566 _reportErrorForToken(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword);
8569 } 8567 }
8570 } 8568 }
8571 } 8569 }
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