Commit 44915666 by Aaron Leung

Consolidating a couple of files.

parent a1173a63
build: sassc.cpp document.cpp node.cpp token.cpp prelexer.cpp build: sassc.cpp document.cpp node.cpp token.cpp prelexer.cpp
g++ -o bin/sassc sassc.cpp document.cpp document_parser.cpp document_eval_pending.cpp eval_apply.cpp document_emitter.cpp node.cpp token.cpp prelexer.cpp g++ -o bin/sassc sassc.cpp document.cpp document_parser.cpp eval_apply.cpp node.cpp token.cpp prelexer.cpp
test: build test: build
ruby spec.rb spec/basic/ ruby spec.rb spec/basic/
......
#include <cstdio> #include <cstdio>
#include "document.hpp" #include "document.hpp"
#include "eval_apply.hpp"
#include <iostream> #include <iostream>
namespace Sass { namespace Sass {
...@@ -58,4 +59,32 @@ namespace Sass { ...@@ -58,4 +59,32 @@ namespace Sass {
if (context.ref_count == 0) delete &context; if (context.ref_count == 0) delete &context;
} }
void Document::eval_pending()
{
for (int i = 0; i < context.pending.size(); ++i) {
eval(context.pending[i], context.global_env);
}
}
using std::string;
using std::stringstream;
using std::endl;
string Document::emit_css(CSS_Style style) {
stringstream output;
switch (style) {
case echo:
root.echo(output);
break;
case nested:
root.emit_nested_css(output, 0, vector<string>());
break;
case expanded:
root.emit_expanded_css(output, "");
break;
}
string retval(output.str());
if (!retval.empty()) retval.resize(retval.size()-1);
return retval;
}
} }
\ No newline at end of file
#include "document.hpp"
namespace Sass {
using std::string;
using std::stringstream;
using std::endl;
string Document::emit_css(CSS_Style style) {
stringstream output;
switch (style) {
case echo:
root.echo(output);
break;
case nested:
root.emit_nested_css(output, 0, vector<string>());
break;
case expanded:
root.emit_expanded_css(output, "");
break;
}
string retval(output.str());
if (!retval.empty()) retval.resize(retval.size()-1);
return retval;
}
}
\ No newline at end of file
#include "document.hpp"
#include "eval_apply.hpp"
namespace Sass {
void Document::eval_pending()
{
for (int i = 0; i < context.pending.size(); ++i) {
eval(context.pending[i], context.global_env);
// Node n(context.pending[i]);
// switch (n.type)
// {
// // case Node::assignment: {
// // // Node val(n[1]);
// // // if (val.type == Node::comma_list || val.type == Node::space_list) {
// // // for (int i = 0; i < val.size(); ++i) {
// // // if (val[i].eval_me) val[i] = eval(val[i], context.global_env);
// // // }
// // // }
// // // else {
// // // val = eval(val, context.global_env);
// // // }
// // // context.global_env[n[0].token] = val;
// //
// // eval(n, context.global_env);
// // } break;
// //
// // case Node::rule: {
// // // treat top-level lists differently from nested ones
// // // Node rhs(n[1]);
// // // if (rhs.type == Node::comma_list || rhs.type == Node::space_list) {
// // // for (int i = 0; i < rhs.size(); ++i) {
// // // if (rhs[i].eval_me) rhs[i] = eval(rhs[i], context.global_env);
// // // }
// // // }
// // // else {
// // // n[1] = eval(n[1], context.global_env);
// // // }
// //
// // eval(n, context.global_env);
// // } break;
// //
// // case Node::mixin: {
// // // context.global_env[n[0].token] = n;
// //
// // eval(n, context.global_env);
// // } break;
//
// // case Node::expansion: {
// // Token name(n[0].token);
// // Node args(n[1]);
// // Node mixin(context.global_env[name]);
// // n.children->pop_back();
// // n.children->pop_back();
// // n += apply(mixin, args, context.global_env);
// // } break;
//
// default: eval(n, context.global_env);
// }
}
}
}
\ No newline at end of file
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