Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay Unary_Expression according to parsed operand #2189

Merged
merged 1 commit into from
Sep 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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