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

Side by Side Diff: compiler/java/com/google/dart/compiler/parser/DartParser.java

Issue 10545159: Fix for 3607 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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
« no previous file with comments | « no previous file | compiler/javatests/com/google/dart/compiler/parser/SyntaxTest.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 package com.google.dart.compiler.parser; 5 package com.google.dart.compiler.parser;
6 6
7 import com.google.common.annotations.VisibleForTesting; 7 import com.google.common.annotations.VisibleForTesting;
8 import com.google.common.collect.ImmutableSet; 8 import com.google.common.collect.ImmutableSet;
9 import com.google.common.io.CharStreams; 9 import com.google.common.io.CharStreams;
10 import com.google.dart.compiler.DartCompilationError; 10 import com.google.dart.compiler.DartCompilationError;
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 reportError(name, ParserErrorCode.FUNCTION_NAME_EXPECTED_IDENTIFIER); 1360 reportError(name, ParserErrorCode.FUNCTION_NAME_EXPECTED_IDENTIFIER);
1361 } 1361 }
1362 if (optional(Token.PERIOD)) { 1362 if (optional(Token.PERIOD)) {
1363 name = doneWithoutConsuming(new DartPropertyAccess(name, parseIdentifi er())); 1363 name = doneWithoutConsuming(new DartPropertyAccess(name, parseIdentifi er()));
1364 } 1364 }
1365 } 1365 }
1366 done(null); 1366 done(null);
1367 } 1367 }
1368 1368
1369 // Parse the parameters definitions. 1369 // Parse the parameters definitions.
1370 List<DartParameter> parameters = parseFormalParameterList(); 1370 List<DartParameter> parameters;
1371 if (modifiers.isGetter() && peek(0) != Token.LPAREN) {
1372 // TODO: For now the parameters are optional so that both the old and new style will be
1373 // accepted, but eventually parameters should be disallowed.
1374 parameters = new ArrayList<DartParameter>();
1375 } else {
1376 if (modifiers.isSetter()) {
1377 // TODO: For now we optionally allow an equal sign before the formal par ameter list, but
1378 // eventually it should be required.
1379 optional(Token.ASSIGN);
1380 }
1381 parameters = parseFormalParameterList();
1382 }
1371 1383
1372 if (arity != -1) { 1384 if (arity != -1) {
1373 if (parameters.size() != arity) { 1385 if (parameters.size() != arity) {
1374 reportError(position(), ParserErrorCode.ILLEGAL_NUMBER_OF_PARAMETERS); 1386 reportError(position(), ParserErrorCode.ILLEGAL_NUMBER_OF_PARAMETERS);
1375 } 1387 }
1376 // In methods with required arity each parameter is required. 1388 // In methods with required arity each parameter is required.
1377 for (DartParameter parameter : parameters) { 1389 for (DartParameter parameter : parameters) {
1378 if (parameter.getModifiers().isNamed()) { 1390 if (parameter.getModifiers().isNamed()) {
1379 reportError(parameter, ParserErrorCode.NAMED_PARAMETER_NOT_ALLOWED); 1391 reportError(parameter, ParserErrorCode.NAMED_PARAMETER_NOT_ALLOWED);
1380 } 1392 }
(...skipping 2931 matching lines...) Expand 10 before | Expand all | Expand 10 after
4312 } 4324 }
4313 4325
4314 private void reportError(DartNode node, ErrorCode errorCode, Object... argumen ts) { 4326 private void reportError(DartNode node, ErrorCode errorCode, Object... argumen ts) {
4315 reportError(new DartCompilationError(node, errorCode, arguments)); 4327 reportError(new DartCompilationError(node, errorCode, arguments));
4316 } 4328 }
4317 4329
4318 private boolean currentlyParsingToplevel() { 4330 private boolean currentlyParsingToplevel() {
4319 return !(isParsingInterface || isTopLevelAbstract || isParsingClass); 4331 return !(isParsingInterface || isTopLevelAbstract || isParsingClass);
4320 } 4332 }
4321 } 4333 }
OLDNEW
« no previous file with comments | « no previous file | compiler/javatests/com/google/dart/compiler/parser/SyntaxTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698