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

Side by Side Diff: pkg/compiler/lib/src/scanner/parser.dart

Issue 886833005: Fix await parsing. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix metadata_test Created 5 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of scanner; 5 part of scanner;
6 6
7 class FormalParameterType { 7 class FormalParameterType {
8 final String type; 8 final String type;
9 const FormalParameterType(this.type); 9 const FormalParameterType(this.type);
10 bool get isRequired => this == REQUIRED; 10 bool get isRequired => this == REQUIRED;
(...skipping 23 matching lines...) Expand all
34 * 34 *
35 * Parse methods are generally named parseGrammarProductionSuffix. The 35 * Parse methods are generally named parseGrammarProductionSuffix. The
36 * suffix can be one of "opt", or "star". "opt" means zero or one 36 * suffix can be one of "opt", or "star". "opt" means zero or one
37 * matches, "star" means zero or more matches. For example, 37 * matches, "star" means zero or more matches. For example,
38 * [parseMetadataStar] corresponds to this grammar snippet: [: 38 * [parseMetadataStar] corresponds to this grammar snippet: [:
39 * metadata* :], and [parseTypeOpt] corresponds to: [: type? :]. 39 * metadata* :], and [parseTypeOpt] corresponds to: [: type? :].
40 */ 40 */
41 class Parser { 41 class Parser {
42 final Listener listener; 42 final Listener listener;
43 bool mayParseFunctionExpressions = true; 43 bool mayParseFunctionExpressions = true;
44 bool yieldIsKeyword = false; 44 bool yieldIsKeyword;
45 bool awaitIsKeyword = false; 45 bool awaitIsKeyword;
46 46
47 Parser(this.listener); 47 Parser(this.listener,
48 {this.yieldIsKeyword: false, this.awaitIsKeyword: false});
48 49
49 Token parseUnit(Token token) { 50 Token parseUnit(Token token) {
50 listener.beginCompilationUnit(token); 51 listener.beginCompilationUnit(token);
51 int count = 0; 52 int count = 0;
52 while (!identical(token.kind, EOF_TOKEN)) { 53 while (!identical(token.kind, EOF_TOKEN)) {
53 token = parseTopLevelDeclaration(token); 54 token = parseTopLevelDeclaration(token);
54 listener.endTopLevelDeclaration(token); 55 listener.endTopLevelDeclaration(token);
55 count++; 56 count++;
56 } 57 }
57 listener.endCompilationUnit(count, token); 58 listener.endCompilationUnit(count, token);
(...skipping 2407 matching lines...) Expand 10 before | Expand all | Expand 10 after
2465 ++statementCount; 2466 ++statementCount;
2466 } 2467 }
2467 listener.endBlock(statementCount, begin, token); 2468 listener.endBlock(statementCount, begin, token);
2468 return expect('}', token); 2469 return expect('}', token);
2469 } 2470 }
2470 2471
2471 Token parseAwaitExpression(Token token, bool allowCascades) { 2472 Token parseAwaitExpression(Token token, bool allowCascades) {
2472 Token awaitToken = token; 2473 Token awaitToken = token;
2473 listener.beginAwaitExpression(awaitToken); 2474 listener.beginAwaitExpression(awaitToken);
2474 token = expect('await', token); 2475 token = expect('await', token);
2475 token = parseUnaryExpression(token, allowCascades); 2476 token = parsePrecedenceExpression(token, POSTFIX_PRECEDENCE,
2477 allowCascades);
2476 listener.endAwaitExpression(awaitToken, token); 2478 listener.endAwaitExpression(awaitToken, token);
2477 return token; 2479 return token;
2478 } 2480 }
2479 2481
2480 Token parseThrowExpression(Token token, bool allowCascades) { 2482 Token parseThrowExpression(Token token, bool allowCascades) {
2481 Token throwToken = token; 2483 Token throwToken = token;
2482 listener.beginThrowExpression(throwToken); 2484 listener.beginThrowExpression(throwToken);
2483 token = expect('throw', token); 2485 token = expect('throw', token);
2484 token = allowCascades 2486 token = allowCascades
2485 ? parseExpression(token) 2487 ? parseExpression(token)
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2672 } 2674 }
2673 listener.handleContinueStatement(hasTarget, continueKeyword, token); 2675 listener.handleContinueStatement(hasTarget, continueKeyword, token);
2674 return expectSemicolon(token); 2676 return expectSemicolon(token);
2675 } 2677 }
2676 2678
2677 Token parseEmptyStatement(Token token) { 2679 Token parseEmptyStatement(Token token) {
2678 listener.handleEmptyStatement(token); 2680 listener.handleEmptyStatement(token);
2679 return expectSemicolon(token); 2681 return expectSemicolon(token);
2680 } 2682 }
2681 } 2683 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/typechecker.dart » ('j') | pkg/compiler/lib/src/typechecker.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698