本文整理汇总了C++中txExprLexer::peekAhead方法的典型用法代码示例。如果您正苦于以下问题:C++ txExprLexer::peekAhead方法的具体用法?C++ txExprLexer::peekAhead怎么用?C++ txExprLexer::peekAhead使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类txExprLexer
的用法示例。
在下文中一共展示了txExprLexer::peekAhead方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createFilterOrStep
/**
* Creates a PathExpr using the given txExprLexer
* @param lexer the txExprLexer for retrieving Tokens
*/
nsresult
txExprParser::createPathExpr(txExprLexer& lexer, txIParseContext* aContext,
Expr** aResult)
{
*aResult = nullptr;
nsAutoPtr<Expr> expr;
Token* tok = lexer.peek();
// is this a root expression?
if (tok->mType == Token::PARENT_OP) {
if (!isLocationStepToken(lexer.peekAhead())) {
lexer.nextToken();
*aResult = new RootExpr();
return NS_OK;
}
}
// parse first step (possibly a FilterExpr)
nsresult rv = NS_OK;
if (tok->mType != Token::PARENT_OP &&
tok->mType != Token::ANCESTOR_OP) {
rv = createFilterOrStep(lexer, aContext, getter_Transfers(expr));
NS_ENSURE_SUCCESS(rv, rv);
// is this a singlestep path expression?
tok = lexer.peek();
if (tok->mType != Token::PARENT_OP &&
tok->mType != Token::ANCESTOR_OP) {
*aResult = expr.forget();
return NS_OK;
}
}
else {
expr = new RootExpr();
#ifdef TX_TO_STRING
static_cast<RootExpr*>(expr.get())->setSerialize(false);
#endif
}
// We have a PathExpr containing several steps
nsAutoPtr<PathExpr> pathExpr(new PathExpr());
rv = pathExpr->addExpr(expr, PathExpr::RELATIVE_OP);
NS_ENSURE_SUCCESS(rv, rv);
expr.forget();
// this is ugly
while (1) {
PathExpr::PathOperator pathOp;
switch (lexer.peek()->mType) {
case Token::ANCESTOR_OP :
pathOp = PathExpr::DESCENDANT_OP;
break;
case Token::PARENT_OP :
pathOp = PathExpr::RELATIVE_OP;
break;
default:
*aResult = pathExpr.forget();
return NS_OK;
}
lexer.nextToken();
rv = createLocationStep(lexer, aContext, getter_Transfers(expr));
NS_ENSURE_SUCCESS(rv, rv);
rv = pathExpr->addExpr(expr, pathOp);
NS_ENSURE_SUCCESS(rv, rv);
expr.forget();
}
NS_NOTREACHED("internal xpath parser error");
return NS_ERROR_UNEXPECTED;
}