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

Unified Diff: pkg/fasta/lib/src/source/diet_parser.dart

Issue 2634543002: Fasta parser listener infrastructure. (Closed)
Patch Set: Created 3 years, 11 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
Index: pkg/fasta/lib/src/source/diet_parser.dart
diff --git a/pkg/fasta/lib/src/source/diet_parser.dart b/pkg/fasta/lib/src/source/diet_parser.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1811f859f1e8f60b2c7f996b130e28be8d59b0d2
--- /dev/null
+++ b/pkg/fasta/lib/src/source/diet_parser.dart
@@ -0,0 +1,47 @@
+// Copyright (c) 2016, 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 fasta.diet_parser;
+
+import 'package:dart_scanner/src/token.dart' show
+ BeginGroupToken,
+ Token;
+
+import 'package:dart_parser/src/class_member_parser.dart' show
+ ClassMemberParser;
+
+import 'package:dart_parser/src/error_kind.dart' show
+ ErrorKind;
+
+import 'package:dart_parser/src/listener.dart' show
+ Listener;
+
+import 'package:dart_parser/src/parser.dart' show
+ optional;
+
+// TODO(ahe): Move this to parser package.
+class DietParser extends ClassMemberParser {
+ DietParser(Listener listener,
+ {bool asyncAwaitKeywordsEnabled: false,
+ bool enableGenericMethodSyntax: false})
+ : super(listener, asyncAwaitKeywordsEnabled: asyncAwaitKeywordsEnabled,
+ enableGenericMethodSyntax: enableGenericMethodSyntax);
+
+ Token parseFormalParameters(Token token) => skipFormals(token);
+
+ Token skipFormals(Token token) {
+ listener.beginOptionalFormalParameters(token);
+ if (!optional('(', token)) {
+ if (optional(';', token)) {
+ listener.reportError(token, ErrorKind.EXPECTED_OPEN_PARENS);
+ return token;
+ }
+ return listener.unexpected(token);
+ }
+ BeginGroupToken beginGroupToken = token;
+ Token endToken = beginGroupToken.endGroup;
+ listener.endFormalParameters(0, token, endToken);
+ return endToken.next;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698