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

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

Issue 2778213002: Use message.yaml in parser. (Closed)
Patch Set: Update subpackage relationships. Created 3 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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.body_builder; 5 library fasta.body_builder;
6 6
7 import '../fasta_codes.dart'
8 show FastaMessage, codeExpectedButGot, codeExpectedFunctionBody;
9
7 import '../parser/parser.dart' show FormalParameterType, optional; 10 import '../parser/parser.dart' show FormalParameterType, optional;
8 11
9 import '../parser/error_kind.dart' show ErrorKind;
10
11 import '../parser/identifier_context.dart' show IdentifierContext; 12 import '../parser/identifier_context.dart' show IdentifierContext;
12 13
13 import 'package:kernel/ast.dart'; 14 import 'package:kernel/ast.dart';
14 15
15 import 'package:kernel/clone.dart' show CloneVisitor; 16 import 'package:kernel/clone.dart' show CloneVisitor;
16 17
17 import 'package:kernel/transformations/flags.dart' show TransformerFlag; 18 import 'package:kernel/transformations/flags.dart' show TransformerFlag;
18 19
19 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy; 20 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy;
20 21
(...skipping 2315 matching lines...) Expand 10 before | Expand all | Expand 10 after
2336 } 2337 }
2337 2338
2338 @override 2339 @override
2339 void handleModifiers(int count) { 2340 void handleModifiers(int count) {
2340 debugEvent("Modifiers"); 2341 debugEvent("Modifiers");
2341 // TODO(ahe): Copied from outline_builder.dart. 2342 // TODO(ahe): Copied from outline_builder.dart.
2342 push(popList(count) ?? NullValue.Modifiers); 2343 push(popList(count) ?? NullValue.Modifiers);
2343 } 2344 }
2344 2345
2345 @override 2346 @override
2346 void handleRecoverableError(Token token, ErrorKind kind, Map arguments) { 2347 void handleRecoverableError(Token token, FastaMessage message) {
2347 bool silent = hasParserError; 2348 bool silent = hasParserError;
2348 super.handleRecoverableError(token, kind, arguments); 2349 super.handleRecoverableError(token, message);
2349 addCompileTimeError(recoverableErrors.last.beginOffset, 2350 addCompileTimeError(message.charOffset, message.message, silent: silent);
2350 '${recoverableErrors.last.kind} $arguments',
2351 silent: silent);
2352 } 2351 }
2353 2352
2354 @override 2353 @override
2355 Token handleUnrecoverableError(Token token, ErrorKind kind, Map arguments) { 2354 Token handleUnrecoverableError(Token token, FastaMessage message) {
2356 if (isDartLibrary && kind == ErrorKind.ExpectedFunctionBody) { 2355 if (isDartLibrary && message.code == codeExpectedFunctionBody) {
2357 Token recover = skipNativeClause(token); 2356 Token recover = skipNativeClause(token);
2358 if (recover != null) return recover; 2357 if (recover != null) return recover;
2359 } else if (kind == ErrorKind.UnexpectedToken) { 2358 } else if (message.code == codeExpectedButGot) {
2360 String expected = arguments["expected"]; 2359 String expected = message.arguments["string"];
2361 const List<String> trailing = const <String>[")", "}", ";", ","]; 2360 const List<String> trailing = const <String>[")", "}", ";", ","];
2362 if (trailing.contains(token.stringValue) && trailing.contains(expected)) { 2361 if (trailing.contains(token.stringValue) && trailing.contains(expected)) {
2363 arguments.putIfAbsent("actual", () => token.lexeme); 2362 handleRecoverableError(token, message);
2364 handleRecoverableError(token, ErrorKind.ExpectedButGot, arguments);
2365 return newSyntheticToken(token); 2363 return newSyntheticToken(token);
2366 } 2364 }
2367 } 2365 }
2368 return super.handleUnrecoverableError(token, kind, arguments); 2366 return super.handleUnrecoverableError(token, message);
2369 } 2367 }
2370 2368
2371 @override 2369 @override
2372 Expression buildCompileTimeError(error, [int charOffset = -1]) { 2370 Expression buildCompileTimeError(error, [int charOffset = -1]) {
2373 addCompileTimeError(charOffset, error); 2371 addCompileTimeError(charOffset, error);
2374 String message = formatUnexpected(uri, charOffset, error); 2372 String message = formatUnexpected(uri, charOffset, error);
2375 Builder constructor = library.loader.getCompileTimeError(); 2373 Builder constructor = library.loader.getCompileTimeError();
2376 return new Throw(buildStaticInvocation(constructor.target, 2374 return new Throw(buildStaticInvocation(constructor.target,
2377 new Arguments(<Expression>[new StringLiteral(message)]))); 2375 new Arguments(<Expression>[new StringLiteral(message)])));
2378 } 2376 }
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
2926 } else if (node is PrefixBuilder) { 2924 } else if (node is PrefixBuilder) {
2927 return node.name; 2925 return node.name;
2928 } else if (node is ThisAccessor) { 2926 } else if (node is ThisAccessor) {
2929 return node.isSuper ? "super" : "this"; 2927 return node.isSuper ? "super" : "this";
2930 } else if (node is FastaAccessor) { 2928 } else if (node is FastaAccessor) {
2931 return node.plainNameForRead; 2929 return node.plainNameForRead;
2932 } else { 2930 } else {
2933 return internalError("Unhandled: ${node.runtimeType}"); 2931 return internalError("Unhandled: ${node.runtimeType}");
2934 } 2932 }
2935 } 2933 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/fasta_codes_generated.dart ('k') | pkg/front_end/lib/src/fasta/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698