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

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

Issue 10539021: Scanner can include comments in the token stream. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: String interpolation identifier used new token 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 f43bddc1f2c4955d7476e928f87da1d11bc1d80e..eb75bb43398602d5d0f8d0328ae07e75796aee81 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,23 @@ 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;
+ while (token.kind != EOF_TOKEN) {
+ if (optional('\${', token)) {
+ // Parsing ${expression}.
+ token = token.next;
+ token = parseExpression(token);
+ token = expect('}', token);
+ token = parseStringPart(token);
+ ++interpolationCount;
+ } else if (token.kind == STRING_INTERPOLATION_IDENTIFIER_TOKEN) {
+ // Parsing $identifier.
+ token = token.next;
+ token = parseExpression(token);
+ token = parseStringPart(token);
+ ++interpolationCount;
+ } else {
+ break;
+ }
}
listener.endLiteralString(interpolationCount);
return token;

Powered by Google App Engine
This is Rietveld 408576698