diff --git a/extend.cpp b/extend.cpp index 60aa95cb3f..0e1a7465a6 100644 --- a/extend.cpp +++ b/extend.cpp @@ -5,7 +5,6 @@ #include "backtrace.hpp" #include "paths.hpp" #include "parser.hpp" -#include "debugger.hpp" #include "node.hpp" #include "sass_util.hpp" #include "debug.hpp" @@ -1580,7 +1579,6 @@ namespace Sass { // out and aren't operated on. Complex_Selector* pNewSelector = pExtComplexSelector->cloneFully(ctx); Complex_Selector* pNewInnerMost = new (ctx.mem) Complex_Selector(pSelector->pstate(), Complex_Selector::ANCESTOR_OF, pUnifiedSelector, NULL); - // pNewInnerMost->media_block(pSelector->media_block()); Complex_Selector::Combinator combinator = pNewSelector->clear_innermost(); pNewSelector->set_innermost(pNewInnerMost, combinator); @@ -1753,11 +1751,9 @@ namespace Sass { pComplexSelector->tail()->has_line_feed(pComplexSelector->has_line_feed()); Node complexSelector = complexSelectorToNode(pComplexSelector, ctx); -// debug_ast(pComplexSelector->parent()); DEBUG_PRINTLN(EXTEND_COMPLEX, "EXTEND COMPLEX: " << complexSelector) Node extendedNotExpanded = Node::createCollection(); - // extendedNotExpanded.media_block = pComplexSelector->media_block(); for (NodeDeque::iterator complexSelIter = complexSelector.collection()->begin(), complexSelIterEnd = complexSelector.collection()->end(); complexSelIter != complexSelIterEnd; ++complexSelIter) { Node& sseqOrOp = *complexSelIter; diff --git a/parser.cpp b/parser.cpp index 1156985e24..5eb1e94de3 100644 --- a/parser.cpp +++ b/parser.cpp @@ -402,7 +402,6 @@ namespace Sass { property_segment = new (ctx.mem) String_Quoted(pstate, lexed); } Propset* propset = new (ctx.mem) Propset(pstate, property_segment); - // debug_ast(property_segment); lex< exactly<':'> >(); if (!peek< exactly<'{'> >()) error("expected a '{' after namespaced property", pstate); @@ -941,6 +940,22 @@ namespace Sass { } } + // parse +/- and return false if negative + bool Parser::parse_number_prefix() + { + bool positive = true; + while(true) { + if (lex < block_comment >()) continue; + if (lex < number_prefix >()) continue; + if (lex < exactly < '-' > >()) { + positive = !positive; + continue; + } + break; + } + return positive; + } + Expression* Parser::parse_map() { To_String to_string(&ctx); @@ -1203,6 +1218,10 @@ namespace Sass { else if (lex< sequence< not_op, spaces_and_comments > >()) { return new (ctx.mem) Unary_Expression(pstate, Unary_Expression::NOT, parse_factor()); } + else if (peek < sequence < one_plus < alternatives < spaces_and_comments, exactly<'-'>, exactly<'+'> > >, number > >()) { + if (parse_number_prefix()) return parse_value(); // prefix is positive + return new (ctx.mem) Unary_Expression(pstate, Unary_Expression::MINUS, parse_value()); + } else { return parse_value(); } @@ -1210,10 +1229,7 @@ namespace Sass { Expression* Parser::parse_value() { - - // ToDo: Move where while (lex< block_comment >()); - if (lex< uri_prefix >()) { Arguments* args = new (ctx.mem) Arguments(pstate); Function_Call* result = new (ctx.mem) Function_Call(pstate, "url", args); diff --git a/parser.hpp b/parser.hpp index 757b7b855f..8f6a061adf 100644 --- a/parser.hpp +++ b/parser.hpp @@ -234,6 +234,7 @@ namespace Sass { Simple_Selector* parse_pseudo_selector(); Attribute_Selector* parse_attribute_selector(); Block* parse_block(); + bool parse_number_prefix(); Declaration* parse_declaration(); Expression* parse_map_value(); Expression* parse_map(); diff --git a/prelexer.cpp b/prelexer.cpp index 189987e308..d1f6065348 100644 --- a/prelexer.cpp +++ b/prelexer.cpp @@ -147,6 +147,18 @@ namespace Sass { return sequence< exactly<'-'>, exactly<'-'>, identifier >(src); } + // Match number prefix ([\+\-]+) + const char* number_prefix(const char* src) { + return alternatives < + exactly < '+' >, + sequence < + exactly < '-' >, + optional_spaces_and_comments, + exactly< '-' > + > + >(src); + } + // Match interpolant schemas const char* identifier_schema(const char* src) { // follows this pattern: (x*ix*)+ ... well, not quite diff --git a/prelexer.hpp b/prelexer.hpp index ba18b131c4..0a2324f49e 100644 --- a/prelexer.hpp +++ b/prelexer.hpp @@ -396,6 +396,8 @@ namespace Sass { const char* quoted_string(const char* src); // Match interpolants. const char* interpolant(const char* src); + // Match number prefix ([\+\-]+) + const char* number_prefix(const char* src); // Whitespace handling. const char* optional_spaces(const char* src);