Chromium Code Reviews| Index: frog/leg/scanner/parser.dart |
| diff --git a/frog/leg/scanner/parser.dart b/frog/leg/scanner/parser.dart |
| index b911d1d82de61e55a730522eafd15e6ae539613f..26413dfb3296c10ea833909beb7c2de3388b597d 100644 |
| --- a/frog/leg/scanner/parser.dart |
| +++ b/frog/leg/scanner/parser.dart |
| @@ -942,10 +942,22 @@ class Parser { |
| Token parseUnaryExpression(Token token) { |
| String value = token.stringValue; |
| // Prefix: |
| - if ((value === '!') || |
| - (value === '+') || // TODO(ahe): Being removed from specification. |
| - (value === '-') || |
| - (value === '~')) { |
| + if (value === '+') { |
| + // Dart only allows "prefix plus" as an initial part of a |
| + // decimal literal. We scan it as a separate token and then throw |
| + // it away here when we know that we have a unary plus, not a |
|
ahe
2012/02/03 13:19:11
We are not throwing it away anymore :-)
|
| + // binary one. |
| + Token operator = token; |
| + Token next = token.next; |
| + if (next.charOffset !== token.charOffset + 1 || |
| + (next.kind !== INT_TOKEN && next.kind !== DOUBLE_TOKEN)) { |
| + listener.recoverableError("Unexpected token '+'", token: token); |
| + } |
| + token = parsePrecedenceExpression(next, POSTFIX_PRECEDENCE); |
| + listener.handleUnaryPrefixExpression(operator); |
| + } else if ((value === '!') || |
| + (value === '-') || |
| + (value === '~')) { |
| Token operator = token; |
| // Right associative, so we recurse at the same precedence |
| // level. |