本文整理汇总了C++中NFA::arc方法的典型用法代码示例。如果您正苦于以下问题:C++ NFA::arc方法的具体用法?C++ NFA::arc怎么用?C++ NFA::arc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NFA
的用法示例。
在下文中一共展示了NFA::arc方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseItem
// item: ATOM('+'|'*'|'?')
void Grammar::parseItem(string &ruleName, NFA **start, NFA **end)
{
parseAtom(ruleName, start, end);
assert(*start != NULL);
assert(*end != NULL);
// check to see wether repeator exist?
if (isMatch(TT_OP, "+")) {
(*end)->arc(*start);
advanceToken();
}
else if (isMatch(TT_OP, "*")) {
NFA *startState = new NFA();
NFA *endState = new NFA();
startState->arc(endState);
startState->arc(*start);
(*end)->arc(*start);
(*end)->arc(endState);
*start = startState;
*end = endState;
advanceToken();
}
else if (isMatch(TT_OP, "?")) {
NFA *endState = new NFA();
(*end)->arc(endState);
(*start)->arc(endState);
*end = endState;
advanceToken();
}
}
示例2: parseAlternative
/// parse the alternative, such as alternative : items (| items)*
void Grammar::parseAlternative(string &ruleName, NFA **start, NFA **end)
{
assert(start != NULL);
assert(end != NULL);
// parse items
parseItems(ruleName, start, end);
if (isMatch(TT_OP, "|")) {
// make a closing state
NFA *closingStartState = new NFA();
NFA *closingEndState = new NFA;
closingStartState->arc(*start);
(*end)->arc(closingEndState);
while (isMatch(TT_OP, "|")) {
advanceToken();
NFA *startState = NULL;
NFA *endState = NULL;
parseItems(ruleName, &startState, &endState);
closingStartState->arc(startState);
endState->arc(closingEndState);
}
*start = closingStartState;
*end = closingEndState;
}
}