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

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

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