@@ -1578,7 +1578,7 @@ namespace Sass {
1578
1578
return nr;
1579
1579
}
1580
1580
1581
- Expression_Ptr Parser::lexed_hex_color (const ParserState& pstate, const std::string& parsed)
1581
+ Value_Ptr Parser::lexed_hex_color (const ParserState& pstate, const std::string& parsed)
1582
1582
{
1583
1583
Color_Ptr color = NULL ;
1584
1584
if (parsed[0 ] != ' #' ) {
@@ -1628,6 +1628,19 @@ namespace Sass {
1628
1628
return color;
1629
1629
}
1630
1630
1631
+ Value_Ptr Parser::color_or_string (const std::string& lexed) const
1632
+ {
1633
+ if (auto color = name_to_color (lexed)) {
1634
+ auto c = SASS_MEMORY_NEW (Color, color);
1635
+ c->is_delayed (true );
1636
+ c->pstate (pstate);
1637
+ c->disp (lexed);
1638
+ return c;
1639
+ } else {
1640
+ return SASS_MEMORY_NEW (String_Constant, pstate, lexed);
1641
+ }
1642
+ }
1643
+
1631
1644
// parse one value for a list
1632
1645
Expression_Obj Parser::parse_value ()
1633
1646
{
@@ -1670,7 +1683,7 @@ namespace Sass {
1670
1683
{ return SASS_MEMORY_NEW (Null, pstate); }
1671
1684
1672
1685
if (lex< identifier >()) {
1673
- return SASS_MEMORY_NEW (String_Constant, pstate, lexed);
1686
+ return color_or_string ( lexed);
1674
1687
}
1675
1688
1676
1689
if (lex< percentage >())
@@ -1841,7 +1854,7 @@ namespace Sass {
1841
1854
return schema->length () > 0 ? schema.detach () : NULL ;
1842
1855
}
1843
1856
1844
- String_Constant_Obj Parser::parse_static_value ()
1857
+ Value_Obj Parser::parse_static_value ()
1845
1858
{
1846
1859
lex< static_value >();
1847
1860
Token str (lexed);
@@ -1852,8 +1865,7 @@ namespace Sass {
1852
1865
--str.end ;
1853
1866
--position;
1854
1867
1855
- String_Constant_Ptr str_node = SASS_MEMORY_NEW (String_Constant, pstate, str.time_wspace ());
1856
- return str_node;
1868
+ return color_or_string (str.time_wspace ());;
1857
1869
}
1858
1870
1859
1871
String_Obj Parser::parse_string ()
@@ -1986,7 +1998,7 @@ namespace Sass {
1986
1998
}
1987
1999
if (peek < exactly < ' -' > >()) break ;
1988
2000
}
1989
- else if (lex< sequence < identifier > >()) {
2001
+ else if (lex< identifier >()) {
1990
2002
schema->append (SASS_MEMORY_NEW (String_Constant, pstate, lexed));
1991
2003
if ((*position == ' "' || *position == ' \' ' ) || peek < alternatives < alpha > >()) {
1992
2004
// need_space = true;
0 commit comments