本文整理汇总了C++中SyntaxTree::isValidTree方法的典型用法代码示例。如果您正苦于以下问题:C++ SyntaxTree::isValidTree方法的具体用法?C++ SyntaxTree::isValidTree怎么用?C++ SyntaxTree::isValidTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyntaxTree
的用法示例。
在下文中一共展示了SyntaxTree::isValidTree方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: parse
SyntaxTree* OperatorParser::parse(void)
{
HMD_ASSERT(m_parser);
m_ErrorPos startPos = m_curErrPos();
SyntaxTree* st = m_parser->parse();
const char* n = name();
if (st->isError()) {
m_fail(startPos);
if (! st->isFatalError()) {
char pbuf[128];
gpInp->sprintSourceInfo(pbuf, 128, startPos.parsePos);
HMD_PRINTF("%s %s -> ERROR %d\n", n, pbuf, st->errorCutId);
}
return m_FATAL_PARSER_ERROR;
}
if (st->isFail()) {
if (m_printIntermediateLevel > 2) {
char pbuf[128];
gpInp->sprintSourceInfo(pbuf, 128, startPos.parsePos);
HMD_PRINTF("%s %s -> fail\n", n, pbuf);
}
m_fail(startPos);
return m_PARSE_FAILED;
}
if (m_printIntermediateLevel > 1) {
char pbuf[128];
gpInp->sprintSourceInfo(pbuf, 128, startPos.parsePos);
if (st->isValidTree()) {
char b[44];
gpInp->copySummary(b, 40, st->str);
HMD_PRINTF("%s %s -> '%s'\n", n, pbuf, b);
} else {
HMD_PRINTF("%s %s -> (notree)\n", n, pbuf);
}
}
#if 0
if (st->isValidTree()) {
if (st->numChild() == 1) {
// no operator, so that this node is not needed
SyntaxTree* tmp = st->replace(0, NULL);
if (! m_bUseMemoize)
delete st;
return tmp;
}
}
#endif
return st;
}
示例3: m_reduceSyntaxTreeToParent
void Parser::m_reduceSyntaxTreeToParent(SyntaxTree::Childs* arr, SyntaxTree* st)
{
if (! st->isValidTree())
return;
for (TArrayIterator<SyntaxTree*> itr(st->childs); itr.hasMore(); ) {
SyntaxTree* t = itr.next();
if (t->isValidTree()) {
t->parser->addSyntaxTreeToParent(arr, t);
}
}
if (! m_bUseMemoize) {
// no more need
if (st->childs != NULL)
delete st->childs;
delete st;
}
}