本文整理汇总了C++中NodeType::arity方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeType::arity方法的具体用法?C++ NodeType::arity怎么用?C++ NodeType::arity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeType
的用法示例。
在下文中一共展示了NodeType::arity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
result_type operator()(
Stream & stream, bool outer, NodeType const & node
) const
{
// Get the program associated with this stream.
Program const * pgm = manipulators::detail::pgm_data(stream);
char close_char = '\0';
m_delim.push(' ');
// Print the label.
if(pgm)
{
switch(node.tag())
{
case FAIL: stream << "**FAIL**"; break;
case CHOICE:
if(!outer)
{
stream << "(";
close_char = ')';
}
stream << "?_" << node.id() << " ";
break;
case OPER:
if(!outer && node.arity() > 0)
{
stream << "(";
close_char = ')';
}
stream << pgm->oper_label[node.id()] << " ";
break;
case CTOR:
default:
// Handle certain built-in types specially.
if(node.tag() >= CTOR)
{
switch(node.id())
{
case CL_TUPLE2:
case CL_TUPLE3:
case CL_TUPLE4:
case CL_TUPLE5:
case CL_TUPLE6:
case CL_TUPLE7:
case CL_TUPLE8:
case CL_TUPLE9:
stream << "(";
close_char = ')';
m_delim.pop();
m_delim.push(',');
break;
case CL_CONS:
case CL_NIL:
{
stream << "[";
Node const * p = &node;
while(true)
{
visit(
tr1::bind<Stream &>(
*this, tr1::ref(stream), false, _1
)
, *(*p)[0]
);
p = (*p)[1].get();
if(p->id() == CL_NIL) break;
stream << ",";
}
stream << "]";
m_delim.pop();
return stream;
}
default:
if(!outer && node.arity() > 0)
{
stream << "(";
close_char = ')';
}
stream << pgm->ctor_label[node.id()] << " ";
break;
}
break;
}
else throw RuntimeError("mishandled node in operator<<");
}
}
else
{
if(!outer)
{
stream << "(";
close_char = ')';
}
stream << "<unknown-ctor> ";
}
//.........这里部分代码省略.........