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

Side by Side Diff: dart/lib/compiler/implementation/scanner/listener.dart

Issue 11092101: Diagnose unbalanced parentheses better. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
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 const bool VERBOSE = false; 5 const bool VERBOSE = false;
6 6
7 /** 7 /**
8 * A parser event listener that does nothing except throw exceptions 8 * A parser event listener that does nothing except throw exceptions
9 * on parser errors. 9 * on parser errors.
10 */ 10 */
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 } 931 }
932 932
933 Token expectedExpression(Token token) { 933 Token expectedExpression(Token token) {
934 listener.cancel("expected an expression, but got '${token.slowToString()}'", 934 listener.cancel("expected an expression, but got '${token.slowToString()}'",
935 token: token); 935 token: token);
936 pushNode(null); 936 pushNode(null);
937 return skipToEof(token); 937 return skipToEof(token);
938 } 938 }
939 939
940 Token unexpected(Token token) { 940 Token unexpected(Token token) {
941 listener.cancel("unexpected token '${token.slowToString()}'", token: token); 941 String message = "unexpected token '${token.slowToString()}'";
942 if (token.info == BAD_INPUT_INFO) {
943 message = token.stringValue;
944 }
945 listener.cancel(message, token: token);
942 return skipToEof(token); 946 return skipToEof(token);
943 } 947 }
944 948
945 Token expectedBlockToSkip(Token token) { 949 Token expectedBlockToSkip(Token token) {
946 if (token.stringValue === 'native') { 950 if (token.stringValue === 'native') {
947 return native.handleNativeBlockToSkip(this, token); 951 return native.handleNativeBlockToSkip(this, token);
948 } else { 952 } else {
949 return unexpected(token); 953 return unexpected(token);
950 } 954 }
951 } 955 }
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 1870
1867 Node parse(DiagnosticListener diagnosticListener, 1871 Node parse(DiagnosticListener diagnosticListener,
1868 CompilationUnitElement element, 1872 CompilationUnitElement element,
1869 doParse(Parser parser)) { 1873 doParse(Parser parser)) {
1870 NodeListener listener = new NodeListener(diagnosticListener, element); 1874 NodeListener listener = new NodeListener(diagnosticListener, element);
1871 doParse(new Parser(listener)); 1875 doParse(new Parser(listener));
1872 Node node = listener.popNode(); 1876 Node node = listener.popNode();
1873 assert(listener.nodes.isEmpty()); 1877 assert(listener.nodes.isEmpty());
1874 return node; 1878 return node;
1875 } 1879 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698