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

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

Issue 1888803002: Support serialization of all resolved asts from dart:core (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix unittests. 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 ParserOptions; 7 import '../options.dart' show ParserOptions;
8 import '../common.dart'; 8 import '../common.dart';
9 import '../tokens/keyword.dart' show Keyword; 9 import '../tokens/keyword.dart' show Keyword;
10 import '../tokens/precedence.dart' show PrecedenceInfo; 10 import '../tokens/precedence.dart' show PrecedenceInfo;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 */ 97 */
98 class Parser { 98 class Parser {
99 final Listener listener; 99 final Listener listener;
100 final ParserOptions parserOptions; 100 final ParserOptions parserOptions;
101 bool mayParseFunctionExpressions = true; 101 bool mayParseFunctionExpressions = true;
102 bool asyncAwaitKeywordsEnabled; 102 bool asyncAwaitKeywordsEnabled;
103 103
104 final bool enableGenericMethodSyntax; 104 final bool enableGenericMethodSyntax;
105 105
106 Parser(this.listener, ParserOptions parserOptions, 106 Parser(this.listener, ParserOptions parserOptions,
107 {this.asyncAwaitKeywordsEnabled: false}) : 107 {this.asyncAwaitKeywordsEnabled: false})
108 parserOptions = parserOptions, 108 : parserOptions = parserOptions,
109 enableGenericMethodSyntax = parserOptions.enableGenericMethodSyntax; 109 enableGenericMethodSyntax = parserOptions.enableGenericMethodSyntax;
110 110
111 Token parseUnit(Token token) { 111 Token parseUnit(Token token) {
112 listener.beginCompilationUnit(token); 112 listener.beginCompilationUnit(token);
113 int count = 0; 113 int count = 0;
114 while (!identical(token.kind, EOF_TOKEN)) { 114 while (!identical(token.kind, EOF_TOKEN)) {
115 token = parseTopLevelDeclaration(token); 115 token = parseTopLevelDeclaration(token);
116 listener.endTopLevelDeclaration(token); 116 listener.endTopLevelDeclaration(token);
117 count++; 117 count++;
118 } 118 }
119 listener.endCompilationUnit(count, token); 119 listener.endCompilationUnit(count, token);
(...skipping 2185 matching lines...) Expand 10 before | Expand all | Expand 10 after
2305 mayParseFunctionExpressions = old; 2305 mayParseFunctionExpressions = old;
2306 listener.handleLiteralMap(count, beginToken, constKeyword, token); 2306 listener.handleLiteralMap(count, beginToken, constKeyword, token);
2307 return expect('}', token); 2307 return expect('}', token);
2308 } 2308 }
2309 2309
2310 /// formalParameterList functionBody. 2310 /// formalParameterList functionBody.
2311 /// 2311 ///
2312 /// This is a suffix parser because it is assumed that type arguments have 2312 /// This is a suffix parser because it is assumed that type arguments have
2313 /// been parsed, or `listener.handleNoTypeArguments(..)` has been executed. 2313 /// been parsed, or `listener.handleNoTypeArguments(..)` has been executed.
2314 Token parseLiteralFunctionSuffix(Token token) { 2314 Token parseLiteralFunctionSuffix(Token token) {
2315 assert(optional('(',token)); 2315 assert(optional('(', token));
2316 BeginGroupToken beginGroup = token; 2316 BeginGroupToken beginGroup = token;
2317 if (beginGroup.endGroup != null) { 2317 if (beginGroup.endGroup != null) {
2318 Token nextToken = beginGroup.endGroup.next; 2318 Token nextToken = beginGroup.endGroup.next;
2319 int kind = nextToken.kind; 2319 int kind = nextToken.kind;
2320 if (identical(kind, FUNCTION_TOKEN) || 2320 if (identical(kind, FUNCTION_TOKEN) ||
2321 identical(kind, OPEN_CURLY_BRACKET_TOKEN) || 2321 identical(kind, OPEN_CURLY_BRACKET_TOKEN) ||
2322 (identical(kind, KEYWORD_TOKEN) && 2322 (identical(kind, KEYWORD_TOKEN) &&
2323 (nextToken.value == 'async' || nextToken.value == 'sync'))) { 2323 (nextToken.value == 'async' || nextToken.value == 'sync'))) {
2324 return parseUnnamedFunction(token); 2324 return parseUnnamedFunction(token);
2325 } 2325 }
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
2982 } 2982 }
2983 listener.handleContinueStatement(hasTarget, continueKeyword, token); 2983 listener.handleContinueStatement(hasTarget, continueKeyword, token);
2984 return expectSemicolon(token); 2984 return expectSemicolon(token);
2985 } 2985 }
2986 2986
2987 Token parseEmptyStatement(Token token) { 2987 Token parseEmptyStatement(Token token) {
2988 listener.handleEmptyStatement(token); 2988 listener.handleEmptyStatement(token);
2989 return expectSemicolon(token); 2989 return expectSemicolon(token);
2990 } 2990 }
2991 } 2991 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend_impact.dart ('k') | pkg/compiler/lib/src/serialization/constant_serialization.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698