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

Unified Diff: pkg/compiler/lib/src/parser/parser.dart

Issue 1789553003: Introduces `ParserOptions`. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/parser/diet_parser_task.dart ('k') | pkg/compiler/lib/src/parser/parser_task.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/parser/parser.dart
diff --git a/pkg/compiler/lib/src/parser/parser.dart b/pkg/compiler/lib/src/parser/parser.dart
index 42e432becd9afb93159aeec24e8c832ec9477ad6..dc8ec5477afe7cc830af2ab709b39ce25c59304e 100644
--- a/pkg/compiler/lib/src/parser/parser.dart
+++ b/pkg/compiler/lib/src/parser/parser.dart
@@ -72,6 +72,15 @@ class FormalParameterType {
static final NAMED = const FormalParameterType('named');
}
+/// Options used for parsing.
+///
+/// Use this to conditionally support certain constructs, e.g.,
+/// experimental ones.
+class ParserOptions {
+ final bool enableConditionalDirectives;
+ const ParserOptions({this.enableConditionalDirectives: false});
Johnni Winther 2016/03/11 13:43:39 Nit: Add an empty line before the constructor.
eernst 2016/03/21 13:03:34 Done.
+}
+
/**
* An event generating parser of Dart programs. This parser expects
* all tokens in a linked list (aka a token stream).
@@ -97,13 +106,12 @@ class FormalParameterType {
*/
class Parser {
final Listener listener;
+ final ParserOptions parserOptions;
bool mayParseFunctionExpressions = true;
- final bool enableConditionalDirectives;
bool asyncAwaitKeywordsEnabled;
- Parser(this.listener,
- {this.enableConditionalDirectives: false,
- this.asyncAwaitKeywordsEnabled: false});
+ Parser(this.listener, this.parserOptions,
+ {this.asyncAwaitKeywordsEnabled: false});
Token parseUnit(Token token) {
listener.beginCompilationUnit(token);
@@ -180,7 +188,7 @@ class Parser {
Token parseConditionalUris(Token token) {
listener.beginConditionalUris(token);
int count = 0;
- if (enableConditionalDirectives) {
+ if (parserOptions.enableConditionalDirectives) {
while (optional('if', token)) {
count++;
token = parseConditionalUri(token);
« no previous file with comments | « pkg/compiler/lib/src/parser/diet_parser_task.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