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

Side by Side Diff: pkg/front_end/lib/src/fasta/parser/parser.dart

Issue 2671013002: Add handleMemberName event to allow parsing Dart VM natives. (Closed)
Patch Set: Created 3 years, 10 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 fasta.parser.parser; 5 library fasta.parser.parser;
6 6
7 import '../scanner.dart' show 7 import '../scanner.dart' show
8 ErrorToken; 8 ErrorToken;
9 9
10 import '../scanner/recover.dart' show 10 import '../scanner/recover.dart' show
(...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 token = token.next; 1193 token = token.next;
1194 if (optional("*", token)) { 1194 if (optional("*", token)) {
1195 // Skip. 1195 // Skip.
1196 token = token.next; 1196 token = token.next;
1197 } 1197 }
1198 continue; 1198 continue;
1199 } else if (optional("(", token) || optional("{", token) || 1199 } else if (optional("(", token) || optional("{", token) ||
1200 optional("=>", token)) { 1200 optional("=>", token)) {
1201 // A method. 1201 // A method.
1202 identifiers = identifiers.prepend(token); 1202 identifiers = identifiers.prepend(token);
1203 return identifiers; 1203 return listener.handleMemberName(identifiers);
1204 } else if (optional("=", token) || optional(";", token) || 1204 } else if (optional("=", token) || optional(";", token) ||
1205 optional(",", token)) { 1205 optional(",", token)) {
1206 // A field or abstract getter. 1206 // A field or abstract getter.
1207 identifiers = identifiers.prepend(token); 1207 identifiers = identifiers.prepend(token);
1208 return identifiers; 1208 return listener.handleMemberName(identifiers);
1209 } else if (isGetter) { 1209 } else if (isGetter) {
1210 hasName = true; 1210 hasName = true;
1211 } 1211 }
1212 identifiers = identifiers.prepend(token); 1212 identifiers = identifiers.prepend(token);
1213 if (isValidTypeReference(token)) { 1213 if (isValidTypeReference(token)) {
1214 // type ... 1214 // type ...
1215 if (optional('.', token.next)) { 1215 if (optional('.', token.next)) {
1216 // type '.' ... 1216 // type '.' ...
1217 if (token.next.next.isIdentifier()) { 1217 if (token.next.next.isIdentifier()) {
1218 // type '.' identifier 1218 // type '.' identifier
1219 token = token.next.next; 1219 token = token.next.next;
1220 } 1220 }
1221 } 1221 }
1222 if (optional('<', token.next)) { 1222 if (optional('<', token.next)) {
1223 if (token.next is BeginGroupToken) { 1223 if (token.next is BeginGroupToken) {
1224 BeginGroupToken beginGroup = token.next; 1224 BeginGroupToken beginGroup = token.next;
1225 if (beginGroup.endGroup == null) { 1225 if (beginGroup.endGroup == null) {
1226 reportUnrecoverableError(beginGroup, ErrorKind.UnmatchedToken); 1226 reportUnrecoverableError(beginGroup, ErrorKind.UnmatchedToken);
1227 } else { 1227 } else {
1228 token = beginGroup.endGroup; 1228 token = beginGroup.endGroup;
1229 } 1229 }
1230 } 1230 }
1231 } 1231 }
1232 } 1232 }
1233 token = token.next; 1233 token = token.next;
1234 } 1234 }
1235 return const Link<Token>(); 1235 return listener.handleMemberName(const Link<Token>());
1236 } 1236 }
1237 1237
1238 Token parseFieldInitializerOpt(Token token) { 1238 Token parseFieldInitializerOpt(Token token) {
1239 if (optional('=', token)) { 1239 if (optional('=', token)) {
1240 Token assignment = token; 1240 Token assignment = token;
1241 listener.beginFieldInitializer(token); 1241 listener.beginFieldInitializer(token);
1242 token = parseExpression(token.next); 1242 token = parseExpression(token.next);
1243 listener.endFieldInitializer(assignment); 1243 listener.endFieldInitializer(assignment);
1244 } else { 1244 } else {
1245 listener.handleNoFieldInitializer(token); 1245 listener.handleNoFieldInitializer(token);
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 (identical(value, '.')) || 1478 (identical(value, '.')) ||
1479 (identical(value, '{')) || 1479 (identical(value, '{')) ||
1480 (identical(value, '=>')) || 1480 (identical(value, '=>')) ||
1481 (identical(value, '<'))) { 1481 (identical(value, '<'))) {
1482 isField = false; 1482 isField = false;
1483 break; 1483 break;
1484 } else if (identical(value, ';')) { 1484 } else if (identical(value, ';')) {
1485 if (getOrSet != null) { 1485 if (getOrSet != null) {
1486 // If we found a "get" keyword, this must be an abstract 1486 // If we found a "get" keyword, this must be an abstract
1487 // getter. 1487 // getter.
1488 isField = (!identical(getOrSet.stringValue, 'get')); 1488 isField = !optional("get", getOrSet);
1489 // TODO(ahe): This feels like a hack. 1489 // TODO(ahe): This feels like a hack.
1490 } else { 1490 } else {
1491 isField = true; 1491 isField = true;
1492 } 1492 }
1493 break; 1493 break;
1494 } else if ((identical(value, '=')) || (identical(value, ','))) { 1494 } else if ((identical(value, '=')) || (identical(value, ','))) {
1495 isField = true; 1495 isField = true;
1496 break; 1496 break;
1497 } else { 1497 } else {
1498 token = reportUnrecoverableError(token, ErrorKind.UnexpectedToken); 1498 token = reportUnrecoverableError(token, ErrorKind.UnexpectedToken);
(...skipping 1813 matching lines...) Expand 10 before | Expand all | Expand 10 after
3312 break; 3312 break;
3313 } 3313 }
3314 if (isRecoverable) { 3314 if (isRecoverable) {
3315 listener.handleRecoverableError(token, kind, arguments); 3315 listener.handleRecoverableError(token, kind, arguments);
3316 return null; 3316 return null;
3317 } else { 3317 } else {
3318 return listener.handleUnrecoverableError(token, kind, arguments); 3318 return listener.handleUnrecoverableError(token, kind, arguments);
3319 } 3319 }
3320 } 3320 }
3321 } 3321 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698