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

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: 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
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/scanner/token.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..5cb6b1337ed20125d42725b7ce09f693874d549b 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;
@@ -1622,25 +1628,7 @@ class Parser {
Token parseUnaryExpression(Token token, bool allowCascades) {
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);
Lasse Reichstein Nielsen 2013/09/18 13:41:19 WOuld it be better to keep the 'if' and the last t
ahe 2013/09/18 13:42:59 Yes. And it would be even better if you replace li
- } else if ((identical(value, '!')) ||
+ if ((identical(value, '!')) ||
(identical(value, '-')) ||
(identical(value, '~'))) {
Token operator = token;
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/scanner/token.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698