Commit 909199cf by Aaron Leung

Renaming a variable/method.

parent e2021333
...@@ -16,7 +16,7 @@ namespace Sass { ...@@ -16,7 +16,7 @@ namespace Sass {
source(doc.source), source(doc.source),
position(doc.position), position(doc.position),
end(doc.end), end(doc.end),
line_number(doc.line_number), line(doc.line),
own_source(doc.own_source), own_source(doc.own_source),
context(doc.context), context(doc.context),
root(doc.root), root(doc.root),
...@@ -44,7 +44,7 @@ namespace Sass { ...@@ -44,7 +44,7 @@ namespace Sass {
Document doc(ctx); Document doc(ctx);
doc.path = path; doc.path = path;
doc.line_number = 1; doc.line = 1;
doc.root = ctx.new_Node(Node::root, path, 1, 0); doc.root = ctx.new_Node(Node::root, path, 1, 0);
doc.lexed = Token::make(); doc.lexed = Token::make();
doc.own_source = true; doc.own_source = true;
...@@ -60,7 +60,7 @@ namespace Sass { ...@@ -60,7 +60,7 @@ namespace Sass {
{ {
Document doc(ctx); Document doc(ctx);
doc.path = path; doc.path = path;
doc.line_number = 1; doc.line = 1;
doc.root = ctx.new_Node(Node::root, path, 1, 0); doc.root = ctx.new_Node(Node::root, path, 1, 0);
doc.lexed = Token::make(); doc.lexed = Token::make();
doc.own_source = false; doc.own_source = false;
...@@ -75,7 +75,7 @@ namespace Sass { ...@@ -75,7 +75,7 @@ namespace Sass {
{ {
Document doc(ctx); Document doc(ctx);
doc.path = path; doc.path = path;
doc.line_number = line_number; doc.line = line_number;
doc.root = ctx.new_Node(Node::root, path, 1, 0); doc.root = ctx.new_Node(Node::root, path, 1, 0);
doc.lexed = Token::make(); doc.lexed = Token::make();
doc.own_source = false; doc.own_source = false;
...@@ -87,10 +87,10 @@ namespace Sass { ...@@ -87,10 +87,10 @@ namespace Sass {
} }
void Document::throw_syntax_error(string message, size_t ln) void Document::throw_syntax_error(string message, size_t ln)
{ throw Error(Error::syntax, ln ? ln : line_number, path, message); } { throw Error(Error::syntax, ln ? ln : line, path, message); }
void Document::throw_read_error(string message, size_t ln) void Document::throw_read_error(string message, size_t ln)
{ throw Error(Error::read, ln ? ln : line_number, path, message); } { throw Error(Error::read, ln ? ln : line, path, message); }
using std::string; using std::string;
using std::stringstream; using std::stringstream;
......
...@@ -20,7 +20,7 @@ namespace Sass { ...@@ -20,7 +20,7 @@ namespace Sass {
char* source; char* source;
const char* position; const char* position;
const char* end; const char* end;
size_t line_number; size_t line;
bool own_source; bool own_source;
Context& context; Context& context;
...@@ -89,7 +89,7 @@ namespace Sass { ...@@ -89,7 +89,7 @@ namespace Sass {
else if (mx == spaces) { else if (mx == spaces) {
after_whitespace = spaces(position); after_whitespace = spaces(position);
if (after_whitespace) { if (after_whitespace) {
line_number += count_interval<'\n'>(position, after_whitespace); line += count_interval<'\n'>(position, after_whitespace);
lexed = Token::make(position, after_whitespace); lexed = Token::make(position, after_whitespace);
return position = after_whitespace; return position = after_whitespace;
} }
...@@ -105,7 +105,7 @@ namespace Sass { ...@@ -105,7 +105,7 @@ namespace Sass {
} }
const char* after_token = mx(after_whitespace); const char* after_token = mx(after_whitespace);
if (after_token) { if (after_token) {
line_number += count_interval<'\n'>(position, after_token); line += count_interval<'\n'>(position, after_token);
lexed = Token::make(after_whitespace, after_token); lexed = Token::make(after_whitespace, after_token);
return position = after_token; return position = after_token;
} }
......
...@@ -12,7 +12,7 @@ namespace Sass { ...@@ -12,7 +12,7 @@ namespace Sass {
lex< optional_spaces >(); lex< optional_spaces >();
while (position < end) { while (position < end) {
if (lex< block_comment >()) { if (lex< block_comment >()) {
root << context.new_Node(Node::comment, path, line_number, lexed); root << context.new_Node(Node::comment, path, line, lexed);
} }
else if (peek< import >()) { else if (peek< import >()) {
Node importee(parse_import()); Node importee(parse_import());
...@@ -52,7 +52,7 @@ namespace Sass { ...@@ -52,7 +52,7 @@ namespace Sass {
{ {
if (peek< string_constant >()) { if (peek< string_constant >()) {
Node schema(parse_string()); Node schema(parse_string());
Node importee(context.new_Node(Node::css_import, path, line_number, 1)); Node importee(context.new_Node(Node::css_import, path, line, 1));
importee << schema; importee << schema;
if (!lex< exactly<')'> >()) throw_syntax_error("unterminated url in @import directive"); if (!lex< exactly<')'> >()) throw_syntax_error("unterminated url in @import directive");
return importee; return importee;
...@@ -61,8 +61,8 @@ namespace Sass { ...@@ -61,8 +61,8 @@ namespace Sass {
const char* beg = position; const char* beg = position;
const char* end = find_first< exactly<')'> >(position); const char* end = find_first< exactly<')'> >(position);
if (!end) throw_syntax_error("unterminated url in @import directive"); if (!end) throw_syntax_error("unterminated url in @import directive");
Node path_node(context.new_Node(Node::identifier, path, line_number, Token::make(beg, end))); Node path_node(context.new_Node(Node::identifier, path, line, Token::make(beg, end)));
Node importee(context.new_Node(Node::css_import, path, line_number, 1)); Node importee(context.new_Node(Node::css_import, path, line, 1));
importee << path_node; importee << path_node;
position = end; position = end;
lex< exactly<')'> >(); lex< exactly<')'> >();
...@@ -94,18 +94,18 @@ namespace Sass { ...@@ -94,18 +94,18 @@ namespace Sass {
{ {
lex< mixin >() || lex< exactly<'='> >(); lex< mixin >() || lex< exactly<'='> >();
if (!lex< identifier >()) throw_syntax_error("invalid name in @mixin directive"); if (!lex< identifier >()) throw_syntax_error("invalid name in @mixin directive");
Node name(context.new_Node(Node::identifier, path, line_number, lexed)); Node name(context.new_Node(Node::identifier, path, line, lexed));
Node params(parse_mixin_parameters()); Node params(parse_mixin_parameters());
if (!peek< exactly<'{'> >()) throw_syntax_error("body for mixin " + name.token().to_string() + " must begin with a '{'"); if (!peek< exactly<'{'> >()) throw_syntax_error("body for mixin " + name.token().to_string() + " must begin with a '{'");
Node body(parse_block(true)); Node body(parse_block(true));
Node the_mixin(context.new_Node(Node::mixin, path, line_number, 3)); Node the_mixin(context.new_Node(Node::mixin, path, line, 3));
the_mixin << name << params << body; the_mixin << name << params << body;
return the_mixin; return the_mixin;
} }
Node Document::parse_mixin_parameters() Node Document::parse_mixin_parameters()
{ {
Node params(context.new_Node(Node::parameters, path, line_number, 0)); Node params(context.new_Node(Node::parameters, path, line, 0));
Token name(lexed); Token name(lexed);
if (lex< exactly<'('> >()) { if (lex< exactly<'('> >()) {
if (peek< variable >()) { if (peek< variable >()) {
...@@ -123,10 +123,10 @@ namespace Sass { ...@@ -123,10 +123,10 @@ namespace Sass {
Node Document::parse_parameter() { Node Document::parse_parameter() {
lex< variable >(); lex< variable >();
Node var(context.new_Node(Node::variable, path, line_number, lexed)); Node var(context.new_Node(Node::variable, path, line, lexed));
if (lex< exactly<':'> >()) { // default value if (lex< exactly<':'> >()) { // default value
Node val(parse_space_list()); Node val(parse_space_list());
Node par_and_val(context.new_Node(Node::assignment, path, line_number, 2)); Node par_and_val(context.new_Node(Node::assignment, path, line, 2));
par_and_val << var << val; par_and_val << var << val;
return par_and_val; return par_and_val;
} }
...@@ -141,9 +141,9 @@ namespace Sass { ...@@ -141,9 +141,9 @@ namespace Sass {
{ {
lex< include >() || lex< exactly<'+'> >(); lex< include >() || lex< exactly<'+'> >();
if (!lex< identifier >()) throw_syntax_error("invalid name in @include directive"); if (!lex< identifier >()) throw_syntax_error("invalid name in @include directive");
Node name(context.new_Node(Node::identifier, path, line_number, lexed)); Node name(context.new_Node(Node::identifier, path, line, lexed));
Node args(parse_arguments()); Node args(parse_arguments());
Node the_call(context.new_Node(Node::expansion, path, line_number, 2)); Node the_call(context.new_Node(Node::expansion, path, line, 2));
the_call << name << args; the_call << name << args;
return the_call; return the_call;
} }
...@@ -151,7 +151,7 @@ namespace Sass { ...@@ -151,7 +151,7 @@ namespace Sass {
Node Document::parse_arguments() Node Document::parse_arguments()
{ {
Token name(lexed); Token name(lexed);
Node args(context.new_Node(Node::arguments, path, line_number, 0)); Node args(context.new_Node(Node::arguments, path, line, 0));
if (lex< exactly<'('> >()) { if (lex< exactly<'('> >()) {
if (!peek< exactly<')'> >(position)) { if (!peek< exactly<')'> >(position)) {
Node arg(parse_argument()); Node arg(parse_argument());
...@@ -172,10 +172,10 @@ namespace Sass { ...@@ -172,10 +172,10 @@ namespace Sass {
{ {
if (peek< sequence < variable, spaces_and_comments, exactly<':'> > >()) { if (peek< sequence < variable, spaces_and_comments, exactly<':'> > >()) {
lex< variable >(); lex< variable >();
Node var(context.new_Node(Node::variable, path, line_number, lexed)); Node var(context.new_Node(Node::variable, path, line, lexed));
lex< exactly<':'> >(); lex< exactly<':'> >();
Node val(parse_space_list()); Node val(parse_space_list());
Node assn(context.new_Node(Node::assignment, path, line_number, 2)); Node assn(context.new_Node(Node::assignment, path, line, 2));
assn << var << val; assn << var << val;
return assn; return assn;
} }
...@@ -187,10 +187,10 @@ namespace Sass { ...@@ -187,10 +187,10 @@ namespace Sass {
Node Document::parse_assignment() Node Document::parse_assignment()
{ {
lex< variable >(); lex< variable >();
Node var(context.new_Node(Node::variable, path, line_number, lexed)); Node var(context.new_Node(Node::variable, path, line, lexed));
if (!lex< exactly<':'> >()) throw_syntax_error("expected ':' after " + lexed.to_string() + " in assignment statement"); if (!lex< exactly<':'> >()) throw_syntax_error("expected ':' after " + lexed.to_string() + " in assignment statement");
Node val(parse_list()); Node val(parse_list());
Node assn(context.new_Node(Node::assignment, path, line_number, 2)); Node assn(context.new_Node(Node::assignment, path, line, 2));
assn << var << val; assn << var << val;
return assn; return assn;
} }
...@@ -198,10 +198,10 @@ namespace Sass { ...@@ -198,10 +198,10 @@ namespace Sass {
Node Document::parse_propset() Node Document::parse_propset()
{ {
lex< identifier >(); lex< identifier >();
Node property_segment(context.new_Node(Node::identifier, path, line_number, lexed)); Node property_segment(context.new_Node(Node::identifier, path, line, lexed));
lex< exactly<':'> >(); lex< exactly<':'> >();
lex< exactly<'{'> >(); lex< exactly<'{'> >();
Node block(context.new_Node(Node::block, path, line_number, 1)); Node block(context.new_Node(Node::block, path, line, 1));
while (!lex< exactly<'}'> >()) { while (!lex< exactly<'}'> >()) {
if (peek< sequence< identifier, optional_spaces, exactly<':'>, optional_spaces, exactly<'{'> > >(position)) { if (peek< sequence< identifier, optional_spaces, exactly<':'>, optional_spaces, exactly<'{'> > >(position)) {
block << parse_propset(); block << parse_propset();
...@@ -212,7 +212,7 @@ namespace Sass { ...@@ -212,7 +212,7 @@ namespace Sass {
} }
} }
if (block.empty()) throw_syntax_error("namespaced property cannot be empty"); if (block.empty()) throw_syntax_error("namespaced property cannot be empty");
Node propset(context.new_Node(Node::propset, path, line_number, 2)); Node propset(context.new_Node(Node::propset, path, line, 2));
propset << property_segment; propset << property_segment;
propset << block; propset << block;
return propset; return propset;
...@@ -220,7 +220,7 @@ namespace Sass { ...@@ -220,7 +220,7 @@ namespace Sass {
Node Document::parse_ruleset(bool definition) Node Document::parse_ruleset(bool definition)
{ {
Node ruleset(context.new_Node(Node::ruleset, path, line_number, 2)); Node ruleset(context.new_Node(Node::ruleset, path, line, 2));
ruleset << parse_selector_group(); ruleset << parse_selector_group();
if (!peek< exactly<'{'> >()) throw_syntax_error("expected a '{' after the selector"); if (!peek< exactly<'{'> >()) throw_syntax_error("expected a '{' after the selector");
ruleset << parse_block(definition); ruleset << parse_block(definition);
...@@ -232,7 +232,7 @@ namespace Sass { ...@@ -232,7 +232,7 @@ namespace Sass {
Node sel1(parse_selector()); Node sel1(parse_selector());
if (!peek< exactly<','> >()) return sel1; if (!peek< exactly<','> >()) return sel1;
Node group(context.new_Node(Node::selector_group, path, line_number, 2)); Node group(context.new_Node(Node::selector_group, path, line, 2));
group << sel1; group << sel1;
while (lex< exactly<','> >()) group << parse_selector(); while (lex< exactly<','> >()) group << parse_selector();
return group; return group;
...@@ -245,7 +245,7 @@ namespace Sass { ...@@ -245,7 +245,7 @@ namespace Sass {
peek< exactly<')'> >() || peek< exactly<')'> >() ||
peek< exactly<'{'> >()) return seq1; peek< exactly<'{'> >()) return seq1;
Node selector(context.new_Node(Node::selector, path, line_number, 2)); Node selector(context.new_Node(Node::selector, path, line, 2));
selector << seq1; selector << seq1;
while (!peek< exactly<'{'> >() && !peek< exactly<','> >()) { while (!peek< exactly<'{'> >() && !peek< exactly<','> >()) {
...@@ -260,15 +260,15 @@ namespace Sass { ...@@ -260,15 +260,15 @@ namespace Sass {
if (lex< exactly<'+'> >() || if (lex< exactly<'+'> >() ||
lex< exactly<'~'> >() || lex< exactly<'~'> >() ||
lex< exactly<'>'> >()) lex< exactly<'>'> >())
{ return context.new_Node(Node::selector_combinator, path, line_number, lexed); } { return context.new_Node(Node::selector_combinator, path, line, lexed); }
// check for backref or type selector, which are only allowed at the front // check for backref or type selector, which are only allowed at the front
Node simp1; Node simp1;
if (lex< exactly<'&'> >()) { if (lex< exactly<'&'> >()) {
simp1 = context.new_Node(Node::backref, path, line_number, lexed); simp1 = context.new_Node(Node::backref, path, line, lexed);
} }
else if (lex< alternatives< type_selector, universal > >()) { else if (lex< alternatives< type_selector, universal > >()) {
simp1 = context.new_Node(Node::simple_selector, path, line_number, lexed); simp1 = context.new_Node(Node::simple_selector, path, line, lexed);
} }
else { else {
simp1 = parse_simple_selector(); simp1 = parse_simple_selector();
...@@ -282,7 +282,7 @@ namespace Sass { ...@@ -282,7 +282,7 @@ namespace Sass {
{ return simp1; } { return simp1; }
// otherwise, we have a sequence of simple selectors // otherwise, we have a sequence of simple selectors
Node seq(context.new_Node(Node::simple_selector_sequence, path, line_number, 2)); Node seq(context.new_Node(Node::simple_selector_sequence, path, line, 2));
seq << simp1; seq << simp1;
while (!peek< spaces >(position) && while (!peek< spaces >(position) &&
...@@ -301,13 +301,13 @@ namespace Sass { ...@@ -301,13 +301,13 @@ namespace Sass {
{ {
lex< exactly<'+'> >() || lex< exactly<'~'> >() || lex< exactly<'+'> >() || lex< exactly<'~'> >() ||
lex< exactly<'>'> >() || lex< ancestor_of >(); lex< exactly<'>'> >() || lex< ancestor_of >();
return context.new_Node(Node::selector_combinator, path, line_number, lexed); return context.new_Node(Node::selector_combinator, path, line, lexed);
} }
Node Document::parse_simple_selector() Node Document::parse_simple_selector()
{ {
if (lex< id_name >() || lex< class_name >()) { if (lex< id_name >() || lex< class_name >()) {
return context.new_Node(Node::simple_selector, path, line_number, lexed); return context.new_Node(Node::simple_selector, path, line, lexed);
} }
else if (peek< exactly<':'> >(position)) { else if (peek< exactly<':'> >(position)) {
return parse_pseudo(); return parse_pseudo();
...@@ -324,39 +324,39 @@ namespace Sass { ...@@ -324,39 +324,39 @@ namespace Sass {
Node Document::parse_pseudo() { Node Document::parse_pseudo() {
if (lex< pseudo_not >()) { if (lex< pseudo_not >()) {
Node ps_not(context.new_Node(Node::pseudo_negation, path, line_number, 2)); Node ps_not(context.new_Node(Node::pseudo_negation, path, line, 2));
ps_not << context.new_Node(Node::value, path, line_number, lexed); ps_not << context.new_Node(Node::value, path, line, lexed);
ps_not << parse_selector_group(); ps_not << parse_selector_group();
lex< exactly<')'> >(); lex< exactly<')'> >();
return ps_not; return ps_not;
} }
else if (lex< sequence< pseudo_prefix, functional > >()) { else if (lex< sequence< pseudo_prefix, functional > >()) {
Node pseudo(context.new_Node(Node::functional_pseudo, path, line_number, 2)); Node pseudo(context.new_Node(Node::functional_pseudo, path, line, 2));
Token name(lexed); Token name(lexed);
pseudo << context.new_Node(Node::value, path, line_number, name); pseudo << context.new_Node(Node::value, path, line, name);
if (lex< alternatives< even, odd > >()) { if (lex< alternatives< even, odd > >()) {
pseudo << context.new_Node(Node::value, path, line_number, lexed); pseudo << context.new_Node(Node::value, path, line, lexed);
} }
else if (peek< binomial >(position)) { else if (peek< binomial >(position)) {
lex< coefficient >(); lex< coefficient >();
pseudo << context.new_Node(Node::value, path, line_number, lexed); pseudo << context.new_Node(Node::value, path, line, lexed);
lex< exactly<'n'> >(); lex< exactly<'n'> >();
pseudo << context.new_Node(Node::value, path, line_number, lexed); pseudo << context.new_Node(Node::value, path, line, lexed);
lex< sign >(); lex< sign >();
pseudo << context.new_Node(Node::value, path, line_number, lexed); pseudo << context.new_Node(Node::value, path, line, lexed);
lex< digits >(); lex< digits >();
pseudo << context.new_Node(Node::value, path, line_number, lexed); pseudo << context.new_Node(Node::value, path, line, lexed);
} }
else if (lex< sequence< optional<sign>, else if (lex< sequence< optional<sign>,
optional<digits>, optional<digits>,
exactly<'n'> > >()) { exactly<'n'> > >()) {
pseudo << context.new_Node(Node::value, path, line_number, lexed); pseudo << context.new_Node(Node::value, path, line, lexed);
} }
else if (lex< sequence< optional<sign>, digits > >()) { else if (lex< sequence< optional<sign>, digits > >()) {
pseudo << context.new_Node(Node::value, path, line_number, lexed); pseudo << context.new_Node(Node::value, path, line, lexed);
} }
else if (lex< string_constant >()) { else if (lex< string_constant >()) {
pseudo << context.new_Node(Node::string_constant, path, line_number, lexed); pseudo << context.new_Node(Node::string_constant, path, line, lexed);
} }
else { else {
throw_syntax_error("invalid argument to " + name.to_string() + "...)"); throw_syntax_error("invalid argument to " + name.to_string() + "...)");
...@@ -365,7 +365,7 @@ namespace Sass { ...@@ -365,7 +365,7 @@ namespace Sass {
return pseudo; return pseudo;
} }
else if (lex < sequence< pseudo_prefix, identifier > >()) { else if (lex < sequence< pseudo_prefix, identifier > >()) {
return context.new_Node(Node::pseudo, path, line_number, lexed); return context.new_Node(Node::pseudo, path, line, lexed);
} }
else { else {
throw_syntax_error("unrecognized pseudo-class or pseudo-element"); throw_syntax_error("unrecognized pseudo-class or pseudo-element");
...@@ -376,19 +376,19 @@ namespace Sass { ...@@ -376,19 +376,19 @@ namespace Sass {
Node Document::parse_attribute_selector() Node Document::parse_attribute_selector()
{ {
Node attr_sel(context.new_Node(Node::attribute_selector, path, line_number, 3)); Node attr_sel(context.new_Node(Node::attribute_selector, path, line, 3));
lex< exactly<'['> >(); lex< exactly<'['> >();
if (!lex< type_selector >()) throw_syntax_error("invalid attribute name in attribute selector"); if (!lex< type_selector >()) throw_syntax_error("invalid attribute name in attribute selector");
Token name(lexed); Token name(lexed);
attr_sel << context.new_Node(Node::value, path, line_number, name); attr_sel << context.new_Node(Node::value, path, line, name);
if (lex< exactly<']'> >()) return attr_sel; if (lex< exactly<']'> >()) return attr_sel;
if (!lex< alternatives< exact_match, class_match, dash_match, if (!lex< alternatives< exact_match, class_match, dash_match,
prefix_match, suffix_match, substring_match > >()) { prefix_match, suffix_match, substring_match > >()) {
throw_syntax_error("invalid operator in attribute selector for " + name.to_string()); throw_syntax_error("invalid operator in attribute selector for " + name.to_string());
} }
attr_sel << context.new_Node(Node::value, path, line_number, lexed); attr_sel << context.new_Node(Node::value, path, line, lexed);
if (!lex< string_constant >()) throw_syntax_error("expected a quoted string constant in attribute selector for " + name.to_string()); if (!lex< string_constant >()) throw_syntax_error("expected a quoted string constant in attribute selector for " + name.to_string());
attr_sel << context.new_Node(Node::value, path, line_number, lexed); attr_sel << context.new_Node(Node::value, path, line, lexed);
if (!lex< exactly<']'> >()) throw_syntax_error("unterminated attribute selector for " + name.to_string()); if (!lex< exactly<']'> >()) throw_syntax_error("unterminated attribute selector for " + name.to_string());
return attr_sel; return attr_sel;
} }
...@@ -397,18 +397,18 @@ namespace Sass { ...@@ -397,18 +397,18 @@ namespace Sass {
{ {
lex< exactly<'{'> >(); lex< exactly<'{'> >();
bool semicolon = false; bool semicolon = false;
Node block(context.new_Node(Node::block, path, line_number, 0)); Node block(context.new_Node(Node::block, path, line, 0));
while (!lex< exactly<'}'> >()) { while (!lex< exactly<'}'> >()) {
if (semicolon) { if (semicolon) {
if (!lex< exactly<';'> >()) throw_syntax_error("non-terminal statement or declaration must end with ';'"); if (!lex< exactly<';'> >()) throw_syntax_error("non-terminal statement or declaration must end with ';'");
semicolon = false; semicolon = false;
while (lex< block_comment >()) { while (lex< block_comment >()) {
block << context.new_Node(Node::comment, path, line_number, lexed); block << context.new_Node(Node::comment, path, line, lexed);
} }
if (lex< exactly<'}'> >()) break; if (lex< exactly<'}'> >()) break;
} }
if (lex< block_comment >()) { if (lex< block_comment >()) {
block << context.new_Node(Node::comment, path, line_number, lexed); block << context.new_Node(Node::comment, path, line, lexed);
} }
else if (peek< import >(position)) { else if (peek< import >(position)) {
if (definition) { if (definition) {
...@@ -449,9 +449,9 @@ namespace Sass { ...@@ -449,9 +449,9 @@ namespace Sass {
// check for lbrace; if it's there, we have a namespace property with a value // check for lbrace; if it's there, we have a namespace property with a value
if (peek< exactly<'{'> >()) { if (peek< exactly<'{'> >()) {
Node inner(parse_block()); Node inner(parse_block());
Node propset(context.new_Node(Node::propset, path, line_number, 2)); Node propset(context.new_Node(Node::propset, path, line, 2));
propset << rule[0]; propset << rule[0];
rule[0] = context.new_Node(Node::property, path, line_number, Token::make()); rule[0] = context.new_Node(Node::property, path, line, Token::make());
// inner[0] = rule; // inner[0] = rule;
inner.push_front(rule); inner.push_front(rule);
propset << inner; propset << inner;
...@@ -465,19 +465,19 @@ namespace Sass { ...@@ -465,19 +465,19 @@ namespace Sass {
} }
else lex< exactly<';'> >(); else lex< exactly<';'> >();
while (lex< block_comment >()) { while (lex< block_comment >()) {
block << context.new_Node(Node::comment, path, line_number, lexed); block << context.new_Node(Node::comment, path, line, lexed);
} }
} }
return block; return block;
} }
Node Document::parse_rule() { Node Document::parse_rule() {
Node rule(context.new_Node(Node::rule, path, line_number, 2)); Node rule(context.new_Node(Node::rule, path, line, 2));
if (!lex< sequence< optional< exactly<'*'> >, identifier > >()) { if (!lex< sequence< optional< exactly<'*'> >, identifier > >()) {
lex< spaces_and_comments >(); // get the line number right lex< spaces_and_comments >(); // get the line number right
throw_syntax_error("invalid property name"); throw_syntax_error("invalid property name");
} }
rule << context.new_Node(Node::property, path, line_number, lexed); rule << context.new_Node(Node::property, path, line, lexed);
if (!lex< exactly<':'> >()) throw_syntax_error("property \"" + lexed.to_string() + "\" must be followed by a ':'"); if (!lex< exactly<':'> >()) throw_syntax_error("property \"" + lexed.to_string() + "\" must be followed by a ':'");
rule << parse_list(); rule << parse_list();
return rule; return rule;
...@@ -494,12 +494,12 @@ namespace Sass { ...@@ -494,12 +494,12 @@ namespace Sass {
peek< exactly<'}'> >(position) || peek< exactly<'}'> >(position) ||
peek< exactly<'{'> >(position) || peek< exactly<'{'> >(position) ||
peek< exactly<')'> >(position)) peek< exactly<')'> >(position))
{ return context.new_Node(Node::nil, path, line_number, 0); } { return context.new_Node(Node::nil, path, line, 0); }
Node list1(parse_space_list()); Node list1(parse_space_list());
// if it's a singleton, return it directly; don't wrap it // if it's a singleton, return it directly; don't wrap it
if (!peek< exactly<','> >(position)) return list1; if (!peek< exactly<','> >(position)) return list1;
Node comma_list(context.new_Node(Node::comma_list, path, line_number, 2)); Node comma_list(context.new_Node(Node::comma_list, path, line, 2));
comma_list << list1; comma_list << list1;
comma_list.should_eval() |= list1.should_eval(); comma_list.should_eval() |= list1.should_eval();
...@@ -524,7 +524,7 @@ namespace Sass { ...@@ -524,7 +524,7 @@ namespace Sass {
peek< exactly<','> >(position)) peek< exactly<','> >(position))
{ return disj1; } { return disj1; }
Node space_list(context.new_Node(Node::space_list, path, line_number, 2)); Node space_list(context.new_Node(Node::space_list, path, line, 2));
space_list << disj1; space_list << disj1;
space_list.should_eval() |= disj1.should_eval(); space_list.should_eval() |= disj1.should_eval();
...@@ -548,7 +548,7 @@ namespace Sass { ...@@ -548,7 +548,7 @@ namespace Sass {
// if it's a singleton, return it directly; don't wrap it // if it's a singleton, return it directly; don't wrap it
if (!peek< sequence< or_kwd, negate< identifier > > >()) return conj1; if (!peek< sequence< or_kwd, negate< identifier > > >()) return conj1;
Node disjunction(context.new_Node(Node::disjunction, path, line_number, 2)); Node disjunction(context.new_Node(Node::disjunction, path, line, 2));
disjunction << conj1; disjunction << conj1;
while (lex< sequence< or_kwd, negate< identifier > > >()) disjunction << parse_conjunction(); while (lex< sequence< or_kwd, negate< identifier > > >()) disjunction << parse_conjunction();
disjunction.should_eval() = true; disjunction.should_eval() = true;
...@@ -562,7 +562,7 @@ namespace Sass { ...@@ -562,7 +562,7 @@ namespace Sass {
// if it's a singleton, return it directly; don't wrap it // if it's a singleton, return it directly; don't wrap it
if (!peek< sequence< and_kwd, negate< identifier > > >()) return rel1; if (!peek< sequence< and_kwd, negate< identifier > > >()) return rel1;
Node conjunction(context.new_Node(Node::conjunction, path, line_number, 2)); Node conjunction(context.new_Node(Node::conjunction, path, line, 2));
conjunction << rel1; conjunction << rel1;
while (lex< sequence< and_kwd, negate< identifier > > >()) conjunction << parse_relation(); while (lex< sequence< and_kwd, negate< identifier > > >()) conjunction << parse_relation();
conjunction.should_eval() = true; conjunction.should_eval() = true;
...@@ -581,16 +581,16 @@ namespace Sass { ...@@ -581,16 +581,16 @@ namespace Sass {
peek< lte_op >(position))) peek< lte_op >(position)))
{ return expr1; } { return expr1; }
Node relation(context.new_Node(Node::relation, path, line_number, 3)); Node relation(context.new_Node(Node::relation, path, line, 3));
expr1.should_eval() = true; expr1.should_eval() = true;
relation << expr1; relation << expr1;
if (lex< eq_op >()) relation << context.new_Node(Node::eq, path, line_number, lexed); if (lex< eq_op >()) relation << context.new_Node(Node::eq, path, line, lexed);
else if (lex< neq_op >()) relation << context.new_Node(Node::neq, path, line_number, lexed); else if (lex< neq_op >()) relation << context.new_Node(Node::neq, path, line, lexed);
else if (lex< gte_op >()) relation << context.new_Node(Node::gte, path, line_number, lexed); else if (lex< gte_op >()) relation << context.new_Node(Node::gte, path, line, lexed);
else if (lex< lte_op >()) relation << context.new_Node(Node::lte, path, line_number, lexed); else if (lex< lte_op >()) relation << context.new_Node(Node::lte, path, line, lexed);
else if (lex< gt_op >()) relation << context.new_Node(Node::gt, path, line_number, lexed); else if (lex< gt_op >()) relation << context.new_Node(Node::gt, path, line, lexed);
else if (lex< lt_op >()) relation << context.new_Node(Node::lt, path, line_number, lexed); else if (lex< lt_op >()) relation << context.new_Node(Node::lt, path, line, lexed);
Node expr2(parse_expression()); Node expr2(parse_expression());
expr2.should_eval() = true; expr2.should_eval() = true;
...@@ -608,16 +608,16 @@ namespace Sass { ...@@ -608,16 +608,16 @@ namespace Sass {
peek< sequence< negate< number >, exactly<'-'> > >(position))) peek< sequence< negate< number >, exactly<'-'> > >(position)))
{ return term1; } { return term1; }
Node expression(context.new_Node(Node::expression, path, line_number, 3)); Node expression(context.new_Node(Node::expression, path, line, 3));
term1.should_eval() = true; term1.should_eval() = true;
expression << term1; expression << term1;
while (lex< exactly<'+'> >() || lex< sequence< negate< number >, exactly<'-'> > >()) { while (lex< exactly<'+'> >() || lex< sequence< negate< number >, exactly<'-'> > >()) {
if (lexed.begin[0] == '+') { if (lexed.begin[0] == '+') {
expression << context.new_Node(Node::add, path, line_number, lexed); expression << context.new_Node(Node::add, path, line, lexed);
} }
else { else {
expression << context.new_Node(Node::sub, path, line_number, lexed); expression << context.new_Node(Node::sub, path, line, lexed);
} }
Node term(parse_term()); Node term(parse_term());
term.should_eval() = true; term.should_eval() = true;
...@@ -636,17 +636,17 @@ namespace Sass { ...@@ -636,17 +636,17 @@ namespace Sass {
peek< exactly<'/'> >(position))) peek< exactly<'/'> >(position)))
{ return fact1; } { return fact1; }
Node term(context.new_Node(Node::term, path, line_number, 3)); Node term(context.new_Node(Node::term, path, line, 3));
term << fact1; term << fact1;
if (fact1.should_eval()) term.should_eval() = true; if (fact1.should_eval()) term.should_eval() = true;
while (lex< exactly<'*'> >() || lex< exactly<'/'> >()) { while (lex< exactly<'*'> >() || lex< exactly<'/'> >()) {
if (lexed.begin[0] == '*') { if (lexed.begin[0] == '*') {
term << context.new_Node(Node::mul, path, line_number, lexed); term << context.new_Node(Node::mul, path, line, lexed);
term.should_eval() = true; term.should_eval() = true;
} }
else { else {
term << context.new_Node(Node::div, path, line_number, lexed); term << context.new_Node(Node::div, path, line, lexed);
} }
Node fact(parse_factor()); Node fact(parse_factor());
term.should_eval() |= fact.should_eval(); term.should_eval() |= fact.should_eval();
...@@ -668,13 +668,13 @@ namespace Sass { ...@@ -668,13 +668,13 @@ namespace Sass {
return value; return value;
} }
else if (lex< sequence< exactly<'+'>, negate< number > > >()) { else if (lex< sequence< exactly<'+'>, negate< number > > >()) {
Node plus(context.new_Node(Node::unary_plus, path, line_number, 1)); Node plus(context.new_Node(Node::unary_plus, path, line, 1));
plus << parse_factor(); plus << parse_factor();
plus.should_eval() = true; plus.should_eval() = true;
return plus; return plus;
} }
else if (lex< sequence< exactly<'-'>, negate< number> > >()) { else if (lex< sequence< exactly<'-'>, negate< number> > >()) {
Node minus(context.new_Node(Node::unary_minus, path, line_number, 1)); Node minus(context.new_Node(Node::unary_minus, path, line, 1));
minus << parse_factor(); minus << parse_factor();
minus.should_eval() = true; minus.should_eval() = true;
return minus; return minus;
...@@ -693,48 +693,48 @@ namespace Sass { ...@@ -693,48 +693,48 @@ namespace Sass {
if (!rparen) throw_syntax_error("URI is missing ')'"); if (!rparen) throw_syntax_error("URI is missing ')'");
Token contents(Token::make(value, rparen)); Token contents(Token::make(value, rparen));
// lex< string_constant >(); // lex< string_constant >();
Node result(context.new_Node(Node::uri, path, line_number, contents)); Node result(context.new_Node(Node::uri, path, line, contents));
position = rparen; position = rparen;
lex< exactly<')'> >(); lex< exactly<')'> >();
return result; return result;
} }
if (lex< value_schema >()) if (lex< value_schema >())
{ return Document::make_from_token(context, lexed, path, line_number).parse_value_schema(); } { return Document::make_from_token(context, lexed, path, line).parse_value_schema(); }
if (lex< sequence< true_kwd, negate< identifier > > >()) if (lex< sequence< true_kwd, negate< identifier > > >())
{ return context.new_Node(Node::boolean, path, line_number, true); } { return context.new_Node(Node::boolean, path, line, true); }
if (lex< sequence< false_kwd, negate< identifier > > >()) if (lex< sequence< false_kwd, negate< identifier > > >())
{ return context.new_Node(Node::boolean, path, line_number, false); } { return context.new_Node(Node::boolean, path, line, false); }
if (peek< functional >()) if (peek< functional >())
{ return parse_function_call(); } { return parse_function_call(); }
if (lex< important >()) if (lex< important >())
{ return context.new_Node(Node::important, path, line_number, lexed); } { return context.new_Node(Node::important, path, line, lexed); }
if (lex< identifier >()) if (lex< identifier >())
{ return context.new_Node(Node::identifier, path, line_number, lexed); } { return context.new_Node(Node::identifier, path, line, lexed); }
if (lex< percentage >()) if (lex< percentage >())
{ return context.new_Node(Node::textual_percentage, path, line_number, lexed); } { return context.new_Node(Node::textual_percentage, path, line, lexed); }
if (lex< dimension >()) if (lex< dimension >())
{ return context.new_Node(Node::textual_dimension, path, line_number, lexed); } { return context.new_Node(Node::textual_dimension, path, line, lexed); }
if (lex< number >()) if (lex< number >())
{ return context.new_Node(Node::textual_number, path, line_number, lexed); } { return context.new_Node(Node::textual_number, path, line, lexed); }
if (lex< hex >()) if (lex< hex >())
{ return context.new_Node(Node::textual_hex, path, line_number, lexed); } { return context.new_Node(Node::textual_hex, path, line, lexed); }
if (peek< string_constant >()) if (peek< string_constant >())
{ return parse_string(); } { return parse_string(); }
if (lex< variable >()) if (lex< variable >())
{ {
Node var(context.new_Node(Node::variable, path, line_number, lexed)); Node var(context.new_Node(Node::variable, path, line, lexed));
var.should_eval() = true; var.should_eval() = true;
return var; return var;
} }
...@@ -756,23 +756,23 @@ namespace Sass { ...@@ -756,23 +756,23 @@ namespace Sass {
// see if there any interpolants // see if there any interpolants
const char* p = find_first_in_interval< sequence< negate< exactly<'\\'> >, exactly<hash_lbrace> > >(str.begin, str.end); const char* p = find_first_in_interval< sequence< negate< exactly<'\\'> >, exactly<hash_lbrace> > >(str.begin, str.end);
if (!p) { if (!p) {
return context.new_Node(Node::string_constant, path, line_number, str); return context.new_Node(Node::string_constant, path, line, str);
} }
Node schema(context.new_Node(Node::string_schema, path, line_number, 1)); Node schema(context.new_Node(Node::string_schema, path, line, 1));
while (i < str.end) { while (i < str.end) {
p = find_first_in_interval< sequence< negate< exactly<'\\'> >, exactly<hash_lbrace> > >(i, str.end); p = find_first_in_interval< sequence< negate< exactly<'\\'> >, exactly<hash_lbrace> > >(i, str.end);
if (p) { if (p) {
if (i < p) { if (i < p) {
schema << context.new_Node(Node::identifier, path, line_number, Token::make(i, p-2)); // accumulate the preceding segment if it's nonempty schema << context.new_Node(Node::identifier, path, line, Token::make(i, p-2)); // accumulate the preceding segment if it's nonempty
// cerr << '[' << Token::make(i,p-2).to_string() << ']' << endl; // cerr << '[' << Token::make(i,p-2).to_string() << ']' << endl;
} }
const char* j = find_first_in_interval< exactly<rbrace> >(p, str.end); // find the closing brace const char* j = find_first_in_interval< exactly<rbrace> >(p, str.end); // find the closing brace
if (j) { if (j) {
// parse the interpolant and accumulate it // parse the interpolant and accumulate it
// cerr << '[' << Token::make(p, j-1).to_string() << ']' << endl; // cerr << '[' << Token::make(p, j-1).to_string() << ']' << endl;
// Document interp_doc(path, line_number, Token::make(p,j-1), context); // Document interp_doc(path, line, Token::make(p,j-1), context);
Node interp_node(Document::make_from_token(context, Token::make(p, j-1), path, line_number).parse_list()); Node interp_node(Document::make_from_token(context, Token::make(p, j-1), path, line).parse_list());
// Node interp_node(interp_doc.parse_list()); // Node interp_node(interp_doc.parse_list());
interp_node.should_eval() = true; interp_node.should_eval() = true;
schema << interp_node; schema << interp_node;
...@@ -784,7 +784,7 @@ namespace Sass { ...@@ -784,7 +784,7 @@ namespace Sass {
} }
} }
else { // no interpolants left; add the last segment if nonempty else { // no interpolants left; add the last segment if nonempty
if (i < str.end) schema << context.new_Node(Node::identifier, path, line_number, Token::make(i, str.end)); if (i < str.end) schema << context.new_Node(Node::identifier, path, line, Token::make(i, str.end));
break; break;
} }
} }
...@@ -793,36 +793,36 @@ namespace Sass { ...@@ -793,36 +793,36 @@ namespace Sass {
Node Document::parse_value_schema() Node Document::parse_value_schema()
{ {
Node schema(context.new_Node(Node::value_schema, path, line_number, 1)); Node schema(context.new_Node(Node::value_schema, path, line, 1));
while (position < end) { while (position < end) {
if (lex< interpolant >()) { if (lex< interpolant >()) {
Token insides(Token::make(lexed.begin + 2, lexed.end - 1)); Token insides(Token::make(lexed.begin + 2, lexed.end - 1));
// Document interp_doc(path, line_number, insides, context); // Document interp_doc(path, line, insides, context);
// Node interp_node(interp_doc.parse_list()); // Node interp_node(interp_doc.parse_list());
Node interp_node(Document::make_from_token(context, insides, path, line_number).parse_list()); Node interp_node(Document::make_from_token(context, insides, path, line).parse_list());
schema << interp_node; schema << interp_node;
} }
else if (lex< identifier >()) { else if (lex< identifier >()) {
schema << context.new_Node(Node::identifier, path, line_number, lexed); schema << context.new_Node(Node::identifier, path, line, lexed);
} }
else if (lex< percentage >()) { else if (lex< percentage >()) {
schema << context.new_Node(Node::textual_percentage, path, line_number, lexed); schema << context.new_Node(Node::textual_percentage, path, line, lexed);
} }
else if (lex< dimension >()) { else if (lex< dimension >()) {
schema << context.new_Node(Node::textual_dimension, path, line_number, lexed); schema << context.new_Node(Node::textual_dimension, path, line, lexed);
} }
else if (lex< number >()) { else if (lex< number >()) {
schema << context.new_Node(Node::textual_number, path, line_number, lexed); schema << context.new_Node(Node::textual_number, path, line, lexed);
} }
else if (lex< hex >()) { else if (lex< hex >()) {
schema << context.new_Node(Node::textual_hex, path, line_number, lexed); schema << context.new_Node(Node::textual_hex, path, line, lexed);
} }
else if (lex< string_constant >()) { else if (lex< string_constant >()) {
schema << context.new_Node(Node::string_constant, path, line_number, lexed); schema << context.new_Node(Node::string_constant, path, line, lexed);
} }
else if (lex< variable >()) { else if (lex< variable >()) {
schema << context.new_Node(Node::variable, path, line_number, lexed); schema << context.new_Node(Node::variable, path, line, lexed);
} }
else { else {
throw_syntax_error("error parsing interpolated value"); throw_syntax_error("error parsing interpolated value");
...@@ -835,9 +835,9 @@ namespace Sass { ...@@ -835,9 +835,9 @@ namespace Sass {
Node Document::parse_function_call() Node Document::parse_function_call()
{ {
lex< identifier >(); lex< identifier >();
Node name(context.new_Node(Node::identifier, path, line_number, lexed)); Node 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_number, 2)); Node call(context.new_Node(Node::function_call, path, line, 2));
call << name << args; call << name << args;
call.should_eval() = true; call.should_eval() = true;
return call; return call;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
namespace Sass { namespace Sass {
using std::cerr; using std::endl; using std::cerr; using std::endl;
static void eval_error(string message, size_t line_number, const char* file_name) static void throw_eval_error(string message, size_t line_number, const char* file_name)
{ {
string fn; string fn;
if (file_name) { if (file_name) {
......
...@@ -11,10 +11,10 @@ ...@@ -11,10 +11,10 @@
namespace Sass { namespace Sass {
using std::map; using std::map;
Node eval(Node& expr, Environment& env, map<pair<string, size_t>, Function>& f_env, vector<vector<Node>*>& registry); Node eval(Node& expr, Environment& env, map<pair<string, size_t>, Function>& f_env, Node_Factory& new_Node);
Node accumulate(Node::Type op, Node& acc, Node& rhs, vector<vector<Node>*>& registry); Node accumulate(Node::Type op, Node& acc, Node& rhs, Node_Factory& new_Node);
double operate(Node::Type op, double lhs, double rhs); double operate(Node::Type op, double lhs, double rhs);
Node apply_mixin(Node& mixin, const Node& args, Environment& env, map<pair<string, size_t>, Function>& f_env, vector<vector<Node>*>& registry); Node apply_mixin(Node& mixin, const Node& args, Environment& env, map<pair<string, size_t>, Function>& f_env, Node_Factory& new_Node);
Node apply_function(const Function& f, const Node& args, Environment& env, map<pair<string, size_t>, Function>& f_env, vector<vector<Node>*>& registry); Node apply_function(const Function& f, const Node& args, Environment& env, map<pair<string, size_t>, Function>& f_env, Node_Factory& new_Node);
} }
\ No newline at end of file
...@@ -82,11 +82,11 @@ namespace Sass { ...@@ -82,11 +82,11 @@ namespace Sass {
return numeric_value() < rhs.numeric_value(); return numeric_value() < rhs.numeric_value();
} }
else { else {
throw Error(Error::evaluation, line_number(), file_name(), "incompatible units"); throw Error(Error::evaluation, line(), path(), "incompatible units");
} }
} }
else { else {
throw Error(Error::evaluation, line_number(), file_name(), "incomparable types"); throw Error(Error::evaluation, line(), path(), "incomparable types");
} }
} }
......
...@@ -163,8 +163,8 @@ namespace Sass { ...@@ -163,8 +163,8 @@ namespace Sass {
bool is_unquoted() const; bool is_unquoted() const;
bool is_numeric() const; bool is_numeric() const;
string& file_name() const; string& path() const;
size_t line_number() const; size_t line() const;
size_t size() const; size_t size() const;
bool empty() const; bool empty() const;
...@@ -200,8 +200,8 @@ namespace Sass { ...@@ -200,8 +200,8 @@ namespace Sass {
// TO DO: look into using a custom allocator in the Node_Factory class // TO DO: look into using a custom allocator in the Node_Factory class
vector<Node> children; // Can't be in the union because it has non-trivial constructors! vector<Node> children; // Can't be in the union because it has non-trivial constructors!
string file_name; string path;
size_t line_number; size_t line;
Node::Type type; Node::Type type;
...@@ -296,8 +296,8 @@ namespace Sass { ...@@ -296,8 +296,8 @@ namespace Sass {
inline bool Node::is_unquoted() const { return ip_->is_unquoted; } inline bool Node::is_unquoted() const { return ip_->is_unquoted; }
inline bool Node::is_numeric() const { return ip_->is_numeric(); } inline bool Node::is_numeric() const { return ip_->is_numeric(); }
inline string& Node::file_name() const { return ip_->file_name; } inline string& Node::path() const { return ip_->path; }
inline size_t Node::line_number() const { return ip_->line_number; } inline size_t Node::line() const { return ip_->line; }
inline size_t Node::size() const { return ip_->size(); } inline size_t Node::size() const { return ip_->size(); }
inline bool Node::empty() const { return ip_->empty(); } inline bool Node::empty() const { return ip_->empty(); }
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
namespace Sass { namespace Sass {
Node_Impl* Node_Factory::alloc_Node_Impl(Node::Type type, string file, size_t line) Node_Impl* Node_Factory::alloc_Node_Impl(Node::Type type, string path, size_t line)
{ {
Node_Impl* ip = new Node_Impl(); Node_Impl* ip = new Node_Impl();
ip->type = type; ip->type = type;
if (type == Node::backref) ip->has_backref = true; if (type == Node::backref) ip->has_backref = true;
ip->file_name = file; ip->path = path;
ip->line_number = line; ip->line = line;
pool_.push_back(ip); pool_.push_back(ip);
return ip; return ip;
} }
...@@ -35,17 +35,17 @@ namespace Sass { ...@@ -35,17 +35,17 @@ namespace Sass {
} }
// for making leaf nodes out of terminals/tokens // for making leaf nodes out of terminals/tokens
Node Node_Factory::operator()(Node::Type type, string file, size_t line, Token& t) Node Node_Factory::operator()(Node::Type type, string path, size_t line, Token& t)
{ {
Node_Impl* ip = alloc_Node_Impl(type, file, line); Node_Impl* ip = alloc_Node_Impl(type, path, line);
ip->value.token = t; ip->value.token = t;
return Node(ip); return Node(ip);
} }
// for making boolean values or 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 Node_Factory::operator()(Node::Type type, string path, size_t line, size_t size)
{ {
Node_Impl* ip = alloc_Node_Impl(type, file, line); Node_Impl* ip = alloc_Node_Impl(type, path, line);
if (type == Node::boolean) ip->value.boolean = size; if (type == Node::boolean) ip->value.boolean = size;
else ip->children.reserve(size); else ip->children.reserve(size);
...@@ -53,38 +53,38 @@ namespace Sass { ...@@ -53,38 +53,38 @@ namespace Sass {
return Node(ip); return Node(ip);
} }
// Node Node_Factory::operator()(Node::Type type, string file, size_t line, bool b) // Node Node_Factory::operator()(Node::Type type, string path, size_t line, bool b)
// { // {
// Node_Impl* ip = alloc_Node_Impl(type, file, line); // Node_Impl* ip = alloc_Node_Impl(type, path, line);
// ip->content.boolean_value = b; // ip->content.boolean_value = b;
// return Node(ip); // return Node(ip);
// } // }
// for making nodes representing numbers // for making nodes representing numbers
Node Node_Factory::operator()(string file, size_t line, double v) Node Node_Factory::operator()(string path, size_t line, double v)
{ {
Node_Impl* ip = alloc_Node_Impl(Node::number, file, line); Node_Impl* ip = alloc_Node_Impl(Node::number, path, line);
ip->value.numeric = v; ip->value.numeric = v;
return Node(ip); return Node(ip);
} }
// for making nodes representing numeric dimensions (e.g. 5px, 3em) // for making nodes representing numeric dimensions (e.g. 5px, 3em)
Node Node_Factory::operator()(string file, size_t line, double v, const Token& t) Node Node_Factory::operator()(string path, size_t line, double v, const Token& t)
{ {
Node_Impl* ip = alloc_Node_Impl(Node::numeric_dimension, file, line); Node_Impl* ip = alloc_Node_Impl(Node::numeric_dimension, path, line);
ip->value.dimension.numeric = v; ip->value.dimension.numeric = v;
ip->value.dimension.unit = t; ip->value.dimension.unit = t;
return Node(ip); return Node(ip);
} }
// for making nodes representing rgba color quads // for making nodes representing rgba color quads
Node Node_Factory::operator()(string file, size_t line, double r, double g, double b, double a) Node Node_Factory::operator()(string path, size_t line, double r, double g, double b, double a)
{ {
Node color((*this)(Node::numeric_color, file, line, 4)); Node color((*this)(Node::numeric_color, path, line, 4));
color << (*this)(file, line, r) color << (*this)(path, line, r)
<< (*this)(file, line, g) << (*this)(path, line, g)
<< (*this)(file, line, b) << (*this)(path, line, b)
<< (*this)(file, line, a); << (*this)(path, line, a);
return color; return color;
} }
......
...@@ -40,7 +40,7 @@ extern "C" { ...@@ -40,7 +40,7 @@ extern "C" {
using namespace Sass; using namespace Sass;
doc.parse_scss(); doc.parse_scss();
// cerr << "PARSED" << endl; // cerr << "PARSED" << endl;
eval(doc.root, doc.context.global_env, doc.context.function_env, doc.context.registry); eval(doc.root, doc.context.global_env, doc.context.function_env, doc.context.new_Node);
// cerr << "EVALUATED" << endl; // cerr << "EVALUATED" << endl;
string output(doc.emit_css(static_cast<Document::CSS_Style>(style))); string output(doc.emit_css(static_cast<Document::CSS_Style>(style)));
// cerr << "EMITTED" << endl; // cerr << "EMITTED" << endl;
......
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