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

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: No entries in language.status, vm and dartc already implemented 'as'. 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 08b77c2665c205dfeb0409ac4be638fb6f75859b..dbe9c6ff7512186245112026fa292ef9334be101 100644
--- a/lib/compiler/implementation/scanner/parser.dart
+++ b/lib/compiler/implementation/scanner/parser.dart
@@ -934,6 +934,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 {
@@ -1376,14 +1378,28 @@ 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
+ String value = token.stringValue;
+ if (value === 'is' || value === 'as') {
+ // 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);
+ String value = token.stringValue;
+ if (value === 'is' || value === 'as') {
+ // 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