view release on metacpan or search on metacpan
libsass/sass-spec/spec/libsass/css-import/expected_output.css
libsass/sass-spec/spec/libsass/css-import/input.scss
libsass/sass-spec/spec/libsass/default-args/expected_output.css
libsass/sass-spec/spec/libsass/default-args/input.scss
libsass/sass-spec/spec/libsass/default-parameters/expected_output.css
libsass/sass-spec/spec/libsass/default-parameters/input.scss
libsass/sass-spec/spec/libsass/default-vars-in-default-params/expected_output.css
libsass/sass-spec/spec/libsass/default-vars-in-default-params/input.scss
libsass/sass-spec/spec/libsass/delayed/expected_output.css
libsass/sass-spec/spec/libsass/delayed/input.scss
libsass/sass-spec/spec/libsass/directives-in-propsets/expected_output.css
libsass/sass-spec/spec/libsass/directives-in-propsets/input.scss
libsass/sass-spec/spec/libsass/directives/expected_output.css
libsass/sass-spec/spec/libsass/directives/input.scss
libsass/sass-spec/spec/libsass/div/expected_output.css
libsass/sass-spec/spec/libsass/div/input.scss
libsass/sass-spec/spec/libsass/each-in-function/expected_output.css
libsass/sass-spec/spec/libsass/each-in-function/input.scss
libsass/sass-spec/spec/libsass/each/expected_output.css
libsass/sass-spec/spec/libsass/each/input.scss
libsass/sass-spec/spec/libsass/env/expected_output.css
libsass/sass-spec/spec/libsass/env/input.scss
libsass/sass-spec/spec/libsass/ie-backslash/expected_output.css
libsass/sass-spec/spec/libsass/ie-backslash/input.scss
libsass/sass-spec/spec/libsass/ie-functions/expected_output.css
libsass/sass-spec/spec/libsass/ie-functions/input.scss
libsass/sass-spec/spec/libsass/ie-hex-str/expected_output.css
libsass/sass-spec/spec/libsass/ie-hex-str/input.scss
libsass/sass-spec/spec/libsass/if-in-function/expected_output.css
libsass/sass-spec/spec/libsass/if-in-function/input.scss
libsass/sass-spec/spec/libsass/if-in-mixin/expected_output.css
libsass/sass-spec/spec/libsass/if-in-mixin/input.scss
libsass/sass-spec/spec/libsass/if-in-propset/expected_output.css
libsass/sass-spec/spec/libsass/if-in-propset/input.scss
libsass/sass-spec/spec/libsass/if/expected_output.css
libsass/sass-spec/spec/libsass/if/input.scss
libsass/sass-spec/spec/libsass/image-url/expected_output.css
libsass/sass-spec/spec/libsass/image-url/input.scss
libsass/sass-spec/spec/libsass/imp/expected_output.css
libsass/sass-spec/spec/libsass/imp/input.scss
libsass/sass-spec/spec/libsass/import/expected_output.css
libsass/sass-spec/spec/libsass/import/input.scss
libsass/sass-spec/spec/libsass/important-in-arglist/expected_output.css
libsass/sass-spec/spec/libsass/important-in-arglist/input.scss
libsass/sass-spec/spec/libsass/numbers/expected_output.css
libsass/sass-spec/spec/libsass/numbers/input.scss
libsass/sass-spec/spec/libsass/odd-selectors/expected_output.css
libsass/sass-spec/spec/libsass/odd-selectors/input.scss
libsass/sass-spec/spec/libsass/percentages/expected_output.css
libsass/sass-spec/spec/libsass/percentages/input.scss
libsass/sass-spec/spec/libsass/placeholder/expected_output.css
libsass/sass-spec/spec/libsass/placeholder/input.scss
libsass/sass-spec/spec/libsass/precision/expected_output.css
libsass/sass-spec/spec/libsass/precision/input.scss
libsass/sass-spec/spec/libsass/propsets/expected_output.css
libsass/sass-spec/spec/libsass/propsets/input.scss
libsass/sass-spec/spec/libsass/quotes-in-interpolated-strings/expected_output.css
libsass/sass-spec/spec/libsass/quotes-in-interpolated-strings/input.scss
libsass/sass-spec/spec/libsass/rel/expected_output.css
libsass/sass-spec/spec/libsass/rel/input.scss
libsass/sass-spec/spec/libsass/retina-image/expected_output.css
libsass/sass-spec/spec/libsass/retina-image/input.scss
libsass/sass-spec/spec/libsass/scale/expected_output.css
libsass/sass-spec/spec/libsass/scale/input.scss
libsass/sass-spec/spec/libsass/selectors/expected_output.css
libsass/sass-spec/spec/libsass/selectors/input.scss
libsass/src/tests/comparable.scss
libsass/src/tests/composed-args.scss
libsass/src/tests/concat.scss
libsass/src/tests/cons-up.scss
libsass/src/tests/conversions.scss
libsass/src/tests/css-import.scss
libsass/src/tests/default-args.scss
libsass/src/tests/default-parameters.scss
libsass/src/tests/default-vars-in-default-params.scss
libsass/src/tests/delayed.scss
libsass/src/tests/directives-in-propsets.scss
libsass/src/tests/directives.scss
libsass/src/tests/div.scss
libsass/src/tests/each-in-function.scss
libsass/src/tests/each.scss
libsass/src/tests/empty-properties.scss
libsass/src/tests/empty-rule.scss
libsass/src/tests/env.scss
libsass/src/tests/eq.scss
libsass/src/tests/extend.scss
libsass/src/tests/foo-imp.scss
libsass/src/tests/functions.scss
libsass/src/tests/hey1.scss
libsass/src/tests/hey2.scss
libsass/src/tests/huge.scss
libsass/src/tests/hyphen-interpolated.scss
libsass/src/tests/ie-backslash.scss
libsass/src/tests/ie-functions.scss
libsass/src/tests/ie-hex-str.scss
libsass/src/tests/if-in-function.scss
libsass/src/tests/if-in-mixin.scss
libsass/src/tests/if-in-propset.scss
libsass/src/tests/if.scss
libsass/src/tests/image-url.scss
libsass/src/tests/imp.scss
libsass/src/tests/import-into-function.scss
libsass/src/tests/import.scss
libsass/src/tests/important-in-arglist.scss
libsass/src/tests/important.scss
libsass/src/tests/index.scss
libsass/src/tests/inh.scss
libsass/src/tests/inheritance.scss
libsass/src/tests/multiline-var.scss
libsass/src/tests/namespaces.scss
libsass/src/tests/negation.scss
libsass/src/tests/nested-extend.scss
libsass/src/tests/null.scss
libsass/src/tests/numbers.scss
libsass/src/tests/odd-selectors.scss
libsass/src/tests/percentages.scss
libsass/src/tests/placeholder.scss
libsass/src/tests/precision.scss
libsass/src/tests/propsets.scss
libsass/src/tests/quotes-in-interpolated-strings.scss
libsass/src/tests/rel.scss
libsass/src/tests/retina-image.scss
libsass/src/tests/return.scss
libsass/src/tests/scale.scss
libsass/src/tests/selectors.scss
libsass/src/tests/simple-inheritance.scss
libsass/src/tests/simple-lists.scss
libsass/src/tests/slice.scss
libsass/src/tests/strings.scss
libsass/ast.hpp view on Meta::CPAN
{ }
// nested rulesets need to be hoisted out of their enclosing blocks
bool is_hoistable() { return true; }
ATTACH_OPERATIONS();
};
/////////////////////////////////////////////////////////
// Nested declaration sets (i.e., namespaced properties).
/////////////////////////////////////////////////////////
class String;
class Propset : public Has_Block {
ADD_PROPERTY(String*, property_fragment);
public:
Propset(string p, size_t l, String* pf, Block* b = 0)
: Has_Block(p, l, b), property_fragment_(pf)
{ }
ATTACH_OPERATIONS();
};
/////////////////
// Media queries.
/////////////////
class List;
class Media_Block : public Has_Block {
libsass/ast_factory.hpp view on Meta::CPAN
namespace Sass {
using namespace std;
class AST_Factory {
vector<AST_Node*> nodes;
public:
// statements
Block* new_Block(string p, size_t l, size_t s = 0, bool r = false);
Ruleset* new_Ruleset(string p, size_t l, Selector* s, Block* b);
Propset* new_Propset(string p, size_t l, String* pf, Block* b);
Media_Query* new_Media_Query(string p, size_t l, List* q, Block* b);
At_Rule* new_At_Rule(string p, size_t l, string kwd, Selector* sel, Block* b);
Declaration* new_Declaration(string p, size_t l, String* prop, List* vals);
Assignment* new_Assignment(string p, size_t l, string var, Expression* val, bool guarded = false);
Import<Function_Call*>* new_CSS_Import(string p, size_t l, Function_Call* loc);
Import<String*>* new_SASS_Import(string p, size_t l, String* loc);
Warning* new_Warning(string p, size_t l, Expression* msg);
Comment* new_Comment(string p, size_t l, String* txt);
If* new_If(string p, size_t l, Expression* pred, Block* con, Block* alt = 0);
For* new_For(string p, size_t l, string var, Expression* lo, Expression* hi, Block* b, bool inc);
libsass/ast_fwd_decl.hpp view on Meta::CPAN
/////////////////////////////////////////////
// Forward declarations for the AST visitors.
/////////////////////////////////////////////
namespace Sass {
class AST_Node;
// statements
class Statement;
class Block;
class Ruleset;
class Propset;
class Media_Block;
class At_Rule;
class Declaration;
class Assignment;
class Import;
class Import_Stub;
class Warning;
class Comment;
class If;
class For;
libsass/expand.cpp view on Meta::CPAN
Selector* sel_ctx = r->selector()->perform(contextualize->with(selector_stack.back(), env, backtrace));
selector_stack.push_back(sel_ctx);
Ruleset* rr = new (ctx.mem) Ruleset(r->path(),
r->line(),
sel_ctx,
r->block()->perform(this)->block());
selector_stack.pop_back();
return rr;
}
Statement* Expand::operator()(Propset* p)
{
property_stack.push_back(p->property_fragment());
Block* expanded_block = p->block()->perform(this)->block();
Block* current_block = block_stack.back();
for (size_t i = 0, L = expanded_block->length(); i < L; ++i) {
Statement* stm = (*expanded_block)[i];
if (typeid(*stm) == typeid(Declaration)) {
Declaration* dec = static_cast<Declaration*>(stm);
String_Schema* combined_prop = new (ctx.mem) String_Schema(p->path(), p->line());
libsass/expand.hpp view on Meta::CPAN
Statement* fallback_impl(AST_Node* n);
public:
Expand(Context&, Eval*, Contextualize*, Env*, Backtrace*);
virtual ~Expand() { }
using Operation<Statement*>::operator();
Statement* operator()(Block*);
Statement* operator()(Ruleset*);
Statement* operator()(Propset*);
Statement* operator()(Media_Block*);
Statement* operator()(At_Rule*);
Statement* operator()(Declaration*);
Statement* operator()(Assignment*);
Statement* operator()(Import*);
Statement* operator()(Import_Stub*);
Statement* operator()(Warning*);
Statement* operator()(Comment*);
Statement* operator()(If*);
Statement* operator()(For*);
libsass/inspect.cpp view on Meta::CPAN
buffer.erase(l-1);
}
}
void Inspect::operator()(Ruleset* ruleset)
{
ruleset->selector()->perform(this);
ruleset->block()->perform(this);
}
void Inspect::operator()(Propset* propset)
{
propset->property_fragment()->perform(this);
buffer += ": ";
propset->block()->perform(this);
}
void Inspect::operator()(Media_Block* media_block)
{
buffer += "@media ";
media_block->media_queries()->perform(this);
media_block->block()->perform(this);
}
void Inspect::operator()(At_Rule* at_rule)
libsass/inspect.hpp view on Meta::CPAN
public:
Inspect(Context* ctx = 0);
virtual ~Inspect();
string get_buffer() { return buffer; }
// statements
virtual void operator()(Block*);
virtual void operator()(Ruleset*);
virtual void operator()(Propset*);
virtual void operator()(Media_Block*);
virtual void operator()(At_Rule*);
virtual void operator()(Declaration*);
virtual void operator()(Assignment*);
virtual void operator()(Import*);
virtual void operator()(Import_Stub*);
virtual void operator()(Warning*);
virtual void operator()(Comment*);
virtual void operator()(If*);
virtual void operator()(For*);
libsass/old/ast_node.hpp view on Meta::CPAN
{ }
// nested rulesets need to be hoisted out of their enclosing blocks
bool hoistable() { return true; }
ATTACH_OPERATIONS();
};
/////////////////////////////////////////////////////////
// Nested declaration sets (i.e., namespaced properties).
/////////////////////////////////////////////////////////
struct String;
struct Propset : public Has_Block {
String* property_fragment;
Propset(string p, size_t l, String* pf, Block* b)
: Has_Block(p, l, b), property_fragment(pf)
{ }
ATTACH_OPERATIONS();
};
/////////////////
// Media queries.
/////////////////
struct List;
struct Media_Query : public Has_Block {
libsass/old/document.hpp view on Meta::CPAN
Node parse_import();
Node parse_include();
Node parse_mixin_definition();
Node parse_function_definition();
Node parse_parameters();
Node parse_parameter(Node::Type);
Node parse_mixin_call(Node::Type inside_of = Node::none);
Node parse_arguments();
Node parse_argument(Node::Type);
Node parse_assignment();
Node parse_propset();
Node parse_ruleset(Selector_Lookahead lookahead, Node::Type inside_of = Node::none);
Node parse_selector_schema(const char* end_of_selector);
Node parse_selector_group();
Node parse_selector();
Node parse_selector_combinator();
Node parse_simple_selector_sequence();
Node parse_simple_selector();
Node parse_pseudo();
Node parse_attribute_selector();
Node parse_block(Node surrounding_ruleset, Node::Type inside_of = Node::none);
libsass/old/document_parser.cpp view on Meta::CPAN
root << parse_mixin_definition();
}
else if (peek< function >()) {
root << parse_function_definition();
}
else if (peek< variable >()) {
root << parse_assignment();
if (!lex< exactly<';'> >()) throw_syntax_error("top-level variable binding must be terminated by ';'");
}
else if (peek< sequence< optional< exactly<'*'> >, alternatives< identifier_schema, identifier >, optional_spaces, exactly<':'>, optional_spaces, exactly<'{'> > >(position)) {
root << parse_propset();
}
else if ((lookahead_result = lookahead_for_selector(position)).found) {
root << parse_ruleset(lookahead_result);
}
else if (peek< include >() /* || peek< exactly<'+'> >() */) {
Node mixin_call(parse_mixin_call());
root << mixin_call;
if (mixin_call.size() < 3 && !lex< exactly<';'> >()) throw_syntax_error("top-level @include directive must be terminated by ';'");
}
else if (peek< if_directive >()) {
libsass/old/document_parser.cpp view on Meta::CPAN
lex< variable >();
Node var(context.new_Node(Node::variable, path, line, lexed));
if (!lex< exactly<':'> >()) throw_syntax_error("expected ':' after " + lexed.to_string() + " in assignment statement");
Node val(parse_list());
Node assn(context.new_Node(Node::assignment, path, line, 2));
assn << var << val;
if (lex< default_flag >()) assn << context.new_Node(Node::none, path, line, 0);
return assn;
}
Node Document::parse_propset()
{
Node property_segment;
if (peek< sequence< optional< exactly<'*'> >, identifier_schema > >()) {
property_segment = parse_identifier_schema();
}
else {
lex< sequence< optional< exactly<'*'> >, identifier > >();
property_segment = context.new_Node(Node::identifier, path, line, lexed);
}
lex< exactly<':'> >();
Node block(parse_block(Node()));
// lex< exactly<'{'> >();
// Node block(context.new_Node(Node::block, path, line, 1));
// while (!lex< exactly<'}'> >()) {
// if (peek< sequence< optional< exactly<'*'> >, alternatives< identifier_schema, identifier >, optional_spaces, exactly<':'>, optional_spaces, exactly<'{'> > >(position)) {
// block << parse_propset();
// }
// else {
// block << parse_rule();
// lex< exactly<';'> >();
// }
// }
if (block.empty()) throw_syntax_error("namespaced property cannot be empty");
Node propset(context.new_Node(Node::propset, path, line, 2));
propset << property_segment;
propset << block;
return propset;
}
Node Document::parse_ruleset(Selector_Lookahead lookahead, Node::Type inside_of)
{
Node ruleset(context.new_Node(Node::ruleset, path, line, 3));
if (lookahead.has_interpolants) {
ruleset << parse_selector_schema(lookahead.found);
}
else {
ruleset << parse_selector_group();
libsass/old/document_parser.cpp view on Meta::CPAN
semicolon = (the_call.size() == 3) ? false : true;
}
else if (lex< content >()) {
if (inside_of != Node::mixin) {
throw_syntax_error("@content may only be used within a mixin");
}
block << context.new_Node(Node::mixin_content, path, line, 0); // just an expansion stub
semicolon = true;
}
else if (peek< sequence< optional< exactly<'*'> >, alternatives< identifier_schema, identifier >, optional_spaces, exactly<':'>, optional_spaces, exactly<'{'> > >(position)) {
block << parse_propset();
}
else if (peek < keyframes >()) {
block << parse_keyframes(inside_of);
}
else if (peek< sequence< keyf, optional_spaces, exactly<'{'> > >()) {
block << parse_keyframe(inside_of);
}
else if ((lookahead_result = lookahead_for_selector(position)).found) {
block << parse_ruleset(lookahead_result, inside_of);
}
libsass/old/document_parser.cpp view on Meta::CPAN
if (peek< exactly<'{'> >()) {
Node inner(parse_block(Node()));
block << inner;
}
}
else if (!peek< exactly<';'> >()) {
Node rule(parse_rule());
// check for lbrace; if it's there, we have a namespace property with a value
if (peek< exactly<'{'> >()) {
Node inner(parse_block(Node()));
Node propset(context.new_Node(Node::propset, path, line, 2));
propset << rule[0];
rule[0] = context.new_Node(Node::property, path, line, Token::make());
inner.push_front(rule);
propset << inner;
block << propset;
}
else {
block << rule;
semicolon = true;
}
}
else lex< exactly<';'> >();
while (lex< block_comment >()) {
block << context.new_Node(Node::comment, path, line, lexed);
}
libsass/old/eval_apply.cpp view on Meta::CPAN
case Node::mixin_content: {
if (!content.is_null()) {
expr += new_Node(content);
for (size_t i = 0, S = expr.size(); i < S; ++i) {
re_expand(expr[i], prefix, env, f_env, new_Node, ctx, bt, false, content);
}
}
} break;
case Node::propset: {
// TO DO: perform the property expansion here, rather than in the emitter (also requires the parser to allow interpolants in the property names)
expr[0] = eval(expr[0], prefix, env, f_env, new_Node, ctx, bt);
expand(expr[1], prefix, env, f_env, new_Node, ctx, bt, false, content);
// Node block(expr[1]);
// for (size_t i = 0, S = block.size(); i < S; ++i) {
// Node stm(block[i]);
// switch (stm.type())
// {
// case Node::propset:
// case Node::mixin_call:
// case Node::if_directive:
// case Node::for_through_directive:
// case Node::for_to_directive:
// case Node::each_directive:
// case Node::while_directive:
// case Node::warning: {
// expand(stm, prefix, env, f_env, new_Node, ctx, bt, false, content);
// } break;
// }
libsass/old/node.hpp view on Meta::CPAN
public:
enum Type {
none,
any,
numeric, // number, numeric_percentage, or numeric_dimension
string_t, // string_constant, identifier, concatenation, schemata
comment,
root,
ruleset,
propset,
media_query,
keyframes,
keyframe,
selector_group,
selector,
selector_combinator,
simple_selector_sequence,
backref,
libsass/old/node.hpp view on Meta::CPAN
bool operator==(Node rhs) const;
bool operator!=(Node rhs) const;
bool operator<(Node rhs) const;
bool operator<=(Node rhs) const;
bool operator>(Node rhs) const;
bool operator>=(Node rhs) const;
string to_string(Type inside_of = none, const string space = " ", const bool in_media_feature = false) const;
void emit_nested_css(stringstream& buf, size_t depth, bool at_toplevel = false, bool in_media_query = false, int source_comments = false);
void emit_propset(stringstream& buf, size_t depth, const string& prefix, const bool compressed = false);
void echo(stringstream& buf, size_t depth = 0);
void emit_expanded_css(stringstream& buf, const string& prefix);
void emit_compressed_css(stringstream& buf);
Sass_Value to_c_val();
};
// The actual implementation object for Nodes; Node handles point at these.
struct Node_Impl {
union value_t {
libsass/old/node.hpp view on Meta::CPAN
has_children = true;
if (n.is_null()) return;
switch (n.type())
{
case Node::comment: {
has_comments = true;
} break;
case Node::css_import:
case Node::rule:
case Node::propset:
case Node::warning:
case Node::keyframe:
case Node::block_directive:
case Node::blockless_directive: {
has_statements = true;
} break;
case Node::media_query:
case Node::keyframes:
case Node::ruleset: {
libsass/old/node.hpp view on Meta::CPAN
void push_front(const Node& n)
{
children.insert(children.begin(), n);
has_children = true;
switch (n.type())
{
case Node::comment: has_comments = true; break;
case Node::css_import:
case Node::rule:
case Node::propset: has_statements = true; break;
case Node::media_query:
case Node::keyframes:
case Node::ruleset: has_blocks = true; break;
case Node::if_directive:
case Node::for_through_directive:
case Node::for_to_directive:
case Node::each_directive:
case Node::while_directive:
libsass/old/node_emitters.cpp view on Meta::CPAN
buf << sel_group.to_string();
buf << " {";
for (size_t i = 0, S = block.size(); i < S; ++i) {
Type stm_type = block[i].type();
if (stm_type == block_directive) buf << endl;
switch (stm_type)
{
case comment:
case rule:
case css_import:
case propset:
case block_directive:
case blockless_directive:
case keyframes:
case warning: {
block[i].emit_nested_css(buf, depth+1, false, false, source_comments);
} break;
default: break;
}
}
buf << " }";
libsass/old/node_emitters.cpp view on Meta::CPAN
} break;
case block: {
if (has_expansions()) flatten();
for (size_t i = 0, S = size(); i < S; ++i) {
Type stm_type = at(i).type();
switch (stm_type)
{
case rule:
case css_import:
case propset:
case block_directive:
case keyframe:
case blockless_directive:
case warning: {
at(i).emit_nested_css(buf, depth, false, false, source_comments);
if (i != S - 1) buf << endl << endl;
} break;
default: break;
}
libsass/old/node_emitters.cpp view on Meta::CPAN
buf << at(2).to_string();
buf << " {";
for (size_t i = 0, S = block.size(); i < S; ++i) {
Type stm_type = block[i].type();
if (stm_type == block_directive) buf << endl;
switch (stm_type)
{
case comment:
case rule:
case css_import:
case propset:
case block_directive:
case blockless_directive:
case warning: {
// if (stm_type != comment) buf << endl;
block[i].emit_nested_css(buf, depth+1, false, false, source_comments);
} break;
default: break;
}
}
libsass/old/node_emitters.cpp view on Meta::CPAN
break;
default:
break;
}
block[i].emit_nested_css(buf, depth+1, false, in_media_query, source_comments);
}
buf << " }" << endl;
if ((depth == 0) && at_toplevel && !in_media_query) buf << endl;
} break;
case propset: {
emit_propset(buf, depth, "");
} break;
case rule: {
buf << endl << string(2*depth, ' ');
buf << to_string();
// at(0).emit_nested_css(buf, depth); // property
// at(1).emit_nested_css(buf, depth); // values
buf << ";";
} break;
libsass/old/node_emitters.cpp view on Meta::CPAN
if (block.has_expansions()) block.flatten();
if (block.has_statements()) {
buf << sel_group.to_string(none, "") << "{";
for (size_t i = 0, S = block.size(); i < S; ++i) {
Type stm_type = block[i].type();
switch (stm_type)
{
case rule:
case css_import:
case propset:
case block_directive:
case blockless_directive:
case warning: {
block[i].emit_compressed_css(buf);
} break;
default: break;
}
}
buf << "}";
}
libsass/old/node_emitters.cpp view on Meta::CPAN
case block: {
if (has_expansions()) flatten();
buf << "{";
for (size_t i = 0, S = size(); i < S; ++i) {
Type stm_type = at(i).type();
switch (stm_type)
{
case rule:
case css_import:
case propset:
case block_directive:
case keyframe:
case blockless_directive:
case warning: {
at(i).emit_compressed_css(buf);
} break;
default: break;
}
}
libsass/old/node_emitters.cpp view on Meta::CPAN
bool has_statements = block.has_statements();
if (has_statements) {
buf << at(2).to_string(none, "");
buf << "{";
for (size_t i = 0, S = block.size(); i < S; ++i) {
Type stm_type = block[i].type();
switch (stm_type)
{
case rule:
case css_import:
case propset:
case block_directive:
case blockless_directive:
case warning: {
block[i].emit_compressed_css(buf);
} break;
default: break;
}
}
buf << "}";
libsass/old/node_emitters.cpp view on Meta::CPAN
Node block(at(1));
if (block.has_expansions()) block.flatten();
buf << header.to_string(none, "");
buf << "{";
for (size_t i = 0, S = block.size(); i < S; ++i) {
block[i].emit_compressed_css(buf);
}
buf << "}";
} break;
case propset: {
emit_propset(buf, 0, "", true);
} break;
case rule: {
buf << to_string(none, "");
buf << ";";
} break;
case css_import: {
buf << to_string(none, "");
buf << ";";
libsass/old/node_emitters.cpp view on Meta::CPAN
case comment: {
// do nothing
} break;
default: {
buf << to_string(none, "");
} break;
}
}
void Node::emit_propset(stringstream& buf, size_t depth, const string& prefix, const bool compressed)
{
string new_prefix(prefix);
// bool has_prefix = false;
if (new_prefix.empty()) {
if (!compressed) {
new_prefix += "\n";
new_prefix += string(2*depth, ' ');
}
new_prefix += at(0).to_string();
}
else {
new_prefix += "-";
new_prefix += at(0).to_string();
// has_prefix = true;
}
Node rules(at(1));
rules.flatten();
for (size_t i = 0, S = rules.size(); i < S; ++i) {
if (rules[i].type() == propset) {
rules[i].emit_propset(buf, depth+1, new_prefix, compressed);
}
else if (rules[i].type() == rule) {
buf << new_prefix;
if (rules[i][0].to_string() != "") buf << '-';
if (!compressed) {
rules[i][0].emit_nested_css(buf, depth);
if (rules[i][0].type() == identifier_schema) buf << ": ";
rules[i][1].emit_nested_css(buf, depth);
}
else {
libsass/operation.hpp view on Meta::CPAN
namespace Sass {
template<typename T>
class Operation {
public:
virtual T operator()(AST_Node* x) = 0;
virtual ~Operation() { }
// statements
virtual T operator()(Block* x) = 0;
virtual T operator()(Ruleset* x) = 0;
virtual T operator()(Propset* x) = 0;
virtual T operator()(Media_Block* x) = 0;
virtual T operator()(At_Rule* x) = 0;
virtual T operator()(Declaration* x) = 0;
virtual T operator()(Assignment* x) = 0;
virtual T operator()(Import* x) = 0;
virtual T operator()(Import_Stub* x) = 0;
virtual T operator()(Warning* x) = 0;
virtual T operator()(Comment* x) = 0;
virtual T operator()(If* x) = 0;
virtual T operator()(For* x) = 0;
libsass/operation.hpp view on Meta::CPAN
};
template <typename T, typename D>
class Operation_CRTP : public Operation<T> {
public:
virtual T operator()(AST_Node* x) { return static_cast<D*>(this)->fallback(x); }
virtual ~Operation_CRTP() = 0;
// statements
virtual T operator()(Block* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Ruleset* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Propset* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Media_Block* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(At_Rule* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Declaration* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Assignment* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Import* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Import_Stub* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Warning* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Comment* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(If* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(For* x) { return static_cast<D*>(this)->fallback(x); }
libsass/output_compressed.hpp view on Meta::CPAN
public:
Output_Compressed(Context* ctx = 0);
virtual ~Output_Compressed();
string get_buffer() { return buffer; }
// statements
virtual void operator()(Block*);
virtual void operator()(Ruleset*);
// virtual void operator()(Propset*);
virtual void operator()(Media_Block*);
virtual void operator()(At_Rule*);
virtual void operator()(Declaration*);
// virtual void operator()(Assignment*);
// virtual void operator()(Import*);
// virtual void operator()(Import_Stub*);
// virtual void operator()(Warning*);
virtual void operator()(Comment*);
// virtual void operator()(If*);
// virtual void operator()(For*);
libsass/output_nested.hpp view on Meta::CPAN
public:
Output_Nested(bool source_comments = false, Context* ctx = 0);
virtual ~Output_Nested();
string get_buffer() { return buffer; }
// statements
virtual void operator()(Block*);
virtual void operator()(Ruleset*);
// virtual void operator()(Propset*);
virtual void operator()(Media_Block*);
virtual void operator()(At_Rule*);
// virtual void operator()(Declaration*);
// virtual void operator()(Assignment*);
// virtual void operator()(Import*);
// virtual void operator()(Import_Stub*);
// virtual void operator()(Warning*);
// virtual void operator()(Comment*);
// virtual void operator()(If*);
// virtual void operator()(For*);
libsass/parser.cpp view on Meta::CPAN
if (!lex< exactly<';'> >()) error("top-level @import directive must be terminated by ';'");
}
else if (peek< mixin >() || peek< function >()) {
(*root) << parse_definition();
}
else if (peek< variable >()) {
(*root) << parse_assignment();
if (!lex< exactly<';'> >()) error("top-level variable binding must be terminated by ';'");
}
else if (peek< sequence< optional< exactly<'*'> >, alternatives< identifier_schema, identifier >, optional_spaces, exactly<':'>, optional_spaces, exactly<'{'> > >(position)) {
(*root) << parse_propset();
}
else if (peek< include >() /* || peek< exactly<'+'> >() */) {
Mixin_Call* mixin_call = parse_mixin_call();
(*root) << mixin_call;
if (!mixin_call->block() && !lex< exactly<';'> >()) error("top-level @include directive must be terminated by ';'");
}
else if (peek< if_directive >()) {
(*root) << parse_if_directive();
}
else if (peek< for_directive >()) {
libsass/parser.cpp view on Meta::CPAN
string name(lexed);
size_t var_line = line;
if (!lex< exactly<':'> >()) error("expected ':' after " + name + " in assignment statement");
Expression* val = parse_list();
val->is_delayed(false);
bool is_guarded = lex< default_flag >();
Assignment* var = new (ctx.mem) Assignment(path, var_line, name, val, is_guarded);
return var;
}
Propset* Parser::parse_propset()
{
String* property_segment;
if (peek< sequence< optional< exactly<'*'> >, identifier_schema > >()) {
property_segment = parse_identifier_schema();
}
else {
lex< sequence< optional< exactly<'*'> >, identifier > >();
property_segment = new (ctx.mem) String_Constant(path, line, lexed);
}
Propset* propset = new (ctx.mem) Propset(path, line, property_segment);
lex< exactly<':'> >();
if (!peek< exactly<'{'> >()) error("expected a '{' after namespaced property");
propset->block(parse_block());
return propset;
}
Ruleset* Parser::parse_ruleset(Selector_Lookahead lookahead)
{
Selector* sel;
if (lookahead.has_interpolants) {
sel = parse_selector_schema(lookahead.found);
}
else {
sel = parse_selector_group();
libsass/parser.cpp view on Meta::CPAN
}
else if (peek< at_keyword >()) {
At_Rule* at_rule = parse_at_rule();
(*block) << at_rule;
if (!at_rule->block()) semicolon = true;
}
else if ((lookahead_result = lookahead_for_selector(position)).found) {
(*block) << parse_ruleset(lookahead_result);
}
else if (peek< sequence< optional< exactly<'*'> >, alternatives< identifier_schema, identifier >, optional_spaces, exactly<':'>, optional_spaces, exactly<'{'> > >(position)) {
(*block) << parse_propset();
}
else if (!peek< exactly<';'> >()) {
if (peek< sequence< optional< exactly<'*'> >, identifier_schema, exactly<':'>, exactly<'{'> > >()) {
(*block) << parse_propset();
}
else if (peek< sequence< optional< exactly<'*'> >, identifier, exactly<':'>, exactly<'{'> > >()) {
(*block) << parse_propset();
}
else {
Declaration* decl = parse_declaration();
(*block) << decl;
if (peek< exactly<'{'> >()) {
// parse a propset that rides on the declaration's property
Propset* ps = new (ctx.mem) Propset(path, line, decl->property(), parse_block());
(*block) << ps;
}
else {
// finish and let the semicolon get munched
semicolon = true;
}
}
}
else lex< exactly<';'> >();
while (lex< block_comment >()) {
libsass/parser.hpp view on Meta::CPAN
Block* parse();
Import* parse_import();
Definition* parse_definition();
Parameters* parse_parameters();
Parameter* parse_parameter();
Mixin_Call* parse_mixin_call();
Arguments* parse_arguments();
Argument* parse_argument();
Assignment* parse_assignment();
Propset* parse_propset();
Ruleset* parse_ruleset(Selector_Lookahead lookahead);
Selector_Schema* parse_selector_schema(const char* end_of_selector);
Selector_Group* parse_selector_group();
Selector_Combination* parse_selector_combination();
Simple_Selector_Sequence* parse_simple_selector_sequence();
Simple_Selector* parse_simple_selector();
Negated_Selector* parse_negated_selector();
Pseudo_Selector* parse_pseudo_selector();
Attribute_Selector* parse_attribute_selector();
Block* parse_block();
libsass/src/ast.hpp view on Meta::CPAN
{ }
// nested rulesets need to be hoisted out of their enclosing blocks
bool is_hoistable() { return true; }
ATTACH_OPERATIONS();
};
/////////////////////////////////////////////////////////
// Nested declaration sets (i.e., namespaced properties).
/////////////////////////////////////////////////////////
class String;
class Propset : public Has_Block {
ADD_PROPERTY(String*, property_fragment);
public:
Propset(string p, size_t l, String* pf)
: Has_Block(p, l, 0), property_fragment_(pf)
{ }
ATTACH_OPERATIONS();
};
/////////////////
// Media queries.
/////////////////
class List;
class Media_Block : public Has_Block {
libsass/src/ast_factory.hpp view on Meta::CPAN
namespace Sass {
using namespace std;
class AST_Factory {
vector<AST_Node*> nodes;
public:
// statements
Block* new_Block(string p, size_t l, size_t s = 0, bool r = false);
Ruleset* new_Ruleset(string p, size_t l, Selector* s, Block* b);
Propset* new_Propset(string p, size_t l, String* pf, Block* b);
Media_Query* new_Media_Query(string p, size_t l, List* q, Block* b);
At_Rule* new_At_Rule(string p, size_t l, string kwd, Selector* sel, Block* b);
Declaration* new_Declaration(string p, size_t l, String* prop, List* vals);
Assignment* new_Assignment(string p, size_t l, string var, Expression* val, bool guarded = false);
Import<Function_Call*>* new_CSS_Import(string p, size_t l, Function_Call* loc);
Import<String*>* new_SASS_Import(string p, size_t l, String* loc);
Warning* new_Warning(string p, size_t l, Expression* msg);
Comment* new_Comment(string p, size_t l, String* txt);
If* new_If(string p, size_t l, Expression* pred, Block* con, Block* alt = 0);
For* new_For(string p, size_t l, string var, Expression* lo, Expression* hi, Block* b, bool inc);
libsass/src/ast_fwd_decl.hpp view on Meta::CPAN
/////////////////////////////////////////////
// Forward declarations for the AST visitors.
/////////////////////////////////////////////
namespace Sass {
class AST_Node;
// statements
class Statement;
class Block;
class Ruleset;
class Propset;
class Media_Block;
class At_Rule;
class Declaration;
class Assignment;
class Import;
class Import_Stub;
class Warning;
class Comment;
class If;
class For;
libsass/src/expand.cpp view on Meta::CPAN
Selector* sel_ctx = r->selector()->perform(contextualize->with(selector_stack.back(), env, backtrace));
selector_stack.push_back(sel_ctx);
Ruleset* rr = new (ctx.mem) Ruleset(r->path(),
r->line(),
sel_ctx,
r->block()->perform(this)->block());
selector_stack.pop_back();
return rr;
}
Statement* Expand::operator()(Propset* p)
{
property_stack.push_back(p->property_fragment());
Block* expanded_block = p->block()->perform(this)->block();
Block* current_block = block_stack.back();
for (size_t i = 0, L = expanded_block->length(); i < L; ++i) {
Statement* stm = (*expanded_block)[i];
if (typeid(*stm) == typeid(Declaration)) {
Declaration* dec = static_cast<Declaration*>(stm);
String_Schema* combined_prop = new (ctx.mem) String_Schema(p->path(), p->line());
libsass/src/expand.hpp view on Meta::CPAN
Statement* fallback_impl(AST_Node* n);
public:
Expand(Context&, Eval*, Contextualize*, Env*, Backtrace*);
virtual ~Expand() { }
using Operation<Statement*>::operator();
Statement* operator()(Block*);
Statement* operator()(Ruleset*);
Statement* operator()(Propset*);
Statement* operator()(Media_Block*);
Statement* operator()(At_Rule*);
Statement* operator()(Declaration*);
Statement* operator()(Assignment*);
Statement* operator()(Import*);
Statement* operator()(Import_Stub*);
Statement* operator()(Warning*);
Statement* operator()(Comment*);
Statement* operator()(If*);
Statement* operator()(For*);
libsass/src/inspect.cpp view on Meta::CPAN
buffer.erase(l-1);
}
}
void Inspect::operator()(Ruleset* ruleset)
{
ruleset->selector()->perform(this);
ruleset->block()->perform(this);
}
void Inspect::operator()(Propset* propset)
{
propset->property_fragment()->perform(this);
buffer += ": ";
// ++indentation;
// for (size_t i = 0, S = propset->declarations().size(); i < S; ++i) {
// indent();
// propset->declarations()[i]->perform(this);
// buffer += '\n';
// }
// for (size_t i = 0, S = propset->propsets().size(); i < S; ++i) {
// indent();
// propset->propsets()[i]->perform(this);
// buffer += '\n';
// }
// --indentation;
// buffer += "}";
propset->block()->perform(this);
}
void Inspect::operator()(Media_Block* media_block)
{
buffer += "@media ";
media_block->media_queries()->perform(this);
media_block->block()->perform(this);
}
void Inspect::operator()(At_Rule* at_rule)
libsass/src/inspect.hpp view on Meta::CPAN
public:
Inspect();
virtual ~Inspect();
string get_buffer() { return buffer; }
// statements
virtual void operator()(Block*);
virtual void operator()(Ruleset*);
virtual void operator()(Propset*);
virtual void operator()(Media_Block*);
virtual void operator()(At_Rule*);
virtual void operator()(Declaration*);
virtual void operator()(Assignment*);
virtual void operator()(Import*);
virtual void operator()(Import_Stub*);
virtual void operator()(Warning*);
virtual void operator()(Comment*);
virtual void operator()(If*);
virtual void operator()(For*);
libsass/src/operation.hpp view on Meta::CPAN
namespace Sass {
template<typename T>
class Operation {
public:
virtual T operator()(AST_Node* x) = 0;
virtual ~Operation() { }
// statements
virtual T operator()(Block* x) = 0;
virtual T operator()(Ruleset* x) = 0;
virtual T operator()(Propset* x) = 0;
virtual T operator()(Media_Block* x) = 0;
virtual T operator()(At_Rule* x) = 0;
virtual T operator()(Declaration* x) = 0;
virtual T operator()(Assignment* x) = 0;
virtual T operator()(Import* x) = 0;
virtual T operator()(Import_Stub* x) = 0;
virtual T operator()(Warning* x) = 0;
virtual T operator()(Comment* x) = 0;
virtual T operator()(If* x) = 0;
virtual T operator()(For* x) = 0;
libsass/src/operation.hpp view on Meta::CPAN
};
template <typename T, typename D>
class Operation_CRTP : public Operation<T> {
public:
virtual T operator()(AST_Node* x) { return static_cast<D*>(this)->fallback(x); }
virtual ~Operation_CRTP() = 0;
// statements
virtual T operator()(Block* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Ruleset* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Propset* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Media_Block* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(At_Rule* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Declaration* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Assignment* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Import* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Import_Stub* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Warning* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Comment* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(If* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(For* x) { return static_cast<D*>(this)->fallback(x); }
libsass/src/output_compressed.hpp view on Meta::CPAN
public:
Output_Compressed();
virtual ~Output_Compressed();
string get_buffer() { return buffer; }
// statements
virtual void operator()(Block*);
virtual void operator()(Ruleset*);
// virtual void operator()(Propset*);
virtual void operator()(Media_Block*);
virtual void operator()(At_Rule*);
virtual void operator()(Declaration*);
// virtual void operator()(Assignment*);
// virtual void operator()(Import*);
// virtual void operator()(Import_Stub*);
// virtual void operator()(Warning*);
// virtual void operator()(Comment*);
// virtual void operator()(If*);
// virtual void operator()(For*);
libsass/src/output_nested.hpp view on Meta::CPAN
public:
Output_Nested();
virtual ~Output_Nested();
string get_buffer() { return buffer; }
// statements
virtual void operator()(Block*);
virtual void operator()(Ruleset*);
// virtual void operator()(Propset*);
virtual void operator()(Media_Block*);
virtual void operator()(At_Rule*);
// virtual void operator()(Declaration*);
// virtual void operator()(Assignment*);
// virtual void operator()(Import*);
// virtual void operator()(Import_Stub*);
// virtual void operator()(Warning*);
// virtual void operator()(Comment*);
// virtual void operator()(If*);
// virtual void operator()(For*);
libsass/src/parser.cpp view on Meta::CPAN
if (!lex< exactly<';'> >()) error("top-level @import directive must be terminated by ';'");
}
else if (peek< mixin >() || peek< function >()) {
(*root) << parse_definition();
}
else if (peek< variable >()) {
(*root) << parse_assignment();
if (!lex< exactly<';'> >()) error("top-level variable binding must be terminated by ';'");
}
else if (peek< sequence< optional< exactly<'*'> >, alternatives< identifier_schema, identifier >, optional_spaces, exactly<':'>, optional_spaces, exactly<'{'> > >(position)) {
(*root) << parse_propset();
}
else if (peek< include >() /* || peek< exactly<'+'> >() */) {
Mixin_Call* mixin_call = parse_mixin_call();
(*root) << mixin_call;
if (!mixin_call->block() && !lex< exactly<';'> >()) error("top-level @include directive must be terminated by ';'");
}
else if (peek< if_directive >()) {
(*root) << parse_if_directive();
}
else if (peek< for_directive >()) {
libsass/src/parser.cpp view on Meta::CPAN
string name(lexed);
size_t var_line = line;
if (!lex< exactly<':'> >()) error("expected ':' after " + name + " in assignment statement");
Expression* val = parse_list();
val->is_delayed(false);
bool is_guarded = lex< default_flag >();
Assignment* var = new (ctx.mem) Assignment(path, var_line, name, val, is_guarded);
return var;
}
Propset* Parser::parse_propset()
{
String* property_segment;
if (peek< sequence< optional< exactly<'*'> >, identifier_schema > >()) {
property_segment = parse_identifier_schema();
}
else {
lex< sequence< optional< exactly<'*'> >, identifier > >();
property_segment = new (ctx.mem) String_Constant(path, line, lexed);
}
Propset* propset = new (ctx.mem) Propset(path, line, property_segment);
lex< exactly<':'> >();
if (!peek< exactly<'{'> >()) error("expected a '{' after namespaced property");
propset->block(parse_block());
return propset;
}
Ruleset* Parser::parse_ruleset(Selector_Lookahead lookahead)
{
Selector* sel;
if (lookahead.has_interpolants) {
sel = parse_selector_schema(lookahead.found);
}
else {
sel = parse_selector_group();
libsass/src/parser.cpp view on Meta::CPAN
}
else if (peek< at_keyword >()) {
At_Rule* at_rule = parse_at_rule();
(*block) << at_rule;
if (!at_rule->block()) semicolon = true;
}
else if ((lookahead_result = lookahead_for_selector(position)).found) {
(*block) << parse_ruleset(lookahead_result);
}
else if (peek< sequence< optional< exactly<'*'> >, alternatives< identifier_schema, identifier >, optional_spaces, exactly<':'>, optional_spaces, exactly<'{'> > >(position)) {
(*block) << parse_propset();
}
else if (!peek< exactly<';'> >()) {
if (peek< sequence< optional< exactly<'*'> >, identifier_schema, exactly<':'>, exactly<'{'> > >()) {
(*block) << parse_propset();
}
else if (peek< sequence< optional< exactly<'*'> >, identifier, exactly<':'>, exactly<'{'> > >()) {
(*block) << parse_propset();
}
else {
(*block) << parse_declaration();
semicolon = true;
}
}
else lex< exactly<';'> >();
while (lex< block_comment >()) {
String_Constant* contents = new (ctx.mem) String_Constant(path, line, lexed);
Comment* comment = new (ctx.mem) Comment(path, line, contents);