本文整理汇总了C++中txExprLexer::pushBack方法的典型用法代码示例。如果您正苦于以下问题:C++ txExprLexer::pushBack方法的具体用法?C++ txExprLexer::pushBack怎么用?C++ txExprLexer::pushBack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类txExprLexer
的用法示例。
在下文中一共展示了txExprLexer::pushBack方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
/**
* Using the given lexer, parses the tokens if they represent a parameter list
* If an error occurs a non-zero String pointer will be returned containing the
* error message.
* @param list, the List to add parameter expressions to
* @param lexer the txExprLexer to use for parsing tokens
* @return NS_OK if successful, or another rv otherwise
*/
nsresult
txExprParser::parseParameters(FunctionCall* aFnCall, txExprLexer& lexer,
txIParseContext* aContext)
{
if (lexer.peek()->mType == Token::R_PAREN) {
lexer.nextToken();
return NS_OK;
}
nsAutoPtr<Expr> expr;
nsresult rv = NS_OK;
while (1) {
rv = createExpr(lexer, aContext, getter_Transfers(expr));
NS_ENSURE_SUCCESS(rv, rv);
if (aFnCall) {
rv = aFnCall->addParam(expr.forget());
NS_ENSURE_SUCCESS(rv, rv);
}
switch (lexer.nextToken()->mType) {
case Token::R_PAREN :
return NS_OK;
case Token::COMMA: //-- param separator
break;
default:
lexer.pushBack();
return NS_ERROR_XPATH_PAREN_EXPECTED;
}
}
NS_NOTREACHED("internal xpath parser error");
return NS_ERROR_UNEXPECTED;
}
示例2: switch
/**
* This method only handles comment(), text(), processing-instructing()
* and node()
*/
nsresult
txExprParser::createNodeTypeTest(txExprLexer& lexer, txNodeTest** aTest)
{
*aTest = 0;
nsAutoPtr<txNodeTypeTest> nodeTest;
Token* nodeTok = lexer.nextToken();
switch (nodeTok->mType) {
case Token::COMMENT_AND_PAREN:
nodeTest = new txNodeTypeTest(txNodeTypeTest::COMMENT_TYPE);
break;
case Token::NODE_AND_PAREN:
nodeTest = new txNodeTypeTest(txNodeTypeTest::NODE_TYPE);
break;
case Token::PROC_INST_AND_PAREN:
nodeTest = new txNodeTypeTest(txNodeTypeTest::PI_TYPE);
break;
case Token::TEXT_AND_PAREN:
nodeTest = new txNodeTypeTest(txNodeTypeTest::TEXT_TYPE);
break;
default:
lexer.pushBack();
return NS_ERROR_XPATH_NO_NODE_TYPE_TEST;
}
NS_ENSURE_TRUE(nodeTest, NS_ERROR_OUT_OF_MEMORY);
if (nodeTok->mType == Token::PROC_INST_AND_PAREN &&
lexer.peek()->mType == Token::LITERAL) {
Token* tok = lexer.nextToken();
nodeTest->setNodeName(tok->Value());
}
if (lexer.nextToken()->mType != Token::R_PAREN) {
lexer.pushBack();
return NS_ERROR_XPATH_PAREN_EXPECTED;
}
*aTest = nodeTest.forget();
return NS_OK;
}
示例3: createStepPattern
nsresult txPatternParser::createStepPattern(txExprLexer& aLexer,
txIParseContext* aContext,
txPattern*& aPattern)
{
nsresult rv = NS_OK;
MBool isAttr = MB_FALSE;
Token* tok = aLexer.peek();
if (tok->mType == Token::AXIS_IDENTIFIER) {
if (TX_StringEqualsAtom(tok->Value(), txXPathAtoms::attribute)) {
isAttr = MB_TRUE;
}
else if (!TX_StringEqualsAtom(tok->Value(), txXPathAtoms::child)) {
// all done already for CHILD_AXIS, for all others
// XXX report unexpected axis error
return NS_ERROR_XPATH_PARSE_FAILURE;
}
aLexer.nextToken();
}
else if (tok->mType == Token::AT_SIGN) {
aLexer.nextToken();
isAttr = MB_TRUE;
}
tok = aLexer.nextToken();
txNodeTest* nodeTest;
if (tok->mType == Token::CNAME) {
// resolve QName
nsCOMPtr<nsIAtom> prefix, lName;
PRInt32 nspace;
rv = resolveQName(tok->Value(), getter_AddRefs(prefix), aContext,
getter_AddRefs(lName), nspace, PR_TRUE);
if (NS_FAILED(rv)) {
// XXX error report namespace resolve failed
return rv;
}
PRUint16 nodeType = isAttr ?
(PRUint16)txXPathNodeType::ATTRIBUTE_NODE :
(PRUint16)txXPathNodeType::ELEMENT_NODE;
nodeTest = new txNameTest(prefix, lName, nspace, nodeType);
if (!nodeTest) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
else {
aLexer.pushBack();
rv = createNodeTypeTest(aLexer, &nodeTest);
NS_ENSURE_SUCCESS(rv, rv);
}
nsAutoPtr<txStepPattern> step(new txStepPattern(nodeTest, isAttr));
if (!step) {
delete nodeTest;
return NS_ERROR_OUT_OF_MEMORY;
}
rv = parsePredicates(step, aLexer, aContext);
NS_ENSURE_SUCCESS(rv, rv);
aPattern = step.forget();
return NS_OK;
}
示例4: 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 = nsnull;
nsAutoPtr<Expr> expr;
Token* tok = lexer.peek();
// is this a root expression?
if (tok->mType == Token::PARENT_OP) {
lexer.nextToken();
if (!isLocationStepToken(lexer.peek())) {
*aResult = new RootExpr();
NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
return NS_OK;
}
lexer.pushBack();
}
// 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();
NS_ENSURE_TRUE(expr, NS_ERROR_OUT_OF_MEMORY);
#ifdef TX_TO_STRING
static_cast<RootExpr*>(expr.get())->setSerialize(PR_FALSE);
#endif
}
// We have a PathExpr containing several steps
nsAutoPtr<PathExpr> pathExpr(new PathExpr());
NS_ENSURE_TRUE(pathExpr, NS_ERROR_OUT_OF_MEMORY);
rv = pathExpr->addExpr(expr, PathExpr::RELATIVE_OP);
NS_ENSURE_SUCCESS(rv, rv);
expr.forget();
// this is ugly
while (1) {
PathExpr::PathOperator pathOp;
tok = lexer.nextToken();
switch (tok->mType) {
case Token::ANCESTOR_OP :
pathOp = PathExpr::DESCENDANT_OP;
break;
case Token::PARENT_OP :
pathOp = PathExpr::RELATIVE_OP;
break;
default:
lexer.pushBack();
*aResult = pathExpr.forget();
return NS_OK;
}
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;
}
示例5: if
//.........这里部分代码省略.........
axisIdentifier = LocationStep::ATTRIBUTE_AXIS;
}
else if (axis == nsGkAtoms::child) {
axisIdentifier = LocationStep::CHILD_AXIS;
}
else if (axis == nsGkAtoms::descendant) {
axisIdentifier = LocationStep::DESCENDANT_AXIS;
}
else if (axis == nsGkAtoms::descendantOrSelf) {
axisIdentifier = LocationStep::DESCENDANT_OR_SELF_AXIS;
}
else if (axis == nsGkAtoms::following) {
axisIdentifier = LocationStep::FOLLOWING_AXIS;
}
else if (axis == nsGkAtoms::followingSibling) {
axisIdentifier = LocationStep::FOLLOWING_SIBLING_AXIS;
}
else if (axis == nsGkAtoms::_namespace) {
axisIdentifier = LocationStep::NAMESPACE_AXIS;
}
else if (axis == nsGkAtoms::parent) {
axisIdentifier = LocationStep::PARENT_AXIS;
}
else if (axis == nsGkAtoms::preceding) {
axisIdentifier = LocationStep::PRECEDING_AXIS;
}
else if (axis == nsGkAtoms::precedingSibling) {
axisIdentifier = LocationStep::PRECEDING_SIBLING_AXIS;
}
else if (axis == nsGkAtoms::self) {
axisIdentifier = LocationStep::SELF_AXIS;
}
else {
return NS_ERROR_XPATH_INVALID_AXIS;
}
break;
}
case Token::AT_SIGN:
//-- eat token
lexer.nextToken();
axisIdentifier = LocationStep::ATTRIBUTE_AXIS;
break;
case Token::PARENT_NODE :
//-- eat token
lexer.nextToken();
axisIdentifier = LocationStep::PARENT_AXIS;
nodeTest = new txNodeTypeTest(txNodeTypeTest::NODE_TYPE);
NS_ENSURE_TRUE(nodeTest, NS_ERROR_OUT_OF_MEMORY);
break;
case Token::SELF_NODE :
//-- eat token
lexer.nextToken();
axisIdentifier = LocationStep::SELF_AXIS;
nodeTest = new txNodeTypeTest(txNodeTypeTest::NODE_TYPE);
NS_ENSURE_TRUE(nodeTest, NS_ERROR_OUT_OF_MEMORY);
break;
default:
break;
}
//-- get NodeTest unless an AbbreviatedStep was found
nsresult rv = NS_OK;
if (!nodeTest) {
tok = lexer.nextToken();
if (tok->mType == Token::CNAME) {
// resolve QName
nsCOMPtr<nsIAtom> prefix, lName;
PRInt32 nspace;
rv = resolveQName(tok->Value(), getter_AddRefs(prefix),
aContext, getter_AddRefs(lName),
nspace, PR_TRUE);
NS_ENSURE_SUCCESS(rv, rv);
nodeTest =
new txNameTest(prefix, lName, nspace,
axisIdentifier == LocationStep::ATTRIBUTE_AXIS ?
static_cast<PRUint16>(txXPathNodeType::ATTRIBUTE_NODE) :
static_cast<PRUint16>(txXPathNodeType::ELEMENT_NODE));
NS_ENSURE_TRUE(nodeTest, NS_ERROR_OUT_OF_MEMORY);
}
else {
lexer.pushBack();
rv = createNodeTypeTest(lexer, getter_Transfers(nodeTest));
NS_ENSURE_SUCCESS(rv, rv);
}
}
nsAutoPtr<LocationStep> lstep(new LocationStep(nodeTest, axisIdentifier));
NS_ENSURE_TRUE(lstep, NS_ERROR_OUT_OF_MEMORY);
nodeTest.forget();
//-- handle predicates
rv = parsePredicates(lstep, lexer, aContext);
NS_ENSURE_SUCCESS(rv, rv);
*aExpr = lstep.forget();
return NS_OK;
}
示例6: createLocationStep
nsresult
txExprParser::createFilterOrStep(txExprLexer& lexer, txIParseContext* aContext,
Expr** aResult)
{
*aResult = nsnull;
nsresult rv = NS_OK;
Token* tok = lexer.nextToken();
nsAutoPtr<Expr> expr;
switch (tok->mType) {
case Token::FUNCTION_NAME_AND_PAREN:
lexer.pushBack();
rv = createFunctionCall(lexer, aContext, getter_Transfers(expr));
NS_ENSURE_SUCCESS(rv, rv);
break;
case Token::VAR_REFERENCE :
{
nsCOMPtr<nsIAtom> prefix, lName;
PRInt32 nspace;
nsresult rv = resolveQName(tok->Value(), getter_AddRefs(prefix),
aContext, getter_AddRefs(lName),
nspace);
NS_ENSURE_SUCCESS(rv, rv);
expr = new VariableRefExpr(prefix, lName, nspace);
NS_ENSURE_TRUE(expr, NS_ERROR_OUT_OF_MEMORY);
}
break;
case Token::L_PAREN:
rv = createExpr(lexer, aContext, getter_Transfers(expr));
NS_ENSURE_SUCCESS(rv, rv);
if (lexer.nextToken()->mType != Token::R_PAREN) {
lexer.pushBack();
return NS_ERROR_XPATH_PAREN_EXPECTED;
}
break;
case Token::LITERAL :
expr = new txLiteralExpr(tok->Value());
NS_ENSURE_TRUE(expr, NS_ERROR_OUT_OF_MEMORY);
break;
case Token::NUMBER:
{
expr = new txLiteralExpr(Double::toDouble(tok->Value()));
NS_ENSURE_TRUE(expr, NS_ERROR_OUT_OF_MEMORY);
break;
}
default:
lexer.pushBack();
return createLocationStep(lexer, aContext, aResult);
}
if (lexer.peek()->mType == Token::L_BRACKET) {
nsAutoPtr<FilterExpr> filterExpr(new FilterExpr(expr));
NS_ENSURE_TRUE(filterExpr, NS_ERROR_OUT_OF_MEMORY);
expr.forget();
//-- handle predicates
rv = parsePredicates(filterExpr, lexer, aContext);
NS_ENSURE_SUCCESS(rv, rv);
expr = filterExpr.forget();
}
*aResult = expr.forget();
return NS_OK;
}