Skip to content

Commit

Permalink
Fix String_Schema and Binary_Expression parsing
Browse files Browse the repository at this point in the history
Fixes sass#948
  • Loading branch information
mgreter committed May 9, 2015
1 parent f802410 commit 956664a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Expression*> operands; // factors
vector<Binary_Expression::Type> operators; // ops
Expand All @@ -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);
Expand Down Expand Up @@ -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));
Expand Down
1 change: 1 addition & 0 deletions parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 956664a

Please sign in to comment.