From 956664ace08d6c94e64383766a4fdbe31a7acf8d Mon Sep 17 00:00:00 2001 From: Marcel Greter Date: Sat, 9 May 2015 04:43:30 +0200 Subject: [PATCH] Fix `String_Schema` and `Binary_Expression` parsing Fixes https://github.com/sass/libsass/issues/948 --- parser.cpp | 14 ++++++++++++-- parser.hpp | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/parser.cpp b/parser.cpp index c9db45c3ee..6a9a98d5ea 100644 --- a/parser.cpp +++ b/parser.cpp @@ -1231,6 +1231,11 @@ namespace Sass { } // if it's a singleton, return it directly; don't wrap it if (!peek< class_char< static_ops > >(position)) return factor; + return parse_operators(factor); + } + + Expression* Parser::parse_operators(Expression* factor) + { // parse more factors and operators vector operands; // factors vector operators; // ops @@ -1241,7 +1246,7 @@ namespace Sass { case '%': operators.push_back(Binary_Expression::MOD); break; default: throw runtime_error("unknown static op parsed"); break; } - operands.push_back(parse_factor()); + operands.push_back(parse_factor(true)); } // operands and operators to binary expression return fold_operands(factor, operands, operators); @@ -1522,7 +1527,12 @@ namespace Sass { (*schema) << new (ctx.mem) Textual(pstate, Textual::DIMENSION, lexed); } else if (lex< number >()) { - (*schema) << new (ctx.mem) Textual(pstate, Textual::NUMBER, lexed); + Expression* factor = new (ctx.mem) Textual(pstate, Textual::NUMBER, lexed); + if (peek< class_char< static_ops > >()) { + (*schema) << parse_operators(factor); + } else { + (*schema) << factor; + } } else if (lex< hex >()) { (*schema) << new (ctx.mem) Textual(pstate, Textual::HEX, unquote(lexed)); diff --git a/parser.hpp b/parser.hpp index e709e4612b..9e8d68b0f6 100644 --- a/parser.hpp +++ b/parser.hpp @@ -243,6 +243,7 @@ namespace Sass { String* parse_ie_property(); String* parse_ie_keyword_arg(); String_Schema* parse_value_schema(const char* stop); + Expression* parse_operators(Expression* factor); String* parse_identifier_schema(); // String_Schema* parse_url_schema(); If* parse_if_directive(bool else_if = false);