Chromium Code Reviews| 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); |