Chromium Code Reviews| Index: lib/compiler/implementation/scanner/parser.dart |
| diff --git a/lib/compiler/implementation/scanner/parser.dart b/lib/compiler/implementation/scanner/parser.dart |
| index f43bddc1f2c4955d7476e928f87da1d11bc1d80e..3e8a382e6d14965b0cde62e8a8ffea875e5d4ef4 100644 |
| --- a/lib/compiler/implementation/scanner/parser.dart |
| +++ b/lib/compiler/implementation/scanner/parser.dart |
| @@ -278,6 +278,9 @@ class Parser { |
| return token; |
| } |
| + /** |
| + * Returns true if the stringValue of the [token] is [value]. |
| + */ |
| bool optional(String value, Token token) => value === token.stringValue; |
| bool notEofOrValue(String value, Token token) { |
| @@ -1283,12 +1286,25 @@ class Parser { |
| listener.beginLiteralString(token); |
| token = token.next; |
| int interpolationCount = 0; |
| - while (optional('\${', token)) { |
| - token = token.next; |
| - token = parseExpression(token); |
| - token = expect('}', token); |
| - token = parseStringPart(token); |
| - ++interpolationCount; |
| + var tokenKind = token.kind; |
|
ahe
2012/06/25 08:12:37
In other places I have used:
var kind = token.kin
Johnni Winther
2012/06/25 10:40:00
Done.
|
| + while (tokenKind != EOF_TOKEN) { |
| + if (tokenKind === STRING_INTERPOLATION_TOKEN) { |
| + // Parsing ${expression}. |
| + token = token.next; |
| + token = parseExpression(token); |
| + token = expect('}', token); |
| + token = parseStringPart(token); |
|
ahe
2012/06/25 08:12:37
The last two lines can be shared.
Johnni Winther
2012/06/25 10:40:00
Done.
|
| + ++interpolationCount; |
| + } else if (tokenKind === STRING_INTERPOLATION_IDENTIFIER_TOKEN) { |
| + // Parsing $identifier. |
| + token = token.next; |
| + token = parseExpression(token); |
| + token = parseStringPart(token); |
| + ++interpolationCount; |
| + } else { |
| + break; |
| + } |
| + tokenKind = token.kind; |
| } |
| listener.endLiteralString(interpolationCount); |
| return token; |