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

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

Issue 10540048: Implement 'as' operator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update semantics to not throw on null. Merge to head. 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 side-by-side diff with in-line comments
Download patch
Index: lib/compiler/implementation/scanner/parser.dart
diff --git a/lib/compiler/implementation/scanner/parser.dart b/lib/compiler/implementation/scanner/parser.dart
index a05394afc82917494cd902b29b25cc4df3dcb7eb..548e8d295f29d76260ceabd115b1d131317db508 100644
--- a/lib/compiler/implementation/scanner/parser.dart
+++ b/lib/compiler/implementation/scanner/parser.dart
@@ -931,6 +931,8 @@ class Parser {
}
} else if (info === IS_INFO) {
token = parseIsOperatorRest(token);
+ } else if (info === AS_INFO) {
+ token = parseAsOperatorRest(token);
} else if (info === QUESTION_INFO) {
token = parseConditionalExpressionRest(token);
} else {
@@ -1357,14 +1359,26 @@ class Parser {
}
token = parseType(token.next);
listener.handleIsOperator(operator, not, token);
- if (optional('is', token)) {
- // The is-operator cannot be chained, but it can take part of
+ if (optional('is', token) || optional('as', token)) {
ahe 2012/06/25 10:36:56 Please put stringValue in a local variable instead
Lasse Reichstein Nielsen 2012/06/25 11:20:06 Done.
+ // The is- and as-operators cannot be chained, but they can take part of
// expressions like: foo is Foo || foo is Bar.
listener.unexpected(token);
}
return token;
}
+ Token parseAsOperatorRest(Token token) {
+ assert(optional('as', token));
+ Token operator = token;
+ token = parseType(token.next);
+ listener.handleAsOperator(operator, token);
+ if (optional('is', token) || optional('as', token)) {
ahe 2012/06/25 10:36:56 Ditto.
Lasse Reichstein Nielsen 2012/06/25 11:20:06 Done.
+ // The is- and as-operators cannot be chained.
+ listener.unexpected(token);
+ }
+ return token;
+ }
+
Token parseVariablesDeclaration(Token token) {
token = parseVariablesDeclarationNoSemicolon(token);
return expectSemicolon(token);

Powered by Google App Engine
This is Rietveld 408576698