Skip to content

Commit

Permalink
Merge pull request sass#2189 from mgreter/bugfix/delay-unary-expressions
Browse files Browse the repository at this point in the history
Delay Unary_Expression according to parsed operand
  • Loading branch information
mgreter authored Sep 25, 2016
2 parents 1cd9ce6 + 03c9fd1 commit 8cd9434
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/debugger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ inline void debug_ast(AST_Node* node, std::string ind, Env* env)
Unary_Expression* expression = dynamic_cast<Unary_Expression*>(node);
std::cerr << ind << "Unary_Expression " << expression;
std::cerr << " [interpolant: " << expression->is_interpolant() << "] ";
std::cerr << " [delayed: " << expression->is_delayed() << "] ";
std::cerr << " (" << pstate_source_position(node) << ")";
std::cerr << " [" << expression->type() << "]" << std::endl;
debug_ast(expression->operand(), ind + " operand: ", env);
Expand Down
16 changes: 12 additions & 4 deletions src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1360,17 +1360,25 @@ namespace Sass {
return parse_function_call();
}
else if (lex< exactly<'+'> >()) {
return SASS_MEMORY_NEW(ctx.mem, Unary_Expression, pstate, Unary_Expression::PLUS, parse_factor());
Unary_Expression* ex = SASS_MEMORY_NEW(ctx.mem, Unary_Expression, pstate, Unary_Expression::PLUS, parse_factor());
if (ex && ex->operand()) ex->is_delayed(ex->operand()->is_delayed());
return ex;
}
else if (lex< exactly<'-'> >()) {
return SASS_MEMORY_NEW(ctx.mem, Unary_Expression, pstate, Unary_Expression::MINUS, parse_factor());
Unary_Expression* ex = SASS_MEMORY_NEW(ctx.mem, Unary_Expression, pstate, Unary_Expression::MINUS, parse_factor());
if (ex && ex->operand()) ex->is_delayed(ex->operand()->is_delayed());
return ex;
}
else if (lex< sequence< kwd_not > >()) {
return SASS_MEMORY_NEW(ctx.mem, Unary_Expression, pstate, Unary_Expression::NOT, parse_factor());
Unary_Expression* ex = SASS_MEMORY_NEW(ctx.mem, Unary_Expression, pstate, Unary_Expression::NOT, parse_factor());
if (ex && ex->operand()) ex->is_delayed(ex->operand()->is_delayed());
return ex;
}
else if (peek < sequence < one_plus < alternatives < css_whitespace, exactly<'-'>, exactly<'+'> > >, number > >()) {
if (parse_number_prefix()) return parse_value(); // prefix is positive
return SASS_MEMORY_NEW(ctx.mem, Unary_Expression, pstate, Unary_Expression::MINUS, parse_value());
Unary_Expression* ex = SASS_MEMORY_NEW(ctx.mem, Unary_Expression, pstate, Unary_Expression::MINUS, parse_value());;
if (ex->operand()) ex->is_delayed(ex->operand()->is_delayed());
return ex;
}
else {
return parse_value();
Expand Down

0 comments on commit 8cd9434

Please sign in to comment.