本文整理汇总了C++中tree::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ tree::getType方法的具体用法?C++ tree::getType怎么用?C++ tree::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree
的用法示例。
在下文中一共展示了tree::getType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeSiblingsXML
void writeSiblingsXML(const tree<AstNode>& t, const tree<AstNode>::iterator iRoot, ostream& stream)
{
if(t.empty())
return;
if (iRoot->getType() == "root") {
tree<AstNode>::sibling_iterator iChildren = t.begin(iRoot);
stream << "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" << endl;
writeSiblingsXML(t,iChildren,stream);
}
else if (t.number_of_children(iRoot) == 0) {
string type = iRoot->getType();
stream << "<php:" << type << '>';
if (iRoot->getValue().length() > 0)
stream << htmlentities(iRoot->getValue());
stream << "</php:" << type << '>' << endl;
}
else {
string type = iRoot->getType();
string xmlns="";
if (type == "start")
xmlns = " xmlns:php=\"http://php.net/csl\"";
stream << "<php:" << type << xmlns << '>' << endl;
int siblingNum;
tree<AstNode>::sibling_iterator iChildren;
for (iChildren = t.begin(iRoot), siblingNum = 0; iChildren != t.end(iRoot); ++iChildren)
{
writeSiblingsXML(t,iChildren,stream);
}
stream << "</php:" << type << '>' << endl;
}
}
示例2: insert_statement
/**
Insert a new statement.
- Create a new inner_statement_list
- Add the statement under it
*/
bool insert_statement(const tree<AstNode>::iterator& where, const tree<AstNode>::iterator& what, tree<AstNode>& tr)
{
if (where->getType() == "text" && where->getValue() == "$enter_the_new_statement") {
// rewind to the inner_statement_list
tree<AstNode>::iterator top = where;
do {
top = tr.parent(top);
} while (top->getType() != "inner_statement" && tr.child(top,0)->getType() != "statement");
top = tr.parent(top);
if (top->getType() != "inner_statement_list")
return false;
else {
top = tr.append_child(top, AstNode("inner_statement_list"));
top = tr.append_child(top, AstNode("inner_statement"));
if (what->getType() == "statement") {
top = tr.append_child(top, AstNode("statement"));
//cout << "Seems to be okay..." << endl;
move_branch(top, what, tr);
}
}
return true;
}
return false;
}
示例3: is_skeleton_node
bool Ast::is_skeleton_node(const tree<AstNode>::iterator& it) const
{
string t = it->getType();
if (t == "T_INLINE_HTML")
return false;
else if (t == "text") {
// look at the parent, if it's T_VARIABLE or T_STRING, keep it
tree<AstNode>::iterator parent = tr.parent(it);
string pt = parent->getType();
if (pt == "T_VARIABLE" || pt == "T_STRING" || pt == "T_CONSTANT_ENCAPSED_STRING")
return true;
return false;
}
else if ((t == "root" || t == "start" || t == "CHAR61" || t == "expr" || t == "top_statement_list"
|| t == "internal_functions_in_yacc" || t == "function_call" || t == "statement" || t == "unticked_statement"
|| utils::start_with(t, "T_")))
return true;
return false;
}
示例4: detectFunction
bool Ast::detectFunction(const tree<AstNode>::iterator& i) const {
if (i->getType() == "function_call")
return true;
return false;
}