Commit 2dbc45a0 by Aaron Leung

More fixes for evaluation edge-cases.

parent f25d02b2
......@@ -215,12 +215,10 @@ namespace Sass {
if (lex< exactly<'('> >()) {
if (!peek< exactly<')'> >(position)) {
Node arg(parse_argument(Node::none));
arg.should_eval() = true;
args << arg;
if (arg.type() == Node::assignment) arg_type = Node::assignment;
while (lex< exactly<','> >()) {
Node arg(parse_argument(arg_type));
arg.should_eval() = true;
args << arg;
if (arg.type() == Node::assignment) arg_type = Node::assignment;
}
......@@ -239,6 +237,7 @@ namespace Sass {
Node var(context.new_Node(Node::variable, path, line, lexed));
lex< exactly<':'> >();
Node val(parse_space_list());
// val.should_eval() = true;
Node assn(context.new_Node(Node::assignment, path, line, 2));
assn << var << val;
return assn;
......@@ -254,23 +253,14 @@ namespace Sass {
Node var(context.new_Node(Node::variable, path, line, lexed));
lex< exactly<':'> >();
Node val(parse_space_list());
// val.should_eval() = true;
Node assn(context.new_Node(Node::assignment, path, line, 2));
assn << var << val;
return assn;
}
return parse_space_list();
// if (peek< sequence < variable, spaces_and_comments, exactly<':'> > >()) {
// lex< variable >();
// Node var(context.new_Node(Node::variable, path, line, lexed));
// lex< exactly<':'> >();
// Node val(parse_space_list());
// Node assn(context.new_Node(Node::assignment, path, line, 2));
// assn << var << val;
// return assn;
// }
// else {
// return parse_space_list();
// }
Node val(parse_space_list());
val.should_eval() = true;
return val;
}
Node Document::parse_assignment()
......@@ -909,45 +899,45 @@ namespace Sass {
if (lex< identifier >())
{ return context.new_Node(Node::identifier, path, line, lexed); }
// if (lex< percentage >())
// { return context.new_Node(Node::textual_percentage, path, line, lexed); }
if (lex< percentage >())
{ return context.new_Node(Node::textual_percentage, path, line, lexed); }
// if (lex< dimension >())
// { return context.new_Node(Node::textual_dimension, path, line, lexed); }
if (lex< dimension >())
{ return context.new_Node(Node::textual_dimension, path, line, lexed); }
// if (lex< number >())
// { return context.new_Node(Node::textual_number, path, line, lexed); }
if (lex< number >())
{ return context.new_Node(Node::textual_number, path, line, lexed); }
// if (lex< hex >())
// { return context.new_Node(Node::textual_hex, path, line, lexed); }
if (lex< hex >())
{ return context.new_Node(Node::textual_hex, path, line, lexed); }
if (lex< percentage >())
{ return context.new_Node(path, line, atof(lexed.begin), Node::numeric_percentage); }
// if (lex< percentage >())
// { return context.new_Node(path, line, atof(lexed.begin), Node::numeric_percentage); }
if (lex< dimension >()) {
return context.new_Node(path, line, atof(lexed.begin),
Token::make(Prelexer::number(lexed.begin), lexed.end));
}
// if (lex< dimension >()) {
// return context.new_Node(path, line, atof(lexed.begin),
// Token::make(Prelexer::number(lexed.begin), lexed.end));
// }
if (lex< number >())
{ return context.new_Node(path, line, atof(lexed.begin)); }
// if (lex< number >())
// { return context.new_Node(path, line, atof(lexed.begin)); }
if (lex< hex >()) {
Node triple(context.new_Node(Node::numeric_color, path, line, 4));
Token hext(Token::make(lexed.begin+1, lexed.end));
if (hext.length() == 6) {
for (int i = 0; i < 6; i += 2) {
triple << context.new_Node(path, line, static_cast<double>(strtol(string(hext.begin+i, 2).c_str(), NULL, 16)));
}
}
else {
for (int i = 0; i < 3; ++i) {
triple << context.new_Node(path, line, static_cast<double>(strtol(string(2, hext.begin[i]).c_str(), NULL, 16)));
}
}
triple << context.new_Node(path, line, 1.0);
return triple;
}
// if (lex< hex >()) {
// Node triple(context.new_Node(Node::numeric_color, path, line, 4));
// Token hext(Token::make(lexed.begin+1, lexed.end));
// if (hext.length() == 6) {
// for (int i = 0; i < 6; i += 2) {
// triple << context.new_Node(path, line, static_cast<double>(strtol(string(hext.begin+i, 2).c_str(), NULL, 16)));
// }
// }
// else {
// for (int i = 0; i < 3; ++i) {
// triple << context.new_Node(path, line, static_cast<double>(strtol(string(2, hext.begin[i]).c_str(), NULL, 16)));
// }
// }
// triple << context.new_Node(path, line, 1.0);
// return triple;
// }
if (peek< string_constant >())
{ return parse_string(); }
......@@ -1023,30 +1013,34 @@ namespace Sass {
schema << context.new_Node(Node::identifier, path, line, lexed);
}
else if (lex< percentage >()) {
schema << context.new_Node(path, line, atof(lexed.begin), Node::numeric_percentage);
schema << context.new_Node(Node::textual_percentage, path, line, lexed);
// schema << context.new_Node(path, line, atof(lexed.begin), Node::numeric_percentage);
}
else if (lex< dimension >()) {
schema << context.new_Node(path, line, atof(lexed.begin),
Token::make(Prelexer::number(lexed.begin), lexed.end));
schema << context.new_Node(Node::textual_dimension, path, line, lexed);
// schema << context.new_Node(path, line, atof(lexed.begin),
// Token::make(Prelexer::number(lexed.begin), lexed.end));
}
else if (lex< number >()) {
schema << context.new_Node(path, line, atof(lexed.begin));
schema << context.new_Node(Node::textual_number, path, line, lexed);
// schema << context.new_Node(path, line, atof(lexed.begin));
}
else if (lex< hex >()) {
Node triple(context.new_Node(Node::numeric_color, path, line, 4));
Token hext(Token::make(lexed.begin+1, lexed.end));
if (hext.length() == 6) {
for (int i = 0; i < 6; i += 2) {
triple << context.new_Node(path, line, static_cast<double>(strtol(string(hext.begin+i, 2).c_str(), NULL, 16)));
}
}
else {
for (int i = 0; i < 3; ++i) {
triple << context.new_Node(path, line, static_cast<double>(strtol(string(2, hext.begin[i]).c_str(), NULL, 16)));
}
}
triple << context.new_Node(path, line, 1.0);
schema << triple;
schema << context.new_Node(Node::textual_hex, path, line, lexed);
// Node triple(context.new_Node(Node::numeric_color, path, line, 4));
// Token hext(Token::make(lexed.begin+1, lexed.end));
// if (hext.length() == 6) {
// for (int i = 0; i < 6; i += 2) {
// triple << context.new_Node(path, line, static_cast<double>(strtol(string(hext.begin+i, 2).c_str(), NULL, 16)));
// }
// }
// else {
// for (int i = 0; i < 3; ++i) {
// triple << context.new_Node(path, line, static_cast<double>(strtol(string(2, hext.begin[i]).c_str(), NULL, 16)));
// }
// }
// triple << context.new_Node(path, line, 1.0);
// schema << triple;
}
else if (lex< string_constant >()) {
Node str(context.new_Node(Node::string_constant, path, line, lexed));
......
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