Commit f5290379 by Aaron Leung

Minor tweaks.

parent bfb7afa2
...@@ -109,8 +109,8 @@ namespace Sass { ...@@ -109,8 +109,8 @@ namespace Sass {
} }
} }
void parse_scss(bool definition = false); void parse_scss();
Node parse_import(bool definition = false); Node parse_import();
Node parse_include(); Node parse_include();
Node parse_mixin_definition(); Node parse_mixin_definition();
Node parse_mixin_parameters(); Node parse_mixin_parameters();
......
...@@ -34,6 +34,10 @@ namespace Sass { ...@@ -34,6 +34,10 @@ namespace Sass {
n[1] = eval(n[1], context.environment); n[1] = eval(n[1], context.environment);
} }
} break; } break;
case Node::expansion: {
} break;
} }
} }
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
namespace Sass { namespace Sass {
using namespace std; using namespace std;
void Document::parse_scss(bool definition) void Document::parse_scss()
{ {
lex<optional_spaces>(); lex<optional_spaces>();
while(*position) { while(*position) {
...@@ -13,13 +13,11 @@ namespace Sass { ...@@ -13,13 +13,11 @@ namespace Sass {
root << Node(line_number, Node::comment, lexed); root << Node(line_number, Node::comment, lexed);
} }
else if (peek< import >(position)) { else if (peek< import >(position)) {
root += parse_import(definition); root += parse_import();
lex< exactly<';'> >(); lex< exactly<';'> >();
} }
else if (peek< mixin >(position)) { else if (peek< mixin >(position)) {
// TO DO: check to see if we're already inside a definition in order context.pending.push_back(parse_mixin_definition());
// to disallow definitions that are sneakily nested via imports.
if (!definition) context.pending.push_back(parse_mixin_definition());
} }
else if (peek< include >(position)) { else if (peek< include >(position)) {
Node call(parse_mixin_call()); Node call(parse_mixin_call());
...@@ -28,26 +26,21 @@ namespace Sass { ...@@ -28,26 +26,21 @@ namespace Sass {
root.has_rulesets |= call.has_rulesets; root.has_rulesets |= call.has_rulesets;
root.has_propsets |= call.has_propsets; root.has_propsets |= call.has_propsets;
lex< exactly<';'> >(); lex< exactly<';'> >();
if (!definition) context.pending.push_back(call); context.pending.push_back(call);
} }
else if (peek< variable >(position)) { else if (peek< variable >(position)) {
Node assn(parse_assignment()); Node assn(parse_assignment());
lex< exactly<';'> >(); lex< exactly<';'> >();
if (!definition) {
context.pending.push_back(assn); context.pending.push_back(assn);
} }
else { else {
root << assn; root << parse_ruleset();
}
}
else {
root << parse_ruleset(definition);
} }
lex<optional_spaces>(); lex<optional_spaces>();
} }
} }
Node Document::parse_import(bool definition) Node Document::parse_import()
{ {
lex< import >(); lex< import >();
lex< string_constant >(); lex< string_constant >();
...@@ -56,7 +49,7 @@ namespace Sass { ...@@ -56,7 +49,7 @@ namespace Sass {
const char* curr_path_end = folders(curr_path_start); const char* curr_path_end = folders(curr_path_start);
string current_path(curr_path_start, curr_path_end - curr_path_start); string current_path(curr_path_start, curr_path_end - curr_path_start);
Document importee(current_path + import_path, context); Document importee(current_path + import_path, context);
importee.parse_scss(definition); importee.parse_scss();
return importee.root; return importee.root;
} }
...@@ -117,7 +110,7 @@ namespace Sass { ...@@ -117,7 +110,7 @@ namespace Sass {
lex< identifier >(); lex< identifier >();
Node name(line_number, Node::identifier, lexed); Node name(line_number, Node::identifier, lexed);
Node args(parse_mixin_arguments()); Node args(parse_mixin_arguments());
Node call(line_number, Node::mixin_expansion, 2); Node call(line_number, Node::expansion, 2);
call << name << args; call << name << args;
return call; return call;
} }
...@@ -325,6 +318,7 @@ namespace Sass { ...@@ -325,6 +318,7 @@ namespace Sass {
semicolon = true; semicolon = true;
} }
else if (peek< import >(position)) { else if (peek< import >(position)) {
// TO DO: disallow imports inside of definitions
Node imported_tree(parse_import()); Node imported_tree(parse_import());
for (int i = 0; i < imported_tree.size(); ++i) { for (int i = 0; i < imported_tree.size(); ++i) {
if (imported_tree[i].type == Node::comment || if (imported_tree[i].type == Node::comment ||
......
...@@ -213,8 +213,8 @@ namespace Sass { ...@@ -213,8 +213,8 @@ namespace Sass {
return result; return result;
} break; } break;
case mixin_expansion: { case expansion: {
string result("MIXIN: "); string result("MIXIN CALL: ");
return result; return result;
} break; } break;
...@@ -325,7 +325,7 @@ namespace Sass { ...@@ -325,7 +325,7 @@ namespace Sass {
if (stm_type == comment || stm_type == rule) { if (stm_type == comment || stm_type == rule) {
block[i].emit_nested_css(buf, depth+1); // NEED OVERLOADED VERSION FOR COMMENTS AND RULES block[i].emit_nested_css(buf, depth+1); // NEED OVERLOADED VERSION FOR COMMENTS AND RULES
} }
else if (stm_type == mixin_expansion) { else if (stm_type == expansion) {
buf << endl << string(2*(depth+1), ' ') << block[i].to_string(""); // TEMPORARY buf << endl << string(2*(depth+1), ' ') << block[i].to_string(""); // TEMPORARY
for (int j = 0; j < block[i].size(); ++j) { for (int j = 0; j < block[i].size(); ++j) {
block[i][j].emit_nested_css(buf, depth+1); block[i][j].emit_nested_css(buf, depth+1);
......
...@@ -64,7 +64,7 @@ namespace Sass { ...@@ -64,7 +64,7 @@ namespace Sass {
mixin, mixin,
parameters, parameters,
mixin_expansion, expansion,
arguments, arguments,
variable, variable,
......
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