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

Unified Diff: compiler/java/com/google/dart/compiler/parser/DartParser.java

Issue 10834334: Support unary minus operator (issue 3767) (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | compiler/javatests/com/google/dart/compiler/parser/SyntaxTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/java/com/google/dart/compiler/parser/DartParser.java
===================================================================
--- compiler/java/com/google/dart/compiler/parser/DartParser.java (revision 10739)
+++ compiler/java/com/google/dart/compiler/parser/DartParser.java (working copy)
@@ -1459,6 +1459,7 @@
}
int arity = -1;
+ Token operation = null;
if (peek(1) != Token.LPAREN && optionalPseudoKeyword(OPERATOR_KEYWORD)) {
// Overloaded operator.
if (modifiers.isStatic()) {
@@ -1467,11 +1468,13 @@
modifiers = modifiers.makeOperator();
beginOperatorName();
- Token operation = next();
+ operation = next();
if (operation.isUserDefinableOperator()) {
name = done(new DartIdentifier(operation.getSyntax()));
if (operation == Token.ASSIGN_INDEX) {
arity = 2;
+ } else if (operation == Token.SUB) {
+ arity = -1;
} else if (operation.isBinaryOperator()) {
arity = 1;
} else if (operation == Token.INDEX) {
@@ -1571,6 +1574,16 @@
reportError(parameter, ParserErrorCode.NAMED_PARAMETER_NOT_ALLOWED);
}
}
+ } else if (operation == Token.SUB) {
+ if (parameters.size() != 0 && parameters.size() != 1) {
+ reportError(position(), ParserErrorCode.ILLEGAL_NUMBER_OF_PARAMETERS);
+ }
+ // In methods with required arity each parameter is required.
+ for (DartParameter parameter : parameters) {
+ if (parameter.getModifiers().isNamed()) {
+ reportError(parameter, ParserErrorCode.NAMED_PARAMETER_NOT_ALLOWED);
+ }
+ }
}
// Parse initializer expressions for constructors.
« 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