Commit 205c762a by Aaron Leung

Makin' a 'nuther test pass.

parent 66f27795
......@@ -15,7 +15,13 @@ namespace Sass {
}
else if (peek< import >(position)) {
// TO DO: don't splice in place at parse-time -- use an expansion node
root += parse_import();
Node import(parse_import());
if (import.type == Node::css_import) {
root << import;
}
else {
root += import;
}
if (!lex< exactly<';'> >()) syntax_error("top-level @import directive must be terminated by ';'");
}
else if (peek< mixin >(position)) {
......@@ -40,7 +46,16 @@ namespace Sass {
Node Document::parse_import()
{
lex< import >();
if (!lex< string_constant >()) syntax_error("@import directive requires a quoted path");
if (lex< uri_prefix >())
{
const char* beg = position;
const char* end = find_first< exactly<')'> >(position);
Node result(Node::css_import, line_number, Token::make(beg, end));
position = end;
lex< exactly<')'> >();
return result;
}
if (!lex< string_constant >()) syntax_error("@import directive requires a url or quoted path");
// TO DO: BETTER PATH HANDLING
string import_path(lexed.unquote());
const char* curr_path_start = path.c_str();
......@@ -413,17 +428,24 @@ namespace Sass {
syntax_error("@import directive not allowed inside mixin definition");
}
Node imported_tree(parse_import());
for (int i = 0; i < imported_tree.size(); ++i) {
if (imported_tree[i].type == Node::comment ||
imported_tree[i].type == Node::rule) {
block[0].has_statements = true;
}
else if (imported_tree[i].type == Node::ruleset) {
block[0].has_blocks = true;
if (imported_tree.type == Node::css_import) {
cerr << "css import inside block" << endl;
block << imported_tree;
block.has_statements = true;
}
else {
for (int i = 0; i < imported_tree.size(); ++i) {
if (imported_tree[i].type == Node::comment ||
imported_tree[i].type == Node::rule) {
block[0].has_statements = true;
}
else if (imported_tree[i].type == Node::ruleset) {
block[0].has_blocks = true;
}
block << imported_tree[i];
}
block << imported_tree[i];
semicolon = true;
}
semicolon = true;
}
else if (peek< include >(position)) {
block << parse_mixin_call();
......
......@@ -174,6 +174,15 @@ namespace Sass {
return "/";
} break;
case css_import: {
stringstream ss;
ss << "@import url(";
ss << content.token.to_string();
cerr << content.token.to_string() << endl;
ss << ")";
return ss.str();
}
case function_call: {
stringstream ss;
ss << at(0).to_string("");
......@@ -398,6 +407,7 @@ namespace Sass {
}
for (int i = 0; i < size(); ++i) {
at(i).emit_nested_css(buf, depth, prefixes);
if (at(i).type == css_import) buf << endl;
}
break;
......@@ -430,7 +440,7 @@ namespace Sass {
buf << " {";
for (int i = 0; i < block.size(); ++i) {
Type stm_type = block[i].type;
if (stm_type == comment || stm_type == rule) {
if (stm_type == comment || stm_type == rule || stm_type == css_import) {
block[i].emit_nested_css(buf, depth+1); // NEED OVERLOADED VERSION FOR COMMENTS AND RULES
}
}
......@@ -464,6 +474,12 @@ namespace Sass {
at(1).emit_nested_css(buf, depth); // values
buf << ";";
break;
case css_import:
buf << endl << string(2*depth, ' ');
buf << to_string("");
buf << ";";
break;
case property:
buf << string(content.token) << ": ";
......
......@@ -81,6 +81,7 @@ namespace Sass {
value_schema,
string_schema,
css_import,
function_call,
mixin,
parameters,
......
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