Commit e2021333 by Aaron Leung

Getting the pegs to fit into the holes.

parent ea68a55e
......@@ -3,6 +3,7 @@
#include <utility>
#include <map>
#include "node_factory.hpp"
#include "functions.hpp"
namespace Sass {
......@@ -45,7 +46,7 @@ namespace Sass {
vector<char*> source_refs; // all the source c-strings
vector<vector<Node>*> registry; // all the child vectors
vector<string> include_paths;
Node_Factory new_node;
Node_Factory new_Node;
size_t ref_count;
string sass_path;
string css_path;
......
......@@ -4,6 +4,7 @@
#include "eval_apply.hpp"
#include "error.hpp"
#include <iostream>
#include <sstream>
namespace Sass {
......@@ -25,7 +26,7 @@ namespace Sass {
Document::~Document()
{ --context.ref_count; }
static Document Document::make_from_file(Context& ctx, string path)
Document Document::make_from_file(Context& ctx, string path)
{
std::FILE *f;
f = std::fopen(path.c_str(), "rb");
......@@ -55,7 +56,7 @@ namespace Sass {
return doc;
}
static Document Document::make_from_source_chars(Context& ctx, char* src, string path)
Document Document::make_from_source_chars(Context& ctx, char* src, string path)
{
Document doc(ctx);
doc.path = path;
......@@ -70,7 +71,7 @@ namespace Sass {
return doc;
}
static Document Document::make_from_token(Context& ctx, Token t, string path, size_t line_number)
Document Document::make_from_token(Context& ctx, Token t, string path, size_t line_number)
{
Document doc(ctx);
doc.path = path;
......
......@@ -4,6 +4,7 @@
#include "node.hpp"
#endif
#include "prelexer.hpp"
#include "context.hpp"
namespace Sass {
......@@ -32,6 +33,7 @@ namespace Sass {
Document(Context& ctx);
~Document();
public:
Document(const Document& doc);
static Document make_from_file(Context& ctx, string path);
static Document make_from_source_chars(Context& ctx, char* src, string path = "");
......@@ -144,26 +146,14 @@ namespace Sass {
Node parse_term();
Node parse_factor();
Node parse_value();
Node parse_identifier();
Node parse_variable();
Node parse_function_call();
Node parse_string();
Node parse_value_schema();
const char* lookahead_for_selector(const char* start = 0);
const char* look_for_rule(const char* start = 0);
const char* look_for_values(const char* start = 0);
const char* look_for_selector_group(const char* start = 0);
const char* look_for_selector(const char* start = 0);
const char* look_for_simple_selector_sequence(const char* start = 0);
const char* look_for_simple_selector(const char* start = 0);
const char* look_for_pseudo(const char* start = 0);
const char* look_for_attrib(const char* start = 0);
void syntax_error(string message, size_t ln = 0);
void read_error(string message, size_t ln = 0);
void throw_syntax_error(string message, size_t ln = 0);
void throw_read_error(string message, size_t ln = 0);
string emit_css(CSS_Style style);
......
......@@ -176,7 +176,7 @@ namespace Sass {
Node& operator<<(Node n);
Node& operator+=(Node n);
bool boolean_value() const;
bool& boolean_value() const;
double numeric_value() const;
Token token() const;
Token unit() const;
......@@ -268,7 +268,7 @@ namespace Sass {
void pop_back()
{ children.pop_back(); }
bool boolean_value()
bool& boolean_value()
{ return value.boolean; }
double numeric_value();
......@@ -320,7 +320,7 @@ namespace Sass {
for (size_t i = 0, L = n.size(); i < L; ++i) push_back(n[i]);
return *this;
}
inline bool Node::boolean_value() const { return ip_->boolean_value(); }
inline bool& Node::boolean_value() const { return ip_->boolean_value(); }
inline double Node::numeric_value() const { return ip_->numeric_value(); }
inline Token Node::token() const { return ip_->value.token; }
inline Token Node::unit() const { return ip_->unit(); }
......
......@@ -35,21 +35,31 @@ namespace Sass {
}
// for making leaf nodes out of terminals/tokens
Node Node_Factory::operator()(Node::Type type, string file, size_t line, const Token& t)
Node Node_Factory::operator()(Node::Type type, string file, size_t line, Token& t)
{
Node_Impl* ip = alloc_Node_Impl(type, file, line);
ip->value.token = t;
return Node(ip);
}
// for making interior nodes that have children
// for making boolean values or interior nodes that have children
Node Node_Factory::operator()(Node::Type type, string file, size_t line, size_t size)
{
Node_Impl* ip = alloc_Node_Impl(type, file, line);
ip->children.reserve(size);
if (type == Node::boolean) ip->value.boolean = size;
else ip->children.reserve(size);
return Node(ip);
}
// Node Node_Factory::operator()(Node::Type type, string file, size_t line, bool b)
// {
// Node_Impl* ip = alloc_Node_Impl(type, file, line);
// ip->content.boolean_value = b;
// return Node(ip);
// }
// for making nodes representing numbers
Node Node_Factory::operator()(string file, size_t line, double v)
{
......
......@@ -19,9 +19,11 @@ namespace Sass {
// for cloning nodes
Node operator()(const Node& n1);
// for making leaf nodes out of terminals/tokens
Node operator()(Node::Type type, string file, size_t line, const Token& t);
// for making interior nodes that have children
Node operator()(Node::Type type, string file, size_t line, Token& t);
// for making boolean values or interior nodes that have children
Node operator()(Node::Type type, string file, size_t line, size_t size);
// // for making nodes representing boolean values
// Node operator()(Node::Type type, string file, size_t line, bool b);
// for making nodes representing numbers
Node operator()(string file, size_t line, double v);
// for making nodes representing numeric dimensions (e.g. 5px, 3em)
......
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