Text-Sass-XS
view release on metacpan or search on metacpan
libsass/ast.hpp view on Meta::CPAN
};
inline Statement::~Statement() { }
////////////////////////
// Blocks of statements.
////////////////////////
class Block : public Statement, public Vectorized<Statement*> {
ADD_PROPERTY(bool, is_root);
// needed for properly formatted CSS emission
ADD_PROPERTY(bool, has_hoistable);
ADD_PROPERTY(bool, has_non_hoistable);
protected:
void adjust_after_pushing(Statement* s)
{
if (s->is_hoistable()) has_hoistable_ = true;
else has_non_hoistable_ = true;
};
public:
Block(string p, size_t l, size_t s = 0, bool r = false)
: Statement(p, l),
Vectorized<Statement*>(s),
is_root_(r), has_hoistable_(false), has_non_hoistable_(false)
{ }
Block* block() { return this; }
ATTACH_OPERATIONS();
};
////////////////////////////////////////////////////////////////////////
// Abstract base class for statements that contain blocks of statements.
////////////////////////////////////////////////////////////////////////
class Has_Block : public Statement {
ADD_PROPERTY(Block*, block);
public:
Has_Block(string p, size_t l, Block* b)
: Statement(p, l), block_(b)
{ }
virtual ~Has_Block() = 0;
};
inline Has_Block::~Has_Block() { }
/////////////////////////////////////////////////////////////////////////////
// Rulesets (i.e., sets of styles headed by a selector and containing a block
// of style declarations.
/////////////////////////////////////////////////////////////////////////////
class Selector;
class Ruleset : public Has_Block {
ADD_PROPERTY(Selector*, selector);
public:
Ruleset(string p, size_t l, Selector* s, Block* b)
: Has_Block(p, l, b), selector_(s)
{ }
// 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 {
ADD_PROPERTY(List*, media_queries);
ADD_PROPERTY(Selector*, enclosing_selector);
public:
Media_Block(string p, size_t l, List* mqs, Block* b)
: Has_Block(p, l, b), media_queries_(mqs), enclosing_selector_(0)
{ }
bool is_hoistable() { return true; }
ATTACH_OPERATIONS();
};
///////////////////////////////////////////////////////////////////////
// At-rules -- arbitrary directives beginning with "@" that may have an
// optional statement block.
///////////////////////////////////////////////////////////////////////
class At_Rule : public Has_Block {
ADD_PROPERTY(string, keyword);
ADD_PROPERTY(Selector*, selector);
public:
At_Rule(string p, size_t l, string kwd, Selector* sel = 0, Block* b = 0)
: Has_Block(p, l, b), keyword_(kwd), selector_(sel)
{ }
ATTACH_OPERATIONS();
};
////////////////////////////////////////////////////////////////////////
// Declarations -- style rules consisting of a property name and values.
////////////////////////////////////////////////////////////////////////
class Declaration : public Statement {
ADD_PROPERTY(String*, property);
ADD_PROPERTY(Expression*, value);
ADD_PROPERTY(bool, is_important);
public:
Declaration(string p, size_t l,
String* prop, Expression* val, bool i = false)
: Statement(p, l), property_(prop), value_(val), is_important_(i)
{ }
ATTACH_OPERATIONS();
};
/////////////////////////////////////
// Assignments -- variable and value.
/////////////////////////////////////
class Variable;
class Expression;
class Assignment : public Statement {
ADD_PROPERTY(string, variable);
ADD_PROPERTY(Expression*, value);
ADD_PROPERTY(bool, is_guarded);
public:
Assignment(string p, size_t l,
( run in 1.227 second using v1.01-cache-2.11-cpan-71847e10f99 )