本文整理汇总了C++中SyntaxTree::isErrorCut方法的典型用法代码示例。如果您正苦于以下问题:C++ SyntaxTree::isErrorCut方法的具体用法?C++ SyntaxTree::isErrorCut怎么用?C++ SyntaxTree::isErrorCut使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyntaxTree
的用法示例。
在下文中一共展示了SyntaxTree::isErrorCut方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: m_parse_sequence
SyntaxTree* Parser::m_parse_sequence(TArray<Parser*>* ps)
{
m_ErrorPos startPos = m_curErrPos();
SyntaxTree::Childs* childs = new SyntaxTree::Childs(ps->size());
childs->setContentsMemID("pcsq");
int errorCutId = 0;
hyu32 errorCutPos = 0;
for (TArrayIterator<Parser*> itr(ps); itr.hasMore(); ) {
Parser* p = itr.next();
SyntaxTree* st = p->parse();
if (st->isErrorCut()) {
errorCutId = st->errorCutId;
errorCutPos = st->str.startPos;
delete st;
} else if (! st->isFail()) {
p->addSyntaxTreeToParent(childs, st);
} else {
if (st->isFailNotError() && errorCutId > 0) {
SyntaxTree* e = new SyntaxTree(errorCutPos, errorCutId, this);
if (! m_bUseMemoize)
delete st;
st = e;
}
m_fail(startPos);
if (! m_bUseMemoize) {
SyntaxTree::Childs::deleteRecursively(childs);
} else {
delete childs;
}
return st;
}
}
return createSyntaxTree(startPos.parsePos, childs);
}
示例2: if
SyntaxTree* UserParser::m_parse1(m_ErrorPos startPos)
{
const char* n = name();
SyntaxTree* st;
if (m_bUseMemoize) {
st = m_memo.getAt(startPos.parsePos);
if (st == m_PARSING) {
// left recursion
char pbuf[128];
gpInp->sprintSourceInfo(pbuf, 128, startPos.parsePos);
HMD_PRINTF("LEFT RECURSION DETECTED: %s %s\n", n, pbuf);
return m_FATAL_PARSER_ERROR;
} else if (st != m_NOT_PARSED_YET) {
if (st->isValidTree())
gpInp->setPos(st->str.endPos);
if (m_printIntermediateLevel > 1 ||
(m_printIntermediateLevel > 0 && !st->isFail())) {
char pbuf[128];
gpInp->sprintSourceInfo(pbuf, 128, startPos.parsePos);
HMD_PRINTF("%s %s -> memoized ", n, pbuf);
if (st->isValidTree()) {
char b[44];
gpInp->copySummary(b, 40, st->str);
HMD_PRINTF("pos=%d-%d '%s'\n", st->str.startPos, st->str.endPos, b);
} else {
if (st == m_NO_SYNTAX_TREE)
HMD_PRINTF("no syntax tree\n");
else if (st == m_PARSE_FAILED)
HMD_PRINTF("parse failed\n");
else if (st->isErrorCut())
HMD_PRINTF("ErrorCut(%d)\n",st->errorCutId);
else
HMD_PRINTF("(UNKNOWN BUG?)\n");
}
}
return st;
}
// not parsed yet
m_memo.setAt(startPos.parsePos, m_PARSING);
}
if (m_printIntermediateLevel > 1) {
char pbuf[128];
gpInp->sprintSourceInfo(pbuf, 128, startPos.parsePos);
HMD_PRINTF("try %s %s pos=%d:\n", n, pbuf, startPos.parsePos);
}
return NULL;
}