From 03c9fd1216a1582258eaab0af2dc81710a068d99 Mon Sep 17 00:00:00 2001 From: Marcel Greter Date: Sun, 25 Sep 2016 02:49:06 +0200 Subject: [PATCH] Delay Unary_Expression according to parsed operand --- src/debugger.hpp | 1 + src/parser.cpp | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/debugger.hpp b/src/debugger.hpp index 6d10fd32ed..8c4ab7bc12 100644 --- a/src/debugger.hpp +++ b/src/debugger.hpp @@ -552,6 +552,7 @@ inline void debug_ast(AST_Node* node, std::string ind, Env* env) Unary_Expression* expression = dynamic_cast(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); diff --git a/src/parser.cpp b/src/parser.cpp index aae4b3e478..97ba4576f2 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -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();