Commit f377899e by Aaron Leung

Working on string concatenation. Still need to tweak the emitter.

parent 2b945a09
......@@ -496,6 +496,49 @@ namespace Sass {
acc.pop_back();
acc << new_Node(acc.path(), acc.line(), r, g, b, a);
}
else if (lhs.type() == Node::concatenation && rhs.type() == Node::concatenation) {
if (op == Node::add) {
lhs += rhs;
}
else {
acc << new_Node(op, acc.path(), acc.line(), Token::make());
acc << rhs;
}
}
else if (lhs.type() == Node::concatenation && rhs.type() == Node::string_constant) {
if (op == Node::add) {
lhs << rhs;
}
else {
acc << new_Node(op, acc.path(), acc.line(), Token::make());
acc << rhs;
}
}
else if (lhs.type() == Node::string_constant && rhs.type() == Node::concatenation) {
if (op == Node::add) {
Node new_cat(new_Node(Node::concatenation, lhs.path(), lhs.line(), 1 + rhs.size()));
new_cat << lhs;
new_cat += rhs;
acc.pop_back();
acc << new_cat;
}
else {
acc << new_Node(op, acc.path(), acc.line(), Token::make());
acc << rhs;
}
}
else if (lhs.type() == Node::string_constant && rhs.type() == Node::string_constant) {
if (op == Node::add) {
Node new_cat(new_Node(Node::concatenation, lhs.path(), lhs.line(), 2));
new_cat << lhs << rhs;
acc.pop_back();
acc << new_cat;
}
else {
acc << new_Node(op, acc.path(), acc.line(), Token::make());
acc << rhs;
}
}
else {
// TO DO: disallow division and multiplication on lists
if (op == Node::sub) acc << new_Node(Node::sub, acc.path(), acc.line(), Token::make());
......
......@@ -324,6 +324,14 @@ namespace Sass {
return result;
} break;
case concatenation: {
string result;
for (size_t i = 0, S = size(); i < S; ++i) {
result += at(i).token().unquote();
}
return "\"" + result + "\"";
} break;
case warning: {
string prefix("WARNING: ");
string indent(" ");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment