Commit 038c77f9 by Aaron Leung

Allowing interpolants in function names.

parent cd6042d5
...@@ -821,6 +821,9 @@ namespace Sass { ...@@ -821,6 +821,9 @@ namespace Sass {
return result; return result;
} }
if (peek< functional >())
{ return parse_function_call(); }
if (lex< value_schema >()) if (lex< value_schema >())
{ return Document::make_from_token(context, lexed, path, line).parse_value_schema(); } { return Document::make_from_token(context, lexed, path, line).parse_value_schema(); }
...@@ -830,9 +833,6 @@ namespace Sass { ...@@ -830,9 +833,6 @@ namespace Sass {
if (lex< sequence< false_kwd, negate< identifier > > >()) if (lex< sequence< false_kwd, negate< identifier > > >())
{ return context.new_Node(Node::boolean, path, line, false); } { return context.new_Node(Node::boolean, path, line, false); }
if (peek< functional >())
{ return parse_function_call(); }
if (lex< important >()) if (lex< important >())
{ return context.new_Node(Node::important, path, line, lexed); } { return context.new_Node(Node::important, path, line, lexed); }
...@@ -988,8 +988,15 @@ namespace Sass { ...@@ -988,8 +988,15 @@ namespace Sass {
Node Document::parse_function_call() Node Document::parse_function_call()
{ {
Node name;
if (lex< identifier_schema >()) {
name = parse_identifier_schema();
}
else {
lex< identifier >(); lex< identifier >();
Node name(context.new_Node(Node::identifier, path, line, lexed)); name = context.new_Node(Node::identifier, path, line, lexed);
}
Node args(parse_arguments()); Node args(parse_arguments());
Node call(context.new_Node(Node::function_call, path, line, 2)); Node call(context.new_Node(Node::function_call, path, line, 2));
call << name << args; call << name << args;
......
...@@ -290,7 +290,9 @@ namespace Sass { ...@@ -290,7 +290,9 @@ namespace Sass {
case Node::function_call: { case Node::function_call: {
// TO DO: default-constructed Function should be a generic callback (maybe) // TO DO: default-constructed Function should be a generic callback (maybe)
pair<string, size_t> sig(expr[0].token().to_string(), expr[1].size()); // eval the function name in case it's interpolated
expr[0] = eval(expr[0], prefix, env, f_env, new_Node, ctx);
pair<string, size_t> sig(expr[0].to_string(), expr[1].size());
if (!f_env.count(sig)) { if (!f_env.count(sig)) {
Node args(expr[1]); Node args(expr[1]);
for (size_t i = 0, S = args.size(); i < S; ++i) { for (size_t i = 0, S = args.size(); i < S; ++i) {
......
...@@ -298,7 +298,7 @@ namespace Sass { ...@@ -298,7 +298,7 @@ namespace Sass {
} }
// Match CSS function call openers. // Match CSS function call openers.
const char* functional(const char* src) { const char* functional(const char* src) {
return sequence< identifier, exactly<'('> >(src); return sequence< alternatives< identifier_schema, identifier >, exactly<'('> >(src);
} }
// Match the CSS negation pseudo-class. // Match the CSS negation pseudo-class.
extern const char pseudo_not_chars[] = ":not("; extern const char pseudo_not_chars[] = ":not(";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment