Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix parsing of another missed block comment
Browse files Browse the repository at this point in the history
Fixes sass#1021
mgreter committed Apr 1, 2015
1 parent d215db5 commit 074108a
Showing 3 changed files with 17 additions and 14 deletions.
4 changes: 4 additions & 0 deletions constants.cpp
Original file line number Diff line number Diff line change
@@ -127,6 +127,10 @@ namespace Sass {
extern const char map_name[] = "map";
extern const char arglist_name[] = "arglist";

// some specific constant character classes
// they must be static to be useable by lexer
extern const char static_ops[] = "*/%";

// byte order marks
// (taken from http://en.wikipedia.org/wiki/Byte_order_mark)
extern const unsigned char utf_8_bom[] = { 0xEF, 0xBB, 0xBF };
4 changes: 4 additions & 0 deletions constants.hpp
Original file line number Diff line number Diff line change
@@ -130,6 +130,10 @@ namespace Sass {
extern const char map_name[];
extern const char arglist_name[];

// some specific constant character classes
// they must be static to be useable by lexer
extern const char static_ops[];

// byte order marks
// (taken from http://en.wikipedia.org/wiki/Byte_order_mark)
extern const unsigned char utf_8_bom[];
23 changes: 9 additions & 14 deletions parser.cpp
Original file line number Diff line number Diff line change
@@ -1191,29 +1191,24 @@ namespace Sass {
Expression* Parser::parse_term()
{
Expression* fact1 = parse_factor();

// Special case: Ruby sass never tries to modulo if the lhs contains an interpolant
if (peek< exactly<'%'> >(position) && fact1->concrete_type() == Expression::STRING) {
if (peek_css< exactly<'%'> >(position) && fact1->concrete_type() == Expression::STRING) {
String_Schema* ss = dynamic_cast<String_Schema*>(fact1);
if (ss && ss->has_interpolants()) return fact1;
}

// if it's a singleton, return it directly; don't wrap it
if (!(peek< exactly<'*'> >(position) ||
peek< exactly<'/'> >(position) ||
peek< exactly<'%'> >(position)))
{ return fact1; }

while (lex< block_comment >());
// parse more ops and factors
vector<Expression*> operands;
vector<Binary_Expression::Type> operators;
while (lex< exactly<'*'> >() || lex< exactly<'/'> >() || lex< exactly<'%'> >()) {
while (lex_css< class_char< static_ops > >()) {
if (lexed.to_string() == "*") operators.push_back(Binary_Expression::MUL);
else if (lexed.to_string() == "/") operators.push_back(Binary_Expression::DIV);
else operators.push_back(Binary_Expression::MOD);
else if (lexed.to_string() == "%") operators.push_back(Binary_Expression::DIV);
else throw runtime_error("unknown static op parsed");
operands.push_back(parse_factor());
}

// maybe return as a singleton
if (operands.empty()) return fact1;
// fold operands into a binary expression
return fold_operands(fact1, operands, operators);
}

@@ -1275,7 +1270,7 @@ namespace Sass {

Expression* Parser::parse_value()
{
while (lex< block_comment >());
lex< css_comments >();
if (lex< uri_prefix >()) {
Arguments* args = new (ctx.mem) Arguments(pstate);
Function_Call* result = new (ctx.mem) Function_Call(pstate, "url", args);

0 comments on commit 074108a

Please sign in to comment.