本文整理汇总了C++中Grammar::isNonTerminal方法的典型用法代码示例。如果您正苦于以下问题:C++ Grammar::isNonTerminal方法的具体用法?C++ Grammar::isNonTerminal怎么用?C++ Grammar::isNonTerminal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Grammar
的用法示例。
在下文中一共展示了Grammar::isNonTerminal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
void ParseTable::operator () (Automaton *aut)
{
Grammar *g = aut->_M_grammar;
int rindex = 1;
for (RulePointer rule = g->rules.begin (); rule != g->rules.end (); ++rule)
out << rindex++ << ")\t" << *rule << endl;
out << endl << endl;
int index = 0;
for (StatePointer state = aut->states.begin (); state != aut->states.end (); ++state)
{
out << "state " << index++ << endl << endl;
for (ItemPointer item = state->kernel.begin (); item != state->kernel.end (); ++item)
{
out << " * " << *item;
if (item->dot == item->end_rhs ())
out << " " << aut->lookaheads [item];
out << endl;
}
bool first = true;
for (Bundle::iterator arrow = state->bundle.begin (); arrow != state->bundle.end (); ++arrow)
{
if (! g->isTerminal (arrow.key ()))
continue;
if (first)
out << endl;
first = false;
out << " " << *arrow.key () << " shift, and go to state " << std::distance (aut->states.begin (), *arrow) << endl;
}
first = true;
for (ItemPointer item = state->closure.begin (); item != state->closure.end (); ++item)
{
if (item->dot != item->end_rhs () || item->rule == state->defaultReduce)
continue;
if (first)
out << endl;
first = false;
foreach (Name la, aut->lookaheads.value (item))
out << " " << *la << " reduce using rule " << aut->id (item->rule) << " (" << *item->rule->lhs << ")" << endl;
}
first = true;
for (Bundle::iterator arrow = state->bundle.begin (); arrow != state->bundle.end (); ++arrow)
{
if (! g->isNonTerminal (arrow.key ()))
continue;
if (first)
out << endl;
first = false;
out << " " << *arrow.key () << " go to state " << std::distance (aut->states.begin (), *arrow) << endl;
}
if (state->defaultReduce != g->rules.end ())
{
out << endl
<< " $default reduce using rule " << aut->id (state->defaultReduce) << " (" << *state->defaultReduce->lhs << ")" << endl;
}
out << endl;
}
}