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

Unified Diff: sdk/lib/_internal/compiler/implementation/scanner/parser.dart

Issue 23450044: Update dart2js parser to disallow repeated comparisons and prefix +. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Correct arguments for reportError. Created 7 years, 3 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
Index: sdk/lib/_internal/compiler/implementation/scanner/parser.dart
diff --git a/sdk/lib/_internal/compiler/implementation/scanner/parser.dart b/sdk/lib/_internal/compiler/implementation/scanner/parser.dart
index 63e7da7a422e1244f7b3bbb062c99615361ba082..05b1acfe4e85acc588c1dbb7655338612e280638 100644
--- a/sdk/lib/_internal/compiler/implementation/scanner/parser.dart
+++ b/sdk/lib/_internal/compiler/implementation/scanner/parser.dart
@@ -1581,6 +1581,12 @@ class Parser {
}
info = token.info;
tokenLevel = info.precedence;
+ if (level == EQUALITY_PRECEDENCE || level == RELATIONAL_PRECEDENCE) {
+ // We don't allow (a == b == c) or (a < b < c).
+ // Continue the outer loop if we have matched one equality or
+ // relational operator.
+ break;
+ }
}
}
return token;
@@ -1623,23 +1629,8 @@ class Parser {
String value = token.stringValue;
// Prefix:
if (identical(value, '+')) {
- // Dart only allows "prefix plus" as an initial part of a
- // decimal literal. We scan it as a separate token and let
- // the parser listener combine it with the digits.
- Token next = token.next;
- if (identical(next.charOffset, token.charOffset + 1)) {
- if (identical(next.kind, INT_TOKEN)) {
- listener.handleLiteralInt(token);
- return next.next;
- }
- if (identical(next.kind, DOUBLE_TOKEN)) {
- listener.handleLiteralDouble(token);
- return next.next;
- }
- }
- listener.recoverableError("Unexpected token '+'", token: token);
- return parsePrecedenceExpression(next, POSTFIX_PRECEDENCE,
- allowCascades);
+ // Dart no longer allows prefix-plus.
+ listener.reportError(token, MessageKind.UNSUPPORTED_PREFIX_PLUS);
} else if ((identical(value, '!')) ||
(identical(value, '-')) ||
(identical(value, '~'))) {

Powered by Google App Engine
This is Rietveld 408576698