Skip to content

Commit 8fbaaf7

Browse files
committed
Merge pull request #1475 from mgreter/bugfix/wrong-list-spacing
Fix small spacing issue with list parsing
2 parents 1d0b207 + a7581d6 commit 8fbaaf7

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

src/ast.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1401,10 +1401,11 @@ namespace Sass {
14011401
////////////////////////////////////////////////////////
14021402
class String_Quoted : public String_Constant {
14031403
public:
1404-
String_Quoted(ParserState pstate, std::string val)
1404+
String_Quoted(ParserState pstate, std::string val, char q = 0)
14051405
: String_Constant(pstate, val)
14061406
{
14071407
value_ = unquote(value_, &quote_mark_);
1408+
if (q && quote_mark_) quote_mark_ = q;
14081409
}
14091410
virtual bool operator==(const Expression& rhs) const;
14101411
virtual std::string to_string(bool compressed = false, int precision = 5) const;

src/parser.cpp

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,14 @@ namespace Sass {
13661366
return parse_function_call_schema();
13671367
}
13681368
else if (lex< identifier_schema >()) {
1369-
return parse_identifier_schema();
1369+
String* string = parse_identifier_schema();
1370+
if (String_Schema* schema = dynamic_cast<String_Schema*>(string)) {
1371+
if (lex < exactly < '(' > >()) {
1372+
*schema << parse_list();
1373+
lex < exactly < ')' > >();
1374+
}
1375+
}
1376+
return string;
13701377
}
13711378
else if (peek< re_functional >()) {
13721379
return parse_function_call();
@@ -1599,13 +1606,14 @@ namespace Sass {
15991606
css_error("Invalid CSS", " after ", ": expected expression (e.g. 1px, bold), was ");
16001607
}
16011608

1609+
const char* e = 0;
16021610
size_t num_items = 0;
16031611
while (position < stop) {
16041612
// parse space between tokens
16051613
if (lex< spaces >() && num_items) {
16061614
(*schema) << new (ctx.mem) String_Constant(pstate, " ");
16071615
}
1608-
if (peek< re_functional >()) {
1616+
if ((e = peek< re_functional >()) && e < stop) {
16091617
(*schema) << parse_function_call();
16101618
}
16111619
// lex an interpolant /#{...}/
@@ -1622,10 +1630,16 @@ namespace Sass {
16221630
// lex some string constants
16231631
else if (lex< alternatives < exactly<'%'>, exactly < '-' >, identifier > >()) {
16241632
(*schema) << new (ctx.mem) String_Constant(pstate, lexed);
1633+
if (*position == '"' || *position == '\'') {
1634+
(*schema) << new (ctx.mem) String_Constant(pstate, " ");
1635+
}
16251636
}
16261637
// lex a quoted string
16271638
else if (lex< quoted_string >()) {
1628-
(*schema) << new (ctx.mem) String_Quoted(pstate, lexed);
1639+
(*schema) << new (ctx.mem) String_Quoted(pstate, lexed, '"');
1640+
if (*position == '"' || *position == '\'' || alpha(position)) {
1641+
(*schema) << new (ctx.mem) String_Constant(pstate, " ");
1642+
}
16291643
}
16301644
// lex (normalized) variable
16311645
else if (lex< variable >()) {
@@ -1681,7 +1695,9 @@ namespace Sass {
16811695
if (p) {
16821696
if (i < p) {
16831697
// accumulate the preceding segment if it's nonempty
1684-
(*schema) << new (ctx.mem) String_Constant(pstate, std::string(i, p));
1698+
const char* o = position; position = i;
1699+
*schema << parse_value_schema(p);
1700+
position = o;
16851701
}
16861702
// we need to skip anything inside strings
16871703
// create a new target in parser/prelexer
@@ -1703,7 +1719,11 @@ namespace Sass {
17031719
}
17041720
}
17051721
else { // no interpolants left; add the last segment if nonempty
1706-
if (i < end) (*schema) << new (ctx.mem) String_Constant(pstate, std::string(i, id.end));
1722+
if (i < end) {
1723+
const char* o = position; position = i;
1724+
*schema << parse_value_schema(id.end);
1725+
position = o;
1726+
}
17071727
break;
17081728
}
17091729
}

src/prelexer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ namespace Sass {
153153
alternatives <
154154
digits,
155155
identifier,
156+
quoted_string,
156157
exactly<'+'>,
157158
exactly<'-'>
158159
>

0 commit comments

Comments
 (0)