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

Unified Diff: frog/leg/scanner/listener.dart

Issue 9642001: Make string juxtaposition combine properly with string interpolations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix typo Created 8 years, 9 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: frog/leg/scanner/listener.dart
diff --git a/frog/leg/scanner/listener.dart b/frog/leg/scanner/listener.dart
index 501f753c5b8dac25f60b2f003f8a1c6c269cde99..4d6d6a5fad1ddf2697b948689f33e6da40d662d8 100644
--- a/frog/leg/scanner/listener.dart
+++ b/frog/leg/scanner/listener.dart
@@ -170,7 +170,7 @@ class Listener {
void endLiteralString(int interpolationCount) {
}
- void handleLiteralStringJuxtaposition(int literalCount) {
+ void handleStringJuxtaposition(int literalCount) {
}
void beginMember(Token token) {
@@ -512,21 +512,27 @@ class ElementListener extends Listener {
LiteralString popLiteralString() {
Node node = popNode();
- if (node is !LiteralString) {
+ if (node is !StringNode) {
listener.cancel("String is not a compile time constant", node: node);
return null;
}
+ StringNode stringNode = node;
+ // TODO(lrn): Handle interpolations in script tags.
+ if (node.isInterpolation) {
+ listener.cancel("String is a string-interpolation", node: node);
+ return null;
+ }
return node;
}
void endScriptTag(bool hasPrefix, Token beginToken, Token endToken) {
- LiteralString prefix = null;
+ StringNode prefix = null;
Identifier argumentName = null;
if (hasPrefix) {
prefix = popLiteralString();
argumentName = popNode();
}
- LiteralString firstArgument = popLiteralString();
+ StringNode firstArgument = popLiteralString();
Identifier tag = popNode();
compilationUnitElement.addTag(new ScriptTag(tag, firstArgument,
argumentName, prefix,
@@ -849,14 +855,16 @@ class ElementListener extends Listener {
}
}
- void handleLiteralStringJuxtaposition(int literalCount) {
- Link<Expression> literals = const EmptyLink<Expression>();
- while (literalCount > 0) {
+ void handleStringJuxtaposition(int stringCount) {
+ assert(stringCount != 0);
+ Expression accumulator = popNode();
+ stringCount -= 1;
+ while (stringCount > 0) {
Expression expression = popNode();
- literals = literals.prepend(expression);
- literalCount -= 1;
+ accumulator = new StringJuxtaposition(expression, accumulator);
+ stringCount -= 1;
}
- pushNode(new LiteralStringJuxtaposition(literals));
+ pushNode(accumulator);
}
}

Powered by Google App Engine
This is Rietveld 408576698