Index: pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart |
diff --git a/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart b/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart |
index 8b88326a6a9b0d4d641889a213011a45969d631c..0468576a6dc9bde1346aa82bb48ba9ea11b6bd56 100644 |
--- a/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart |
+++ b/pkg/front_end/lib/src/fasta/scanner/abstract_scanner.dart |
@@ -34,6 +34,14 @@ abstract class AbstractScanner implements Scanner { |
bool scanGenericMethodComments = false; |
/** |
+ * A flag indicating whether the lazy compound assignment operators '&&=' and |
+ * '||=' are enabled. |
+ */ |
+ // TODO(paulberry): once lazyAssignmentOperators are fully supported by |
+ // Dart, remove this flag. |
+ bool scanLazyAssignmentOperators = false; |
ahe
2017/05/22 11:37:38
Why are we adding this flag?
danrubel
2017/05/23 11:33:40
AFAIK, the language does not yet support lazy assi
ahe
2017/05/23 11:46:08
I don't think the flag is necessary. The parser wi
|
+ |
+ /** |
* The string offset for the next token that will be created. |
* |
* Note that in the [Utf8BytesScanner], [stringOffset] and [scanOffset] values |
@@ -71,6 +79,7 @@ abstract class AbstractScanner implements Scanner { |
final List<int> lineStarts; |
AbstractScanner(this.includeComments, this.scanGenericMethodComments, |
+ this.scanLazyAssignmentOperators, |
{int numberOfBytesHint}) |
: lineStarts = new LineStarts(numberOfBytesHint) { |
this.tail = this.tokens; |
@@ -486,11 +495,16 @@ abstract class AbstractScanner implements Scanner { |
} |
int tokenizeBar(int next) { |
- // | || |= |
+ // | || |= ||= |
next = advance(); |
if (identical(next, $BAR)) { |
+ next = advance(); |
+ if (scanLazyAssignmentOperators && identical(next, $EQ)) { |
+ appendPrecedenceToken(TokenType.BAR_BAR_EQ); |
+ return advance(); |
+ } |
appendPrecedenceToken(TokenType.BAR_BAR); |
- return advance(); |
+ return next; |
} else if (identical(next, $EQ)) { |
appendPrecedenceToken(TokenType.BAR_EQ); |
return advance(); |
@@ -501,11 +515,16 @@ abstract class AbstractScanner implements Scanner { |
} |
int tokenizeAmpersand(int next) { |
- // && &= & |
+ // && &= & &&= |
next = advance(); |
if (identical(next, $AMPERSAND)) { |
+ next = advance(); |
+ if (scanLazyAssignmentOperators && identical(next, $EQ)) { |
+ appendPrecedenceToken(TokenType.AMPERSAND_AMPERSAND_EQ); |
+ return advance(); |
+ } |
appendPrecedenceToken(TokenType.AMPERSAND_AMPERSAND); |
- return advance(); |
+ return next; |
} else if (identical(next, $EQ)) { |
appendPrecedenceToken(TokenType.AMPERSAND_EQ); |
return advance(); |