Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 '../parser/parser.dart' show FormalParameterType, optional; | 7 import '../parser/parser.dart' show FormalParameterType, optional; |
| 8 | 8 |
| 9 import '../parser/error_kind.dart' show ErrorKind; | 9 import '../parser/error_kind.dart' show ErrorKind; |
| 10 | 10 |
| (...skipping 2173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2184 printUnexpected(uri, recoverableErrors.last.beginOffset, | 2184 printUnexpected(uri, recoverableErrors.last.beginOffset, |
| 2185 '${recoverableErrors.last.kind}'); | 2185 '${recoverableErrors.last.kind}'); |
| 2186 } | 2186 } |
| 2187 hasParserError = true; | 2187 hasParserError = true; |
| 2188 } | 2188 } |
| 2189 | 2189 |
| 2190 @override | 2190 @override |
| 2191 Token handleUnrecoverableError(Token token, ErrorKind kind, Map arguments) { | 2191 Token handleUnrecoverableError(Token token, ErrorKind kind, Map arguments) { |
| 2192 if (isDartLibrary && kind == ErrorKind.ExpectedFunctionBody) { | 2192 if (isDartLibrary && kind == ErrorKind.ExpectedFunctionBody) { |
| 2193 Token recover = skipNativeClause(token); | 2193 Token recover = skipNativeClause(token); |
| 2194 if (recover != null) return recover; | 2194 if (recover != null) return newSyntheticToken(recover); |
|
ahe
2017/03/09 12:08:39
I think we should modify skipNativeClause instead.
Paul Berry
2017/03/09 21:51:21
Done.
| |
| 2195 } else if (kind == ErrorKind.UnexpectedToken) { | 2195 } else if (kind == ErrorKind.UnexpectedToken) { |
| 2196 String expected = arguments["expected"]; | 2196 String expected = arguments["expected"]; |
| 2197 const List<String> trailing = const <String>[")", "}", ";", ","]; | 2197 const List<String> trailing = const <String>[")", "}", ";", ","]; |
| 2198 if (trailing.contains(token.stringValue) && trailing.contains(expected)) { | 2198 if (trailing.contains(token.stringValue) && trailing.contains(expected)) { |
| 2199 arguments.putIfAbsent("actual", () => token.value); | 2199 arguments.putIfAbsent("actual", () => token.value); |
| 2200 handleRecoverableError(token, ErrorKind.ExpectedButGot, arguments); | 2200 handleRecoverableError(token, ErrorKind.ExpectedButGot, arguments); |
| 2201 } | 2201 } |
| 2202 return token; | 2202 return newSyntheticToken(token); |
|
ahe
2017/03/09 12:08:39
FYI: Expect an easy conflict here. The return stat
Paul Berry
2017/03/09 21:51:21
Thanks for the heads up.
| |
| 2203 } | 2203 } |
| 2204 return super.handleUnrecoverableError(token, kind, arguments); | 2204 return super.handleUnrecoverableError(token, kind, arguments); |
| 2205 } | 2205 } |
| 2206 | 2206 |
| 2207 @override | 2207 @override |
| 2208 Expression buildCompileTimeError(error, [int charOffset = -1]) { | 2208 Expression buildCompileTimeError(error, [int charOffset = -1]) { |
| 2209 String message = printUnexpected(uri, charOffset, error); | 2209 String message = printUnexpected(uri, charOffset, error); |
| 2210 Builder constructor = library.loader.getCompileTimeError(); | 2210 Builder constructor = library.loader.getCompileTimeError(); |
| 2211 return new Throw(buildStaticInvocation(constructor.target, | 2211 return new Throw(buildStaticInvocation(constructor.target, |
| 2212 new Arguments(<Expression>[new StringLiteral(message)]), | 2212 new Arguments(<Expression>[new StringLiteral(message)]), |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2692 } else if (node is TypeDeclarationBuilder) { | 2692 } else if (node is TypeDeclarationBuilder) { |
| 2693 return node.name; | 2693 return node.name; |
| 2694 } else if (node is PrefixBuilder) { | 2694 } else if (node is PrefixBuilder) { |
| 2695 return node.name; | 2695 return node.name; |
| 2696 } else if (node is ThisPropertyAccessor) { | 2696 } else if (node is ThisPropertyAccessor) { |
| 2697 return node.name.name; | 2697 return node.name.name; |
| 2698 } else { | 2698 } else { |
| 2699 return internalError("Unhandled: ${node.runtimeType}"); | 2699 return internalError("Unhandled: ${node.runtimeType}"); |
| 2700 } | 2700 } |
| 2701 } | 2701 } |
| OLD | NEW |