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

Unified Diff: pkg/compiler/lib/src/scanner/partial_parser.dart

Issue 1313073007: Move parser and token related libraries into their own subfolder. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix unittests and try Created 5 years, 3 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/scanner/parser_task.dart ('k') | pkg/compiler/lib/src/scanner/scanner.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/scanner/partial_parser.dart
diff --git a/pkg/compiler/lib/src/scanner/partial_parser.dart b/pkg/compiler/lib/src/scanner/partial_parser.dart
deleted file mode 100644
index 7b3232d56f943307c2cc6fb7d932974599207c98..0000000000000000000000000000000000000000
--- a/pkg/compiler/lib/src/scanner/partial_parser.dart
+++ /dev/null
@@ -1,181 +0,0 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-library dart2js.parser.partial;
-
-import '../diagnostics/messages.dart' show
- MessageKind;
-import '../util/characters.dart' show
- $CLOSE_CURLY_BRACKET;
-
-import 'listener.dart' show
- Listener;
-import 'parser.dart' show
- Parser;
-import 'token.dart' show
- BeginGroupToken,
- EOF_TOKEN,
- ErrorToken,
- Token;
-
-class PartialParser extends Parser {
- PartialParser(Listener listener) : super(listener);
-
- Token parseClassBody(Token token) => skipClassBody(token);
-
- Token fullParseClassBody(Token token) => super.parseClassBody(token);
-
- Token parseExpression(Token token) => skipExpression(token);
-
- Token parseArgumentsOpt(Token token) {
- // This method is overridden for two reasons:
- // 1. Avoid generating events for arguments.
- // 2. Avoid calling skip expression for each argument (which doesn't work).
- if (optional('(', token)) {
- BeginGroupToken begin = token;
- return begin.endGroup.next;
- } else {
- return token;
- }
- }
-
- Token skipExpression(Token token) {
- while (true) {
- final kind = token.kind;
- final value = token.stringValue;
- if ((identical(kind, EOF_TOKEN)) ||
- (identical(value, ';')) ||
- (identical(value, ',')) ||
- (identical(value, '}')) ||
- (identical(value, ')')) ||
- (identical(value, ']'))) {
- break;
- }
- if (identical(value, '=') ||
- identical(value, '?') ||
- identical(value, ':')) {
- var nextValue = token.next.stringValue;
- if (identical(nextValue, 'const')) {
- token = token.next;
- nextValue = token.next.stringValue;
- }
- if (identical(nextValue, '{')) {
- // Handle cases like this:
- // class Foo {
- // var map;
- // Foo() : map = {};
- // Foo.x() : map = true ? {} : {};
- // }
- BeginGroupToken begin = token.next;
- token = (begin.endGroup != null) ? begin.endGroup : token;
- token = token.next;
- continue;
- }
- if (identical(nextValue, '<')) {
- // Handle cases like this:
- // class Foo {
- // var map;
- // Foo() : map = <String, Foo>{};
- // Foo.x() : map = true ? <String, Foo>{} : <String, Foo>{};
- // }
- BeginGroupToken begin = token.next;
- token = (begin.endGroup != null) ? begin.endGroup : token;
- token = token.next;
- if (identical(token.stringValue, '{')) {
- begin = token;
- token = (begin.endGroup != null) ? begin.endGroup : token;
- token = token.next;
- }
- continue;
- }
- }
- if (!mayParseFunctionExpressions && identical(value, '{')) {
- break;
- }
- if (token is BeginGroupToken) {
- BeginGroupToken begin = token;
- token = (begin.endGroup != null) ? begin.endGroup : token;
- } else if (token is ErrorToken) {
- listener.reportErrorToken(token);
- }
- token = token.next;
- }
- return token;
- }
-
- Token skipClassBody(Token token) {
- if (!optional('{', token)) {
- return listener.expectedClassBodyToSkip(token);
- }
- BeginGroupToken beginGroupToken = token;
- Token endGroup = beginGroupToken.endGroup;
- if (endGroup == null) {
- return listener.unmatched(beginGroupToken);
- } else if (!identical(endGroup.kind, $CLOSE_CURLY_BRACKET)) {
- return listener.unmatched(beginGroupToken);
- }
- return endGroup;
- }
-
- Token skipAsyncModifier(Token token) {
- String value = token.stringValue;
- if (identical(value, 'async')) {
- token = token.next;
- value = token.stringValue;
-
- if (identical(value, '*')) {
- token = token.next;
- }
- } else if (identical(value, 'sync')) {
- token = token.next;
- value = token.stringValue;
-
- if (identical(value, '*')) {
- token = token.next;
- }
- }
- return token;
- }
-
- Token parseFunctionBody(Token token, bool isExpression, bool allowAbstract) {
- assert(!isExpression);
- token = skipAsyncModifier(token);
- String value = token.stringValue;
- if (identical(value, ';')) {
- if (!allowAbstract) {
- listener.reportError(token, MessageKind.BODY_EXPECTED);
- }
- listener.handleNoFunctionBody(token);
- } else {
- if (identical(value, '=>')) {
- token = parseExpression(token.next);
- expectSemicolon(token);
- } else if (value == '=') {
- token = parseRedirectingFactoryBody(token);
- expectSemicolon(token);
- } else {
- token = skipBlock(token);
- }
- listener.skippedFunctionBody(token);
- }
- return token;
- }
-
- Token parseFormalParameters(Token token) => skipFormals(token);
-
- Token skipFormals(Token token) {
- listener.beginOptionalFormalParameters(token);
- if (!optional('(', token)) {
- if (optional(';', token)) {
- listener.recoverableError(token, "expected '('");
- return token;
- }
- return listener.unexpected(token);
- }
- BeginGroupToken beginGroupToken = token;
- Token endToken = beginGroupToken.endGroup;
- listener.endFormalParameters(0, token, endToken);
- return endToken.next;
- }
-}
« no previous file with comments | « pkg/compiler/lib/src/scanner/parser_task.dart ('k') | pkg/compiler/lib/src/scanner/scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698