本文整理汇总了C++中Comment::pstate方法的典型用法代码示例。如果您正苦于以下问题:C++ Comment::pstate方法的具体用法?C++ Comment::pstate怎么用?C++ Comment::pstate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comment
的用法示例。
在下文中一共展示了Comment::pstate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: debug_ast
inline void debug_ast(AST_Node* node, std::string ind, Env* env)
{
if (node == 0) return;
if (ind == "") std::cerr << "####################################################################\n";
if (dynamic_cast<Bubble*>(node)) {
Bubble* bubble = dynamic_cast<Bubble*>(node);
std::cerr << ind << "Bubble " << bubble;
std::cerr << " (" << pstate_source_position(node) << ")";
std::cerr << " " << bubble->tabs();
std::cerr << std::endl;
} else if (dynamic_cast<At_Root_Block*>(node)) {
At_Root_Block* root_block = dynamic_cast<At_Root_Block*>(node);
std::cerr << ind << "At_Root_Block " << root_block;
std::cerr << " (" << pstate_source_position(node) << ")";
std::cerr << " " << root_block->tabs();
std::cerr << std::endl;
debug_ast(root_block->expression(), ind + ":", env);
debug_ast(root_block->block(), ind + " ", env);
} else if (dynamic_cast<Selector_List*>(node)) {
Selector_List* selector = dynamic_cast<Selector_List*>(node);
std::cerr << ind << "Selector_List " << selector;
std::cerr << " (" << pstate_source_position(node) << ")";
std::cerr << " <" << selector->hash() << ">";
std::cerr << " [@media:" << selector->media_block() << "]";
std::cerr << (selector->is_optional() ? " [is_optional]": " -");
std::cerr << (selector->has_parent_ref() ? " [has-parent]": " -");
std::cerr << (selector->has_line_break() ? " [line-break]": " -");
std::cerr << (selector->has_line_feed() ? " [line-feed]": " -");
std::cerr << std::endl;
for(auto i : selector->elements()) { debug_ast(i, ind + " ", env); }
// } else if (dynamic_cast<Expression*>(node)) {
// Expression* expression = dynamic_cast<Expression*>(node);
// std::cerr << ind << "Expression " << expression << " " << expression->concrete_type() << std::endl;
} else if (dynamic_cast<Parent_Selector*>(node)) {
Parent_Selector* selector = dynamic_cast<Parent_Selector*>(node);
std::cerr << ind << "Parent_Selector " << selector;
// if (selector->not_selector()) cerr << " [in_declaration]";
std::cerr << " (" << pstate_source_position(node) << ")";
std::cerr << " <" << selector->hash() << ">";
std::cerr << " <" << prettyprint(selector->pstate().token.ws_before()) << ">" << std::endl;
// debug_ast(selector->selector(), ind + "->", env);
} else if (dynamic_cast<Complex_Selector*>(node)) {
Complex_Selector* selector = dynamic_cast<Complex_Selector*>(node);
std::cerr << ind << "Complex_Selector " << selector
<< " (" << pstate_source_position(node) << ")"
<< " <" << selector->hash() << ">"
<< " [weight:" << longToHex(selector->specificity()) << "]"
<< " [@media:" << selector->media_block() << "]"
<< (selector->is_optional() ? " [is_optional]": " -")
<< (selector->has_parent_ref() ? " [has parent]": " -")
<< (selector->has_line_feed() ? " [line-feed]": " -")
<< (selector->has_line_break() ? " [line-break]": " -")
<< " -- ";
std::string del;
switch (selector->combinator()) {
case Complex_Selector::PARENT_OF: del = ">"; break;
case Complex_Selector::PRECEDES: del = "~"; break;
case Complex_Selector::ADJACENT_TO: del = "+"; break;
case Complex_Selector::ANCESTOR_OF: del = " "; break;
case Complex_Selector::REFERENCE: del = "//"; break;
}
// if (del = "/") del += selector->reference()->perform(&to_string) + "/";
std::cerr << " <" << prettyprint(selector->pstate().token.ws_before()) << ">" << std::endl;
debug_ast(selector->head(), ind + " " /* + "[" + del + "]" */, env);
if (selector->tail()) {
debug_ast(selector->tail(), ind + "{" + del + "}", env);
} else if(del != " ") {
std::cerr << ind << " |" << del << "| {trailing op}" << std::endl;
}
SourcesSet set = selector->sources();
// debug_sources_set(set, ind + " @--> ");
} else if (dynamic_cast<Compound_Selector*>(node)) {
Compound_Selector* selector = dynamic_cast<Compound_Selector*>(node);
std::cerr << ind << "Compound_Selector " << selector;
std::cerr << " (" << pstate_source_position(node) << ")";
std::cerr << " <" << selector->hash() << ">";
std::cerr << " [weight:" << longToHex(selector->specificity()) << "]";
std::cerr << " [@media:" << selector->media_block() << "]";
std::cerr << (selector->extended() ? " [extended]": " -");
std::cerr << (selector->is_optional() ? " [is_optional]": " -");
std::cerr << (selector->has_parent_ref() ? " [has-parent]": " -");
std::cerr << (selector->has_line_break() ? " [line-break]": " -");
std::cerr << (selector->has_line_feed() ? " [line-feed]": " -");
std::cerr << " <" << prettyprint(selector->pstate().token.ws_before()) << ">" << std::endl;
for(auto i : selector->elements()) { debug_ast(i, ind + " ", env); }
} else if (dynamic_cast<Propset*>(node)) {
Propset* selector = dynamic_cast<Propset*>(node);
std::cerr << ind << "Propset " << selector;
std::cerr << " (" << pstate_source_position(node) << ")";
std::cerr << " " << selector->tabs() << std::endl;
if (selector->block()) for(auto i : selector->block()->elements()) { debug_ast(i, ind + " ", env); }
} else if (dynamic_cast<Wrapped_Selector*>(node)) {
Wrapped_Selector* selector = dynamic_cast<Wrapped_Selector*>(node);
std::cerr << ind << "Wrapped_Selector " << selector;
std::cerr << " (" << pstate_source_position(node) << ")";
std::cerr << " <" << selector->hash() << ">";
//.........这里部分代码省略.........
示例2: debug_ast
inline void debug_ast(AST_Node* node, string ind = "", Env* env = 0)
{
if (node == 0) return;
if (ind == "") cerr << "####################################################################\n";
if (dynamic_cast<Bubble*>(node)) {
Bubble* bubble = dynamic_cast<Bubble*>(node);
cerr << ind << "Bubble " << bubble << " " << bubble->tabs() << endl;
} else if (dynamic_cast<At_Root_Block*>(node)) {
At_Root_Block* root_block = dynamic_cast<At_Root_Block*>(node);
cerr << ind << "At_Root_Block " << root_block << " " << root_block->tabs() << endl;
if (root_block->block()) for(auto i : root_block->block()->elements()) { debug_ast(i, ind + " ", env); }
} else if (dynamic_cast<Selector_List*>(node)) {
Selector_List* selector = dynamic_cast<Selector_List*>(node);
cerr << ind << "Selector_List " << selector
<< " [block:" << selector->last_block() << "]"
<< (selector->last_block() && selector->last_block()->is_root() ? " [root]" : "")
<< " [@media:" << selector->media_block() << "]"
<< (selector->is_optional() ? " [is_optional]": " -")
<< (selector->has_line_break() ? " [line-break]": " -")
<< (selector->has_line_feed() ? " [line-feed]": " -")
<< endl;
for(auto i : selector->elements()) { debug_ast(i, ind + " ", env); }
// } else if (dynamic_cast<Expression*>(node)) {
// Expression* expression = dynamic_cast<Expression*>(node);
// cerr << ind << "Expression " << expression << " " << expression->concrete_type() << endl;
} else if (dynamic_cast<Parent_Selector*>(node)) {
Parent_Selector* selector = dynamic_cast<Parent_Selector*>(node);
cerr << ind << "Parent_Selector " << selector;
cerr << " <" << prettyprint(selector->pstate().token.ws_before()) << ">" << endl;
debug_ast(selector->selector(), ind + "->", env);
} else if (dynamic_cast<Complex_Selector*>(node)) {
Complex_Selector* selector = dynamic_cast<Complex_Selector*>(node);
cerr << ind << "Complex_Selector " << selector
<< " [block:" << selector->last_block() << "]"
<< " [weight:" << longToHex(selector->specificity()) << "]"
<< (selector->last_block() && selector->last_block()->is_root() ? " [root]" : "")
<< " [@media:" << selector->media_block() << "]"
<< (selector->is_optional() ? " [is_optional]": " -")
<< (selector->has_line_break() ? " [line-break]": " -")
<< (selector->has_line_feed() ? " [line-feed]": " -") << " -> ";
switch (selector->combinator()) {
case Complex_Selector::PARENT_OF: cerr << "{>}"; break;
case Complex_Selector::PRECEDES: cerr << "{~}"; break;
case Complex_Selector::ADJACENT_TO: cerr << "{+}"; break;
case Complex_Selector::ANCESTOR_OF: cerr << "{ }"; break;
}
cerr << " <" << prettyprint(selector->pstate().token.ws_before()) << ">" << endl;
debug_ast(selector->head(), ind + " ", env);
debug_ast(selector->tail(), ind + "-", env);
} else if (dynamic_cast<Compound_Selector*>(node)) {
Compound_Selector* selector = dynamic_cast<Compound_Selector*>(node);
cerr << ind << "Compound_Selector " << selector;
cerr << " [block:" << selector->last_block() << "]";
cerr << " [weight:" << longToHex(selector->specificity()) << "]";
// cerr << (selector->last_block() && selector->last_block()->is_root() ? " [root]" : "");
cerr << " [@media:" << selector->media_block() << "]";
cerr << (selector->is_optional() ? " [is_optional]": " -");
cerr << (selector->has_line_break() ? " [line-break]": " -");
cerr << (selector->has_line_feed() ? " [line-feed]": " -");
cerr << " <" << prettyprint(selector->pstate().token.ws_before()) << ">" << endl;
for(auto i : selector->elements()) { debug_ast(i, ind + " ", env); }
} else if (dynamic_cast<Propset*>(node)) {
Propset* selector = dynamic_cast<Propset*>(node);
cerr << ind << "Propset " << selector << " " << selector->tabs() << endl;
if (selector->block()) for(auto i : selector->block()->elements()) { debug_ast(i, ind + " ", env); }
} else if (dynamic_cast<Wrapped_Selector*>(node)) {
Wrapped_Selector* selector = dynamic_cast<Wrapped_Selector*>(node);
cerr << ind << "Wrapped_Selector " << selector << " <<" << selector->name() << ">>" << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << endl;
debug_ast(selector->selector(), ind + " () ", env);
} else if (dynamic_cast<Pseudo_Selector*>(node)) {
Pseudo_Selector* selector = dynamic_cast<Pseudo_Selector*>(node);
cerr << ind << "Pseudo_Selector " << selector << " <<" << selector->name() << ">>" << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << endl;
debug_ast(selector->expression(), ind + " <= ", env);
} else if (dynamic_cast<Attribute_Selector*>(node)) {
Attribute_Selector* selector = dynamic_cast<Attribute_Selector*>(node);
cerr << ind << "Attribute_Selector " << selector << " <<" << selector->name() << ">>" << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << endl;
debug_ast(selector->value(), ind + "[" + selector->matcher() + "] ", env);
} else if (dynamic_cast<Selector_Qualifier*>(node)) {
Selector_Qualifier* selector = dynamic_cast<Selector_Qualifier*>(node);
cerr << ind << "Selector_Qualifier " << selector << " <<" << selector->name() << ">>" << (selector->has_line_break() ? " [line-break]": " -") << (selector->has_line_feed() ? " [line-feed]": " -") << endl;
} else if (dynamic_cast<Type_Selector*>(node)) {
Type_Selector* selector = dynamic_cast<Type_Selector*>(node);
cerr << ind << "Type_Selector " << selector << " <<" << selector->name() << ">>" << (selector->has_line_break() ? " [line-break]": " -") <<
" <" << prettyprint(selector->pstate().token.ws_before()) << ">" << endl;
} else if (dynamic_cast<Selector_Placeholder*>(node)) {
Selector_Placeholder* selector = dynamic_cast<Selector_Placeholder*>(node);
cerr << ind << "Selector_Placeholder [" << selector->name() << "] " << selector
<< " [block:" << selector->last_block() << "]"
<< " [@media:" << selector->media_block() << "]"
<< (selector->is_optional() ? " [is_optional]": " -")
<< (selector->has_line_break() ? " [line-break]": " -")
<< (selector->has_line_feed() ? " [line-feed]": " -")
<< endl;
//.........这里部分代码省略.........