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

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

Issue 1864433004: Repeats and fixes the changes landed & reverted as CL 1789553003. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updates to external dependents Created 4 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
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 library dart2js.parser; 5 library dart2js.parser;
6 6
7 import '../options.dart' show
8 ParserOptions;
7 import '../common.dart'; 9 import '../common.dart';
8 import '../tokens/keyword.dart' show 10 import '../tokens/keyword.dart' show
9 Keyword; 11 Keyword;
10 import '../tokens/precedence.dart' show 12 import '../tokens/precedence.dart' show
11 PrecedenceInfo; 13 PrecedenceInfo;
12 import '../tokens/precedence_constants.dart' show 14 import '../tokens/precedence_constants.dart' show
13 AS_INFO, 15 AS_INFO,
14 ASSIGNMENT_PRECEDENCE, 16 ASSIGNMENT_PRECEDENCE,
15 CASCADE_PRECEDENCE, 17 CASCADE_PRECEDENCE,
16 EQUALITY_PRECEDENCE, 18 EQUALITY_PRECEDENCE,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 * events (except for errors) and may return null. 92 * events (except for errors) and may return null.
91 * 93 *
92 * Parse methods are generally named parseGrammarProductionSuffix. The 94 * Parse methods are generally named parseGrammarProductionSuffix. The
93 * suffix can be one of "opt", or "star". "opt" means zero or one 95 * suffix can be one of "opt", or "star". "opt" means zero or one
94 * matches, "star" means zero or more matches. For example, 96 * matches, "star" means zero or more matches. For example,
95 * [parseMetadataStar] corresponds to this grammar snippet: [: 97 * [parseMetadataStar] corresponds to this grammar snippet: [:
96 * metadata* :], and [parseTypeOpt] corresponds to: [: type? :]. 98 * metadata* :], and [parseTypeOpt] corresponds to: [: type? :].
97 */ 99 */
98 class Parser { 100 class Parser {
99 final Listener listener; 101 final Listener listener;
102 final ParserOptions parserOptions;
100 bool mayParseFunctionExpressions = true; 103 bool mayParseFunctionExpressions = true;
101 final bool enableConditionalDirectives;
102 bool asyncAwaitKeywordsEnabled; 104 bool asyncAwaitKeywordsEnabled;
103 105
104 Parser(this.listener, 106 Parser(this.listener, this.parserOptions,
105 {this.enableConditionalDirectives: false, 107 {this.asyncAwaitKeywordsEnabled: false});
106 this.asyncAwaitKeywordsEnabled: false});
107 108
108 Token parseUnit(Token token) { 109 Token parseUnit(Token token) {
109 listener.beginCompilationUnit(token); 110 listener.beginCompilationUnit(token);
110 int count = 0; 111 int count = 0;
111 while (!identical(token.kind, EOF_TOKEN)) { 112 while (!identical(token.kind, EOF_TOKEN)) {
112 token = parseTopLevelDeclaration(token); 113 token = parseTopLevelDeclaration(token);
113 listener.endTopLevelDeclaration(token); 114 listener.endTopLevelDeclaration(token);
114 count++; 115 count++;
115 } 116 }
116 listener.endCompilationUnit(count, token); 117 listener.endCompilationUnit(count, token);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 Token semicolon = token; 174 Token semicolon = token;
174 token = expect(';', token); 175 token = expect(';', token);
175 listener.endImport(importKeyword, deferredKeyword, asKeyword, semicolon); 176 listener.endImport(importKeyword, deferredKeyword, asKeyword, semicolon);
176 return token; 177 return token;
177 } 178 }
178 179
179 /// if (test) uri 180 /// if (test) uri
180 Token parseConditionalUris(Token token) { 181 Token parseConditionalUris(Token token) {
181 listener.beginConditionalUris(token); 182 listener.beginConditionalUris(token);
182 int count = 0; 183 int count = 0;
183 if (enableConditionalDirectives) { 184 if (parserOptions.enableConditionalDirectives) {
184 while (optional('if', token)) { 185 while (optional('if', token)) {
185 count++; 186 count++;
186 token = parseConditionalUri(token); 187 token = parseConditionalUri(token);
187 } 188 }
188 } 189 }
189 listener.endConditionalUris(count); 190 listener.endConditionalUris(count);
190 return token; 191 return token;
191 } 192 }
192 193
193 Token parseConditionalUri(Token token) { 194 Token parseConditionalUri(Token token) {
(...skipping 2584 matching lines...) Expand 10 before | Expand all | Expand 10 after
2778 } 2779 }
2779 listener.handleContinueStatement(hasTarget, continueKeyword, token); 2780 listener.handleContinueStatement(hasTarget, continueKeyword, token);
2780 return expectSemicolon(token); 2781 return expectSemicolon(token);
2781 } 2782 }
2782 2783
2783 Token parseEmptyStatement(Token token) { 2784 Token parseEmptyStatement(Token token) {
2784 listener.handleEmptyStatement(token); 2785 listener.handleEmptyStatement(token);
2785 return expectSemicolon(token); 2786 return expectSemicolon(token);
2786 } 2787 }
2787 } 2788 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/parser/element_listener.dart ('k') | pkg/compiler/lib/src/parser/parser_task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698