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

Unified Diff: pkg/front_end/lib/src/fasta/parser/parser.dart

Issue 2996163002: support class native clause (Closed)
Patch Set: add new fasta native clause error code Created 3 years, 4 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/front_end/lib/src/fasta/parser/parser.dart
diff --git a/pkg/front_end/lib/src/fasta/parser/parser.dart b/pkg/front_end/lib/src/fasta/parser/parser.dart
index f7e2e1f90c1ca2e2ecc07d131512ef7aaa3a7661..a738931d88c46f80e4b3a88cac3d28d99dfa2cb9 100644
--- a/pkg/front_end/lib/src/fasta/parser/parser.dart
+++ b/pkg/front_end/lib/src/fasta/parser/parser.dart
@@ -857,9 +857,16 @@ class Parser {
++interfacesCount;
} while (optional(',', token));
}
+ Token nativeToken;
+ if (optional('native', token)) {
+ nativeToken = token;
+ token = parseNativeClause(token.next);
+ reportRecoverableError(
+ nativeToken, fasta.messageNativeClauseShouldBeAnnotation);
+ }
token = parseClassBody(token);
listener.endClassDeclaration(interfacesCount, begin, classKeyword,
- extendsKeyword, implementsKeyword, token);
+ extendsKeyword, implementsKeyword, nativeToken, token);
return token.next;
}
@@ -2105,6 +2112,11 @@ class Parser {
return token;
}
+ Token parseNativeClause(Token token) {
+ if (!identical(token.kind, STRING_TOKEN)) return token;
ahe 2017/08/21 12:04:10 We don't need to use identical on token.kind.
danrubel 2017/08/22 01:35:28 Good point. Fixed.
+ return parseSingleLiteralString(token);
ahe 2017/08/21 12:04:10 We should generate an event here. I'm thinking som
danrubel 2017/08/22 01:35:28 Good point. Per discussion I've added a handleNati
+ }
+
Token skipClassBody(Token token) {
if (!optional('{', token)) {
return reportUnrecoverableErrorWithToken(

Powered by Google App Engine
This is Rietveld 408576698