Commit bff3e4e2 by Aaron Leung

Little tweaks. Some concatenations are still erroneously quoted, but that can be…

Little tweaks. Some concatenations are still erroneously quoted, but that can be easily worked around for the time being with the 'unquote' built-in.
parent 6eb7c4ed
...@@ -512,10 +512,18 @@ namespace Sass { ...@@ -512,10 +512,18 @@ namespace Sass {
if (optype != Node::add) acc << op; if (optype != Node::add) acc << op;
acc << rhs; acc << rhs;
} }
else if (acc.is_string()) { else if (rtype == Node::concatenation) {
acc = (new_Node(Node::concatenation, list.path(), list.line(), 2) << acc);
acc += rhs;
acc.is_quoted() = acc[0].is_quoted();
acc.is_unquoted() = acc[0].is_unquoted();
}
else if (acc.is_string() || rhs.is_string()) {
acc = (new_Node(Node::concatenation, list.path(), list.line(), 2) << acc); acc = (new_Node(Node::concatenation, list.path(), list.line(), 2) << acc);
if (optype != Node::add) acc << op; if (optype != Node::add) acc << op;
acc << rhs; acc << rhs;
acc.is_quoted() = acc[0].is_quoted();
acc.is_unquoted() = acc[0].is_unquoted();
} }
else if (ltype == Node::number && rtype == Node::number) { else if (ltype == Node::number && rtype == Node::number) {
acc = new_Node(list.path(), list.line(), operate(op, acc.numeric_value(), rhs.numeric_value())); acc = new_Node(list.path(), list.line(), operate(op, acc.numeric_value(), rhs.numeric_value()));
...@@ -544,9 +552,11 @@ namespace Sass { ...@@ -544,9 +552,11 @@ namespace Sass {
acc = new_Node(list.path(), list.line(), r, g, b, a); acc = new_Node(list.path(), list.line(), r, g, b, a);
} }
else { else {
acc = (new_Node(Node::concatenation, list.path(), list.line(), 3) << acc); acc = (new_Node(Node::value_schema, list.path(), list.line(), 3) << acc);
acc << op; acc << op;
acc << rhs; acc << rhs;
acc.is_quoted() = false;
acc.is_unquoted() = true;
} }
} }
else if (ltype == Node::numeric_color && rtype == Node::number) { else if (ltype == Node::numeric_color && rtype == Node::number) {
...@@ -564,15 +574,27 @@ namespace Sass { ...@@ -564,15 +574,27 @@ namespace Sass {
double a = acc[3].numeric_value(); double a = acc[3].numeric_value();
acc = new_Node(list.path(), list.line(), r, g, b, a); acc = new_Node(list.path(), list.line(), r, g, b, a);
} }
else { // two lists else { // lists or schemas
if (optype != Node::mul) { if (acc.is_schema() && rhs.is_schema()) {
acc = (new_Node(Node::value_schema, list.path(), list.line(), 2) << acc); if (optype != Node::add) acc << op;
acc += rhs;
}
else if (acc.is_schema()) {
if (optype != Node::add) acc << op; if (optype != Node::add) acc << op;
acc << rhs; acc << rhs;
} }
else if (rhs.is_schema()) {
acc = (new_Node(Node::value_schema, list.path(), list.line(), 2) << acc);
if (optype != Node::add) acc << op;
acc += rhs;
}
else { else {
throw_eval_error("cannot multiply lists", op.path(), op.line()); acc = (new_Node(Node::value_schema, list.path(), list.line(), 2) << acc);
if (optype != Node::add) acc << op;
acc << rhs;
} }
acc.is_quoted() = false;
acc.is_unquoted() = true;
} }
return reduce(list, head + 2, acc, new_Node); return reduce(list, head + 2, acc, new_Node);
} }
......
...@@ -194,6 +194,7 @@ namespace Sass { ...@@ -194,6 +194,7 @@ namespace Sass {
bool& is_quoted() const; // for identifiers bool& is_quoted() const; // for identifiers
bool is_numeric() const; bool is_numeric() const;
bool is_string() const; // for all string-like types bool is_string() const; // for all string-like types
bool is_schema() const; // for all interpolated data
bool is_guarded() const; bool is_guarded() const;
bool& has_been_extended() const; bool& has_been_extended() const;
bool is_false() const; bool is_false() const;
...@@ -315,6 +316,24 @@ namespace Sass { ...@@ -315,6 +316,24 @@ namespace Sass {
return false; return false;
} }
bool is_schema()
{
switch (type)
{
case Node::selector_schema:
case Node::value_schema:
case Node::string_schema:
case Node::identifier_schema: {
return true;
} break;
default: {
return false;
} break;
}
return false;
}
size_t size() size_t size()
{ return children.size(); } { return children.size(); }
...@@ -428,6 +447,7 @@ namespace Sass { ...@@ -428,6 +447,7 @@ namespace Sass {
inline bool& Node::is_quoted() const { return ip_->is_quoted; } inline bool& Node::is_quoted() const { return ip_->is_quoted; }
inline bool Node::is_numeric() const { return ip_->is_numeric(); } inline bool Node::is_numeric() const { return ip_->is_numeric(); }
inline bool Node::is_string() const { return ip_->is_string(); } inline bool Node::is_string() const { return ip_->is_string(); }
inline bool Node::is_schema() const { return ip_->is_schema(); }
inline bool Node::is_guarded() const { return (type() == assignment) && (size() == 3); } inline bool Node::is_guarded() const { return (type() == assignment) && (size() == 3); }
inline bool& Node::has_been_extended() const { return ip_->has_been_extended; } inline bool& Node::has_been_extended() const { return ip_->has_been_extended; }
inline bool Node::is_false() const { return (type() == boolean) && (boolean_value() == false); } inline bool Node::is_false() const { return (type() == boolean) && (boolean_value() == false); }
......
...@@ -349,7 +349,15 @@ namespace Sass { ...@@ -349,7 +349,15 @@ namespace Sass {
case concatenation: { case concatenation: {
string result; string result;
bool quoted = (at(0).type() == string_constant || at(0).type() == string_schema) ? true : false; bool quoted /* = (at(0).type() == string_constant || at(0).type() == string_schema) ? true : false */;
if (at(0).type() == string_constant ||
at(0).type() == string_schema ||
(at(0).is_numeric() && (at(1).is_quoted() || !at(1).is_unquoted()))) {
quoted = true;
}
else {
quoted = false;
}
for (size_t i = 0, S = size(); i < S; ++i) { for (size_t i = 0, S = size(); i < S; ++i) {
// result += at(i).to_string().substr(1, at(i).token().length()-2); // result += at(i).to_string().substr(1, at(i).token().length()-2);
Node::Type itype = at(i).type(); Node::Type itype = at(i).type();
......
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