本文整理汇总了C++中Alternative::first方法的典型用法代码示例。如果您正苦于以下问题:C++ Alternative::first方法的具体用法?C++ Alternative::first怎么用?C++ Alternative::first使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Alternative
的用法示例。
在下文中一共展示了Alternative::first方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseAtom
// Atom ::= "(" Expression ")" | "[" [^] Range "]" | Characters
Instruction* ParseAtom(const char **ppc, ParseInfo &info)
{
Instruction *i = 0;
const char *pc = *ppc;
switch (*pc)
{
case '(':
{
Group::TriState dnl = Group::Inherit;
Group::TriState nc = Group::Inherit;
Group::TriState ml = Group::Inherit;
bool capture = true;
bool consume = true;
bool invert = false;
bool reverse = false;
std::string name = "";
++pc;
if (*pc == '?')
{
++pc;
if (*pc == '#')
{
// skip everything until ) and from behave as if ParseAtom was
// called starting next character
++pc;
while (*pc != ')')
{
if (*pc == '\0')
{
return 0;
}
++pc;
}
*ppc = ++pc;
return ParseAtom(ppc, info);
}
if (*pc == ':')
{
capture = false;
++pc;
}
else if (*pc == '(')
{
// conditional
++pc;
std::string cond;
while (*pc != ')')
{
if (*pc == '\0')
{
return 0;
}
cond.push_back(*pc);
++pc;
}
++pc;
Instruction *ci = ParseExpression(&pc, info);
if (!ci || *pc != ')')
{
if (ci)
{
delete ci;
}
return 0;
}
++pc;
Alternative *alt = dynamic_cast<Alternative*>(ci);
Instruction *ifTrue, *ifFalse;
if (alt == 0)
{
ifTrue = ci;
ifFalse = 0;
}
else
{
ifTrue = alt->first()->clone();
ifFalse = alt->second()->clone();
delete alt;
}
*ppc = pc;
int index = 0;
if (sscanf(cond.c_str(), "%d", &index) != 1)
{
return new Conditional(cond, ifTrue, ifFalse);
}
else
{
return new Conditional(index, ifTrue, ifFalse);
}
}
else if (*pc == 'P')
{
//.........这里部分代码省略.........