Skip to content

Commit

Permalink
Add base eval step for map keys while parsing
Browse files Browse the repository at this point in the history
Keys need to be immutable for the main structure, so we
need to evaluate them while the map is being parsed. We
may defer the map initialization into the eval step too.

Fixes #1169
  • Loading branch information
mgreter committed May 7, 2015
1 parent 66631c0 commit 9c74c7a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,16 @@ namespace Sass {
{
To_String to_string(&ctx);
Expression* key = parse_list();
if (String_Quoted* str = dynamic_cast<String_Quoted*>(key)) {
if (!str->quote_mark() && !str->is_delayed()) {
if (ctx.names_to_colors.count(str->value())) {
Color* c = new (ctx.mem) Color(*ctx.names_to_colors[str->value()]);
c->pstate(str->pstate());
c->disp(str->value());
key = c;
}
}
}

// it's not a map so return the lexed value as a list value
if (!peek< exactly<':'> >())
Expand All @@ -1029,6 +1039,16 @@ namespace Sass {
{ break; }

Expression* key = parse_list();
if (String_Quoted* str = dynamic_cast<String_Quoted*>(key)) {
if (!str->quote_mark() && !str->is_delayed()) {
if (ctx.names_to_colors.count(str->value())) {
Color* c = new (ctx.mem) Color(*ctx.names_to_colors[str->value()]);
c->pstate(str->pstate());
c->disp(str->value());
key = c;
}
}
}

if (!(lex< exactly<':'> >()))
{ error("invalid syntax", pstate); }
Expand Down

0 comments on commit 9c74c7a

Please sign in to comment.