Back to index

lightning-sunbird  0.9+nobinonly
Static Public Member Functions | Static Protected Member Functions
txPatternParser Class Reference

#include <txPatternParser.h>

Inheritance diagram for txPatternParser:
Inheritance graph
[legend]
Collaboration diagram for txPatternParser:
Collaboration graph
[legend]

List of all members.

Static Public Member Functions

static txPatterncreatePattern (const nsAFlatString &aPattern, txIParseContext *aContext)
static nsresult createExpr (const nsASingleFragmentString &aExpression, txIParseContext *aContext, Expr **aExpr)
static AttributeValueTemplatecreateAttributeValueTemplate (const nsAFlatString &attValue, txIParseContext *aContext)
 Creates an Attribute Value Template using the given value.

Static Protected Member Functions

static nsresult createUnionPattern (txExprLexer &aLexer, txIParseContext *aContext, txPattern *&aPattern)
static nsresult createLocPathPattern (txExprLexer &aLexer, txIParseContext *aContext, txPattern *&aPattern)
static nsresult createIdPattern (txExprLexer &aLexer, txPattern *&aPattern)
static nsresult createKeyPattern (txExprLexer &aLexer, txIParseContext *aContext, txPattern *&aPattern)
static nsresult createStepPattern (txExprLexer &aLexer, txIParseContext *aContext, txPattern *&aPattern)
static nsresult createExpr (txExprLexer &lexer, txIParseContext *aContext, Expr **aResult)
static nsresult createBinaryExpr (nsAutoPtr< Expr > &left, nsAutoPtr< Expr > &right, Token *op, Expr **aResult)
 Using nsAutoPtr& to optimize passing the ownership to the created binary expression objects.
static nsresult createFilter (txExprLexer &lexer, txIParseContext *aContext, Expr **aResult)
static nsresult createFunctionCall (txExprLexer &lexer, txIParseContext *aContext, Expr **aResult)
static nsresult createLocationStep (txExprLexer &lexer, txIParseContext *aContext, Expr **aResult)
static nsresult createNodeTypeTest (txExprLexer &lexer, txNodeTest **aResult)
 This method only handles comment(), text(), processing-instructing() and node()
static nsresult createPathExpr (txExprLexer &lexer, txIParseContext *aContext, Expr **aResult)
 Creates a PathExpr using the given txExprLexer.
static nsresult createUnionExpr (txExprLexer &lexer, txIParseContext *aContext, Expr **aResult)
 Creates a PathExpr using the given txExprLexer.
static PRBool isFilterExprToken (Token *aToken)
static PRBool isLocationStepToken (Token *aToken)
static PRBool isNodeTypeToken (Token *aToken)
static short precedence (Token *aToken)
static nsresult resolveQName (const nsAString &aQName, nsIAtom **aPrefix, txIParseContext *aContext, nsIAtom **aLocalName, PRInt32 &aNamespace, PRBool aIsNameTest=MB_FALSE)
 Resolve a QName, given the mContext parse context.
static nsresult parsePredicates (PredicateList *aPredicateList, txExprLexer &lexer, txIParseContext *aContext)
 Using the given lexer, parses the tokens if they represent a predicate list If an error occurs a non-zero String pointer will be returned containing the error message.
static nsresult parseParameters (FunctionCall *aFnCall, txExprLexer &lexer, txIParseContext *aContext)
 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.

Detailed Description

Definition at line 45 of file txPatternParser.h.


Member Function Documentation

Creates an Attribute Value Template using the given value.

ExprParser This class is used to parse XSL Expressions.

See also:
ExprLexer Creates an Attribute Value Template using the given value This should move to XSLProcessor class

Definition at line 60 of file ExprParser.cpp.

{
    AttributeValueTemplate* avt = new AttributeValueTemplate();
    if (!avt) {
        // XXX ErrorReport: out of memory
        return 0;
    }

    if (attValue.IsEmpty())
        return avt;

    PRUint32 size = attValue.Length();
    PRUint32 cc = 0;
    PRUnichar nextCh;
    PRUnichar ch;
    nsAutoString buffer;
    MBool inExpr    = MB_FALSE;
    MBool inLiteral = MB_FALSE;
    PRUnichar endLiteral = 0;

    nextCh = attValue.CharAt(cc);
    while (cc++ < size) {
        ch = nextCh;
        nextCh = cc != size ? attValue.CharAt(cc) : 0;
        
        // if in literal just add ch to buffer
        if (inLiteral && (ch != endLiteral)) {
                buffer.Append(ch);
                continue;
        }
        switch ( ch ) {
            case '\'' :
            case '"' :
                buffer.Append(ch);
                if (inLiteral)
                    inLiteral = MB_FALSE;
                else if (inExpr) {
                    inLiteral = MB_TRUE;
                    endLiteral = ch;
                }
                break;
            case  '{' :
                if (!inExpr) {
                    // Ignore case where we find two {
                    if (nextCh == ch) {
                        buffer.Append(ch); //-- append '{'
                        cc++;
                        nextCh = cc != size ? attValue.CharAt(cc) : 0;
                    }
                    else {
                        if (!buffer.IsEmpty()) {
                            Expr* strExpr = new txLiteralExpr(buffer);
                            if (!strExpr) {
                                // XXX ErrorReport: out of memory
                                delete avt;
                                return 0;
                            }
                            avt->addExpr(strExpr);
                        }
                        buffer.Truncate();
                        inExpr = MB_TRUE;
                    }
                }
                else
                    buffer.Append(ch); //-- simply append '{'
                break;
            case '}':
                if (inExpr) {
                    inExpr = MB_FALSE;
                    txExprLexer lexer;
                    nsresult rv = lexer.parse(buffer);
                    if (NS_FAILED(rv)) {
                        delete avt;
                        return 0;
                    }
                    Expr* expr;
                    rv = createExpr(lexer, aContext, &expr);
                    if (NS_FAILED(rv)) {
                        delete avt;
                        return 0;
                    }
                    avt->addExpr(expr);
                    buffer.Truncate();
                }
                else if (nextCh == ch) {
                    buffer.Append(ch);
                    cc++;
                    nextCh = cc != size ? attValue.CharAt(cc) : 0;
                }
                else {
                    //XXX ErrorReport: unmatched '}' found
                    delete avt;
                    return 0;
                }
                break;
            default:
                buffer.Append(ch);
                break;
        }
    }

    if (inExpr) {
        //XXX ErrorReport: ending '}' missing
        delete avt;
        return 0;
    }

    if (!buffer.IsEmpty()) {
        Expr* strExpr = new txLiteralExpr(buffer);
        if (!strExpr) {
            // XXX ErrorReport: out of memory
            delete avt;
            return 0;
        }
        avt->addExpr(strExpr);
    }

    return avt;

}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult txExprParser::createBinaryExpr ( nsAutoPtr< Expr > &  left,
nsAutoPtr< Expr > &  right,
Token op,
Expr **  aResult 
) [static, protected, inherited]

Using nsAutoPtr& to optimize passing the ownership to the created binary expression objects.

Private Methods.

Creates a binary Expr for the given operator

Definition at line 217 of file ExprParser.cpp.

{
    NS_ASSERTION(op, "internal error");
    *aResult = nsnull;

    Expr* expr = nsnull;
    switch (op->mType) {
        //-- additive ops
        case Token::ADDITION_OP :
            expr = new AdditiveExpr(left, right, AdditiveExpr::ADDITION);
            break;
        case Token::SUBTRACTION_OP:
            expr = new AdditiveExpr(left, right, AdditiveExpr::SUBTRACTION);
            break;

        //-- case boolean ops
        case Token::AND_OP:
            expr = new BooleanExpr(left, right, BooleanExpr::AND);
            break;
        case Token::OR_OP:
            expr = new BooleanExpr(left, right, BooleanExpr::OR);
            break;

        //-- equality ops
        case Token::EQUAL_OP :
            expr = new RelationalExpr(left, right, RelationalExpr::EQUAL);
            break;
        case Token::NOT_EQUAL_OP :
            expr = new RelationalExpr(left, right, RelationalExpr::NOT_EQUAL);
            break;

        //-- relational ops
        case Token::LESS_THAN_OP:
            expr = new RelationalExpr(left, right, RelationalExpr::LESS_THAN);
            break;
        case Token::GREATER_THAN_OP:
            expr = new RelationalExpr(left, right,
                                      RelationalExpr::GREATER_THAN);
            break;
        case Token::LESS_OR_EQUAL_OP:
            expr = new RelationalExpr(left, right,
                                      RelationalExpr::LESS_OR_EQUAL);
            break;
        case Token::GREATER_OR_EQUAL_OP:
            expr = new RelationalExpr(left, right,
                                      RelationalExpr::GREATER_OR_EQUAL);
            break;

        //-- multiplicative ops
        case Token::DIVIDE_OP :
            expr = new MultiplicativeExpr(left, right,
                                          MultiplicativeExpr::DIVIDE);
            break;
        case Token::MODULUS_OP :
            expr = new MultiplicativeExpr(left, right,
                                          MultiplicativeExpr::MODULUS);
            break;
        case Token::MULTIPLY_OP :
            expr = new MultiplicativeExpr(left, right,
                                          MultiplicativeExpr::MULTIPLY);
            break;
        default:
            NS_NOTREACHED("operator tokens should be already checked");
            return NS_ERROR_UNEXPECTED;
    }
    NS_ENSURE_TRUE(expr, NS_ERROR_OUT_OF_MEMORY);

    *aResult = expr;
    return NS_OK;
}

Here is the caller graph for this function:

nsresult txExprParser::createExpr ( const nsASingleFragmentString aExpression,
txIParseContext aContext,
Expr **  aExpr 
) [static, inherited]

Definition at line 182 of file ExprParser.cpp.

{
    NS_ENSURE_ARG_POINTER(aExpr);
    *aExpr = nsnull;
    txExprLexer lexer;
    nsresult rv = lexer.parse(aExpression);
    if (NS_FAILED(rv)) {
        nsASingleFragmentString::const_char_iterator start;
        aExpression.BeginReading(start);
        aContext->SetErrorOffset(lexer.mPosition - start);
        return rv;
    }
    rv = createExpr(lexer, aContext, aExpr);
    if (NS_SUCCEEDED(rv) && lexer.peek()->mType != Token::END) {
        delete *aExpr;
        *aExpr = nsnull;
        rv = NS_ERROR_XPATH_BINARY_EXPECTED;
    }
    if (NS_FAILED(rv)) {
        nsASingleFragmentString::const_char_iterator start;
        aExpression.BeginReading(start);
        aContext->SetErrorOffset(lexer.peek()->mStart - start);
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult txExprParser::createExpr ( txExprLexer lexer,
txIParseContext aContext,
Expr **  aResult 
) [static, protected, inherited]

Definition at line 291 of file ExprParser.cpp.

{
    *aResult = nsnull;

    nsresult rv = NS_OK;
    MBool done = MB_FALSE;

    nsAutoPtr<Expr> expr;

    txStack exprs;
    txStack ops;
    
    while (!done) {

        MBool unary = MB_FALSE;
        while (lexer.peek()->mType == Token::SUBTRACTION_OP) {
            unary = !unary;
            lexer.nextToken();
        }

        rv = createUnionExpr(lexer, aContext, getter_Transfers(expr));
        if (NS_FAILED(rv)) {
            break;
        }

        if (unary) {
            Expr* uExpr = new UnaryExpr(expr);
            if (!uExpr) {
                rv = NS_ERROR_OUT_OF_MEMORY;
                break;
            }
            expr = uExpr;
        }

        Token* tok = lexer.nextToken();
        switch (tok->mType) {
            case Token::ADDITION_OP:
            case Token::DIVIDE_OP:
            //-- boolean ops
            case Token::AND_OP :
            case Token::OR_OP :
            //-- equality ops
            case Token::EQUAL_OP:
            case Token::NOT_EQUAL_OP:
            //-- relational ops
            case Token::LESS_THAN_OP:
            case Token::GREATER_THAN_OP:
            case Token::LESS_OR_EQUAL_OP:
            case Token::GREATER_OR_EQUAL_OP:
            //-- multiplicative ops
            case Token::MODULUS_OP:
            case Token::MULTIPLY_OP:
            case Token::SUBTRACTION_OP:
            {
                while (!exprs.isEmpty() && precedence(tok) 
                       <= precedence(NS_STATIC_CAST(Token*, ops.peek()))) {
                    // can't use expr as result due to order of evaluation
                    nsAutoPtr<Expr> left(NS_STATIC_CAST(Expr*, exprs.pop()));
                    nsAutoPtr<Expr> right(expr);
                    rv = createBinaryExpr(left, right,
                                          NS_STATIC_CAST(Token*, ops.pop()),
                                          getter_Transfers(expr));
                    if (NS_FAILED(rv)) {
                        break;
                    }
                }
                exprs.push(expr.forget());
                ops.push(tok);
                break;
            }
            default:
                lexer.pushBack();
                done = MB_TRUE;
                break;
        }
    }

    while (NS_SUCCEEDED(rv) && !exprs.isEmpty()) {
        nsAutoPtr<Expr> left(NS_STATIC_CAST(Expr*, exprs.pop()));
        nsAutoPtr<Expr> right(expr);
        rv = createBinaryExpr(left, right, NS_STATIC_CAST(Token*, ops.pop()),
                              getter_Transfers(expr));
    }
    // clean up on error
    while (!exprs.isEmpty()) {
        delete NS_STATIC_CAST(Expr*, exprs.pop());
    }
    NS_ENSURE_SUCCESS(rv, rv);

    *aResult = expr.forget();
    return NS_OK;
}

Here is the call graph for this function:

nsresult txExprParser::createFilter ( txExprLexer lexer,
txIParseContext aContext,
Expr **  aResult 
) [static, protected, inherited]

Definition at line 386 of file ExprParser.cpp.

{
    *aResult = nsnull;

    nsresult rv = NS_OK;
    Token* tok = lexer.nextToken();

    nsAutoPtr<Expr> expr;
    switch (tok->mType) {
        case Token::FUNCTION_NAME :
            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:
            NS_NOTREACHED("internal error, this is not a filter token");
            lexer.pushBack();
            return NS_ERROR_UNEXPECTED;
    }

    if (lexer.peek()->mType == Token::L_BRACKET) {
        nsAutoPtr<FilterExpr> filterExpr(new FilterExpr(expr));
        NS_ENSURE_TRUE(filterExpr, NS_ERROR_OUT_OF_MEMORY);

        //-- handle predicates
        rv = parsePredicates(filterExpr, lexer, aContext);
        NS_ENSURE_SUCCESS(rv, rv);
        expr = filterExpr.forget();
    }

    *aResult = expr.forget();
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult txExprParser::createFunctionCall ( txExprLexer lexer,
txIParseContext aContext,
Expr **  aResult 
) [static, protected, inherited]

Definition at line 453 of file ExprParser.cpp.

{
    *aResult = nsnull;

    nsAutoPtr<FunctionCall> fnCall;

    Token* tok = lexer.nextToken();
    NS_ASSERTION(tok->mType == Token::FUNCTION_NAME, "FunctionCall expected");

    //-- compare function names
    nsCOMPtr<nsIAtom> prefix, lName;
    PRInt32 namespaceID;
    nsresult rv = resolveQName(tok->Value(), getter_AddRefs(prefix), aContext,
                               getter_AddRefs(lName), namespaceID);
    NS_ENSURE_SUCCESS(rv, rv);

    if (namespaceID == kNameSpaceID_None) {
        PRBool isOutOfMem = PR_TRUE;
        if (lName == txXPathAtoms::boolean) {
            fnCall = new BooleanFunctionCall(BooleanFunctionCall::TX_BOOLEAN);
        }
        else if (lName == txXPathAtoms::concat) {
            fnCall = new StringFunctionCall(StringFunctionCall::CONCAT);
        }
        else if (lName == txXPathAtoms::contains) {
            fnCall = new StringFunctionCall(StringFunctionCall::CONTAINS);
        }
        else if (lName == txXPathAtoms::count) {
            fnCall = new NodeSetFunctionCall(NodeSetFunctionCall::COUNT);
        }
        else if (lName == txXPathAtoms::_false) {
            fnCall = new BooleanFunctionCall(BooleanFunctionCall::TX_FALSE);
        }
        else if (lName == txXPathAtoms::id) {
            fnCall = new NodeSetFunctionCall(NodeSetFunctionCall::ID);
        }
        else if (lName == txXPathAtoms::lang) {
            fnCall = new BooleanFunctionCall(BooleanFunctionCall::TX_LANG);
        }
        else if (lName == txXPathAtoms::last) {
            fnCall = new NodeSetFunctionCall(NodeSetFunctionCall::LAST);
        }
        else if (lName == txXPathAtoms::localName) {
            fnCall = new NodeSetFunctionCall(NodeSetFunctionCall::LOCAL_NAME);
        }
        else if (lName == txXPathAtoms::name) {
            fnCall = new NodeSetFunctionCall(NodeSetFunctionCall::NAME);
        }
        else if (lName == txXPathAtoms::namespaceUri) {
            fnCall = new NodeSetFunctionCall(NodeSetFunctionCall::NAMESPACE_URI);
        }
        else if (lName == txXPathAtoms::normalizeSpace) {
            fnCall = new StringFunctionCall(StringFunctionCall::NORMALIZE_SPACE);
        }
        else if (lName == txXPathAtoms::_not) {
            fnCall = new BooleanFunctionCall(BooleanFunctionCall::TX_NOT);
        }
        else if (lName == txXPathAtoms::position) {
            fnCall = new NodeSetFunctionCall(NodeSetFunctionCall::POSITION);
        }
        else if (lName == txXPathAtoms::startsWith) {
            fnCall = new StringFunctionCall(StringFunctionCall::STARTS_WITH);
        }
        else if (lName == txXPathAtoms::string) {
            fnCall = new StringFunctionCall(StringFunctionCall::STRING);
        }
        else if (lName == txXPathAtoms::stringLength) {
            fnCall = new StringFunctionCall(StringFunctionCall::STRING_LENGTH);
        }
        else if (lName == txXPathAtoms::substring) {
            fnCall = new StringFunctionCall(StringFunctionCall::SUBSTRING);
        }
        else if (lName == txXPathAtoms::substringAfter) {
            fnCall = new StringFunctionCall(StringFunctionCall::SUBSTRING_AFTER);
        }
        else if (lName == txXPathAtoms::substringBefore) {
            fnCall = new StringFunctionCall(StringFunctionCall::SUBSTRING_BEFORE);
        }
        else if (lName == txXPathAtoms::sum) {
            fnCall = new NumberFunctionCall(NumberFunctionCall::SUM);
        }
        else if (lName == txXPathAtoms::translate) {
            fnCall = new StringFunctionCall(StringFunctionCall::TRANSLATE);
        }
        else if (lName == txXPathAtoms::_true) {
            fnCall = new BooleanFunctionCall(BooleanFunctionCall::TX_TRUE);
        }
        else if (lName == txXPathAtoms::number) {
            fnCall = new NumberFunctionCall(NumberFunctionCall::NUMBER);
        }
        else if (lName == txXPathAtoms::round) {
            fnCall = new NumberFunctionCall(NumberFunctionCall::ROUND);
        }
        else if (lName == txXPathAtoms::ceiling) {
            fnCall = new NumberFunctionCall(NumberFunctionCall::CEILING);
        }
        else if (lName == txXPathAtoms::floor) {
            fnCall = new NumberFunctionCall(NumberFunctionCall::FLOOR);
        }
        else {
            // didn't find functioncall here, fnCall should be null
            isOutOfMem = PR_FALSE;
        }
        if (!fnCall && isOutOfMem) {
            NS_ERROR("XPath FunctionLib failed on out-of-memory");
            return NS_ERROR_OUT_OF_MEMORY;
        }
    }
    // check extension functions and xslt
    if (!fnCall) {
        rv = aContext->resolveFunctionCall(lName, namespaceID,
                                           *getter_Transfers(fnCall));

        if (rv == NS_ERROR_NOT_IMPLEMENTED) {
            // this should just happen for unparsed-entity-uri()
            NS_ASSERTION(!fnCall, "Now is it implemented or not?");
            rv = parseParameters(0, lexer, aContext);
            NS_ENSURE_SUCCESS(rv, rv);
            *aResult = new txLiteralExpr(tok->Value() +
                                         NS_LITERAL_STRING(" not implemented."));
            NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
            return NS_OK;
        }

        if (NS_FAILED(rv)) {
            NS_ERROR("Creation of FunctionCall failed");
            return rv;
        }
    }
    
    //-- handle parametes
    rv = parseParameters(fnCall, lexer, aContext);
    NS_ENSURE_SUCCESS(rv, rv);

    *aResult = fnCall.forget();
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult txPatternParser::createIdPattern ( txExprLexer aLexer,
txPattern *&  aPattern 
) [static, protected]

Definition at line 243 of file txPatternParser.cpp.

{
    // check for '(' Literal ')'
    if (aLexer.nextToken()->mType != Token::L_PAREN && 
        aLexer.peek()->mType != Token::LITERAL)
        return NS_ERROR_XPATH_PARSE_FAILURE;
    const nsDependentSubstring& value =
        aLexer.nextToken()->Value();
    if (aLexer.nextToken()->mType != Token::R_PAREN)
        return NS_ERROR_XPATH_PARSE_FAILURE;
    aPattern  = new txIdPattern(value);
    return aPattern ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult txPatternParser::createKeyPattern ( txExprLexer aLexer,
txIParseContext aContext,
txPattern *&  aPattern 
) [static, protected]

Definition at line 258 of file txPatternParser.cpp.

{
    // check for '(' Literal, Literal ')'
    if (aLexer.nextToken()->mType != Token::L_PAREN && 
        aLexer.peek()->mType != Token::LITERAL)
        return NS_ERROR_XPATH_PARSE_FAILURE;
    const nsDependentSubstring& key =
        aLexer.nextToken()->Value();
    if (aLexer.nextToken()->mType != Token::COMMA && 
        aLexer.peek()->mType != Token::LITERAL)
        return NS_ERROR_XPATH_PARSE_FAILURE;
    const nsDependentSubstring& value =
        aLexer.nextToken()->Value();
    if (aLexer.nextToken()->mType != Token::R_PAREN)
        return NS_ERROR_XPATH_PARSE_FAILURE;

    const PRUnichar* colon;
    if (!XMLUtils::isValidQName(PromiseFlatString(key), &colon))
        return NS_ERROR_XPATH_PARSE_FAILURE;
    nsCOMPtr<nsIAtom> prefix, localName;
    PRInt32 namespaceID;
    nsresult rv = resolveQName(key, getter_AddRefs(prefix), aContext,
                               getter_AddRefs(localName), namespaceID);
    if (NS_FAILED(rv))
        return rv;

    aPattern  = new txKeyPattern(prefix, localName, namespaceID, value);

    return aPattern ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult txExprParser::createLocationStep ( txExprLexer lexer,
txIParseContext aContext,
Expr **  aResult 
) [static, protected, inherited]

Definition at line 593 of file ExprParser.cpp.

{
    *aExpr = nsnull;

    //-- child axis is default
    LocationStep::LocationStepType axisIdentifier = LocationStep::CHILD_AXIS;
    nsAutoPtr<txNodeTest> nodeTest;

    //-- get Axis Identifier or AbbreviatedStep, if present
    Token* tok = lexer.peek();
    switch (tok->mType) {
        case Token::AXIS_IDENTIFIER:
        {
            //-- eat token
            lexer.nextToken();
            nsCOMPtr<nsIAtom> axis = do_GetAtom(tok->Value());
            if (axis == txXPathAtoms::ancestor) {
                axisIdentifier = LocationStep::ANCESTOR_AXIS;
            }
            else if (axis == txXPathAtoms::ancestorOrSelf) {
                axisIdentifier = LocationStep::ANCESTOR_OR_SELF_AXIS;
            }
            else if (axis == txXPathAtoms::attribute) {
                axisIdentifier = LocationStep::ATTRIBUTE_AXIS;
            }
            else if (axis == txXPathAtoms::child) {
                axisIdentifier = LocationStep::CHILD_AXIS;
            }
            else if (axis == txXPathAtoms::descendant) {
                axisIdentifier = LocationStep::DESCENDANT_AXIS;
            }
            else if (axis == txXPathAtoms::descendantOrSelf) {
                axisIdentifier = LocationStep::DESCENDANT_OR_SELF_AXIS;
            }
            else if (axis == txXPathAtoms::following) {
                axisIdentifier = LocationStep::FOLLOWING_AXIS;
            }
            else if (axis == txXPathAtoms::followingSibling) {
                axisIdentifier = LocationStep::FOLLOWING_SIBLING_AXIS;
            }
            else if (axis == txXPathAtoms::_namespace) {
                axisIdentifier = LocationStep::NAMESPACE_AXIS;
            }
            else if (axis == txXPathAtoms::parent) {
                axisIdentifier = LocationStep::PARENT_AXIS;
            }
            else if (axis == txXPathAtoms::preceding) {
                axisIdentifier = LocationStep::PRECEDING_AXIS;
            }
            else if (axis == txXPathAtoms::precedingSibling) {
                axisIdentifier = LocationStep::PRECEDING_SIBLING_AXIS;
            }
            else if (axis == txXPathAtoms::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();

        switch (tok->mType) {
            case 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);
                    switch (axisIdentifier) {
                        case LocationStep::ATTRIBUTE_AXIS:
                            nodeTest = new txNameTest(prefix, lName, nspace,
                                                      txXPathNodeType::ATTRIBUTE_NODE);
                            break;
                        default:
                            nodeTest = new txNameTest(prefix, lName, nspace,
                                                      txXPathNodeType::ELEMENT_NODE);
                            break;
                    }
                    NS_ENSURE_TRUE(nodeTest, NS_ERROR_OUT_OF_MEMORY);
                }
                break;
            default:
                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);

    //-- handle predicates
    rv = parsePredicates(lstep, lexer, aContext);
    NS_ENSURE_SUCCESS(rv, rv);

    *aExpr = lstep.forget();
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult txPatternParser::createLocPathPattern ( txExprLexer aLexer,
txIParseContext aContext,
txPattern *&  aPattern 
) [static, protected]

Definition at line 128 of file txPatternParser.cpp.

{
    nsresult rv = NS_OK;

    MBool isChild = MB_TRUE;
    MBool isAbsolute = MB_FALSE;
    txPattern* stepPattern = 0;
    txLocPathPattern* pathPattern = 0;

    Token::Type type = aLexer.peek()->mType;
    switch (type) {
        case Token::ANCESTOR_OP:
            isChild = MB_FALSE;
            isAbsolute = MB_TRUE;
            aLexer.nextToken();
            break;
        case Token::PARENT_OP:
            aLexer.nextToken();
            isAbsolute = MB_TRUE;
            if (aLexer.peek()->mType == Token::END || 
                aLexer.peek()->mType == Token::UNION_OP) {
                aPattern = new txRootPattern();

                return aPattern ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
            }
            break;
        case Token::FUNCTION_NAME:
            // id(Literal) or key(Literal, Literal)
            {
                nsCOMPtr<nsIAtom> nameAtom =
                    do_GetAtom(aLexer.nextToken()->Value());
                if (nameAtom == txXPathAtoms::id) {
                    rv = createIdPattern(aLexer, stepPattern);
                }
                else if (nameAtom == txXSLTAtoms::key) {
                    rv = createKeyPattern(aLexer, aContext, stepPattern);
                }
                if (NS_FAILED(rv))
                    return rv;
            }
            break;
        default:
            break;
    }
    if (!stepPattern) {
        rv = createStepPattern(aLexer, aContext, stepPattern);
        if (NS_FAILED(rv))
            return rv;
    }

    type = aLexer.peek()->mType;
    if (!isAbsolute && type != Token::PARENT_OP
        && type != Token::ANCESTOR_OP) {
        aPattern = stepPattern;
        return NS_OK;
    }

    pathPattern = new txLocPathPattern();
    if (!pathPattern) {
        delete stepPattern;
        return NS_ERROR_OUT_OF_MEMORY;
    }

    if (isAbsolute) {
        txRootPattern* root = new txRootPattern();
        if (!root) {
            delete stepPattern;
            delete pathPattern;
            return NS_ERROR_OUT_OF_MEMORY;
        }

#ifdef TX_TO_STRING
        root->setSerialize(PR_FALSE);
#endif

        rv = pathPattern->addStep(root, isChild);
        if (NS_FAILED(rv)) {
            delete stepPattern;
            delete pathPattern;
            delete root;
            return NS_ERROR_OUT_OF_MEMORY;
        }
    }

    rv = pathPattern->addStep(stepPattern, isChild);
    if (NS_FAILED(rv)) {
        delete stepPattern;
        delete pathPattern;
        return NS_ERROR_OUT_OF_MEMORY;
    }
    stepPattern = 0; // stepPattern is part of pathPattern now

    while (type == Token::PARENT_OP || type == Token::ANCESTOR_OP) {
        isChild = type == Token::PARENT_OP;
        aLexer.nextToken();
        rv = createStepPattern(aLexer, aContext, stepPattern);
        if (NS_FAILED(rv)) {
            delete pathPattern;
            return rv;
        }
        rv = pathPattern->addStep(stepPattern, isChild);
        if (NS_FAILED(rv)) {
            delete stepPattern;
            delete pathPattern;
            return NS_ERROR_OUT_OF_MEMORY;
        }
        stepPattern = 0; // stepPattern is part of pathPattern now
        type = aLexer.peek()->mType;
    }
    aPattern = pathPattern;
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult txExprParser::createNodeTypeTest ( txExprLexer lexer,
txNodeTest **  aResult 
) [static, protected, inherited]

This method only handles comment(), text(), processing-instructing() and node()

Definition at line 728 of file ExprParser.cpp.

{
    *aTest = 0;
    nsAutoPtr<txNodeTypeTest> nodeTest;

    Token* nodeTok = lexer.nextToken();

    switch (nodeTok->mType) {
        case Token::COMMENT:
            nodeTest = new txNodeTypeTest(txNodeTypeTest::COMMENT_TYPE);
            break;
        case Token::NODE :
            nodeTest = new txNodeTypeTest(txNodeTypeTest::NODE_TYPE);
            break;
        case Token::PROC_INST :
            nodeTest = new txNodeTypeTest(txNodeTypeTest::PI_TYPE);
            break;
        case Token::TEXT :
            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 (lexer.nextToken()->mType != Token::L_PAREN) {
        lexer.pushBack();
        NS_NOTREACHED("txExprLexer doesn't generate nodetypetest without(");
        return NS_ERROR_UNEXPECTED;
    }
    if (nodeTok->mType == Token::PROC_INST &&
        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;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult txExprParser::createPathExpr ( txExprLexer lexer,
txIParseContext aContext,
Expr **  aResult 
) [static, protected, inherited]

Creates a PathExpr using the given txExprLexer.

Parameters:
lexerthe txExprLexer for retrieving Tokens

Definition at line 778 of file ExprParser.cpp.

{
    *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) {
        if (isFilterExprToken(tok)) {
            rv = createFilter(lexer, aContext, getter_Transfers(expr));
        }
        else {
            rv = createLocationStep(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
        NS_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.forget(), PathExpr::RELATIVE_OP);
    NS_ENSURE_SUCCESS(rv, rv);

    // 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.forget(), pathOp);
        NS_ENSURE_SUCCESS(rv, rv);
    }
    NS_NOTREACHED("internal xpath parser error");
    return NS_ERROR_UNEXPECTED;
}

Here is the call graph for this function:

Here is the caller graph for this function:

txPattern * txPatternParser::createPattern ( const nsAFlatString aPattern,
txIParseContext aContext 
) [static]

Definition at line 47 of file txPatternParser.cpp.

{
    txPattern* pattern = 0;
    txExprLexer lexer;
    nsresult rv = lexer.parse(aPattern);
    if (NS_FAILED(rv)) {
        // XXX error report parsing error
        return 0;
    }
    rv = createUnionPattern(lexer, aContext, pattern);
    if (NS_FAILED(rv)) {
        // XXX error report parsing error
        return 0;
    }
    return pattern;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult txPatternParser::createStepPattern ( txExprLexer aLexer,
txIParseContext aContext,
txPattern *&  aPattern 
) [static, protected]

Definition at line 291 of file txPatternParser.cpp.

{
    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 = 0;
    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;
        }
        if (isAttr) {
            nodeTest = new txNameTest(prefix, lName, nspace,
                                      txXPathNodeType::ATTRIBUTE_NODE);
        }
        else {
            nodeTest = new txNameTest(prefix, lName, nspace,
                                      txXPathNodeType::ELEMENT_NODE);
        }
        if (!nodeTest) {
            return NS_ERROR_OUT_OF_MEMORY;
        }
    }
    else {
        aLexer.pushBack();
        rv = createNodeTypeTest(aLexer, &nodeTest);
        NS_ENSURE_SUCCESS(rv, rv);
    }

    txStepPattern* step = new txStepPattern(nodeTest, isAttr);
    if (!step) {
        delete nodeTest;
        return NS_ERROR_OUT_OF_MEMORY;
    }
    nodeTest = 0;
    rv = parsePredicates(step, aLexer, aContext);
    if (NS_FAILED(rv)) {
        delete step;
        return rv;
    }

    aPattern = step;
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult txExprParser::createUnionExpr ( txExprLexer lexer,
txIParseContext aContext,
Expr **  aResult 
) [static, protected, inherited]

Creates a PathExpr using the given txExprLexer.

Parameters:
lexerthe txExprLexer for retrieving Tokens

Definition at line 866 of file ExprParser.cpp.

{
    *aResult = nsnull;

    nsAutoPtr<Expr> expr;
    nsresult rv = createPathExpr(lexer, aContext, getter_Transfers(expr));
    NS_ENSURE_SUCCESS(rv, rv);
    
    if (lexer.peek()->mType != Token::UNION_OP) {
        *aResult = expr.forget();
        return NS_OK;
    }

    nsAutoPtr<UnionExpr> unionExpr(new UnionExpr());
    NS_ENSURE_TRUE(unionExpr, NS_ERROR_OUT_OF_MEMORY);

    rv = unionExpr->addExpr(expr.forget());
    NS_ENSURE_SUCCESS(rv, rv);

    while (lexer.peek()->mType == Token::UNION_OP) {
        lexer.nextToken(); //-- eat token

        rv = createPathExpr(lexer, aContext, getter_Transfers(expr));
        NS_ENSURE_SUCCESS(rv, rv);

        rv = unionExpr->addExpr(expr.forget());
        NS_ENSURE_SUCCESS(rv, rv);
    }

    *aResult = unionExpr.forget();
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult txPatternParser::createUnionPattern ( txExprLexer aLexer,
txIParseContext aContext,
txPattern *&  aPattern 
) [static, protected]

Definition at line 65 of file txPatternParser.cpp.

{
    nsresult rv = NS_OK;
    txPattern* locPath = 0;

    rv = createLocPathPattern(aLexer, aContext, locPath);
    if (NS_FAILED(rv))
        return rv;

    Token::Type type = aLexer.peek()->mType;
    if (type == Token::END) {
        aPattern = locPath;
        return NS_OK;
    }

    if (type != Token::UNION_OP) {
        delete locPath;
        return NS_ERROR_XPATH_PARSE_FAILURE;
    }

    txUnionPattern* unionPattern = new txUnionPattern();
    if (!unionPattern) {
        delete locPath;
        return NS_ERROR_OUT_OF_MEMORY;
    }
    rv = unionPattern->addPattern(locPath);
#if 0 // XXX addPattern can't fail yet, it doesn't check for mem
    if (NS_FAILED(rv)) {
        delete unionPattern;
        delete locPath;
        return rv;
    }
#endif

    aLexer.nextToken();
    do {
        rv = createLocPathPattern(aLexer, aContext, locPath);
        if (NS_FAILED(rv)) {
            delete unionPattern;
            return rv;
        }
        rv = unionPattern->addPattern(locPath);
#if 0 // XXX addPattern can't fail yet, it doesn't check for mem
        if (NS_FAILED(rv)) {
            delete unionPattern;
            delete locPath;
            return rv;
        }
#endif
        type = aLexer.nextToken()->mType;
    } while (type == Token::UNION_OP);

    if (type != Token::END) {
        delete unionPattern;
        return NS_ERROR_XPATH_PARSE_FAILURE;
    }

    aPattern = unionPattern;
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool txExprParser::isFilterExprToken ( Token aToken) [static, protected, inherited]

Definition at line 901 of file ExprParser.cpp.

{
    switch (aToken->mType) {
        case Token::LITERAL:
        case Token::NUMBER:
        case Token::FUNCTION_NAME:
        case Token::VAR_REFERENCE:
        case Token::L_PAREN:            // grouping expr
            return PR_TRUE;
        default:
            return PR_FALSE;
    }
}

Here is the caller graph for this function:

PRBool txExprParser::isLocationStepToken ( Token aToken) [static, protected, inherited]

Definition at line 916 of file ExprParser.cpp.

{
    switch (aToken->mType) {
        case Token::AXIS_IDENTIFIER :
        case Token::AT_SIGN :
        case Token::PARENT_NODE :
        case Token::SELF_NODE :
            return PR_TRUE;
        default:
            return isNodeTypeToken(aToken);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool txExprParser::isNodeTypeToken ( Token aToken) [static, protected, inherited]

Definition at line 930 of file ExprParser.cpp.

{
    switch (aToken->mType) {
        case Token::CNAME:
        case Token::COMMENT:
        case Token::NODE :
        case Token::PROC_INST :
        case Token::TEXT :
            return PR_TRUE;
        default:
            return PR_FALSE;
    }
}

Here is the caller graph for this function:

nsresult txExprParser::parseParameters ( FunctionCall aFnCall,
txExprLexer lexer,
txIParseContext aContext 
) [static, protected, inherited]

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.

Parameters:
list,theList to add parameter expressions to
lexerthe txExprLexer to use for parsing tokens
Returns:
NS_OK if successful, or another rv otherwise

Definition at line 986 of file ExprParser.cpp.

{
    if (lexer.nextToken()->mType != Token::L_PAREN) {
        lexer.pushBack();
        NS_NOTREACHED("txExprLexer doesn't generate functions without(");
        return NS_ERROR_UNEXPECTED;
    }

    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;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult txExprParser::parsePredicates ( PredicateList aPredicateList,
txExprLexer lexer,
txIParseContext aContext 
) [static, protected, inherited]

Using the given lexer, parses the tokens if they represent a predicate list If an error occurs a non-zero String pointer will be returned containing the error message.

Parameters:
predicateList,thePredicateList to add predicate expressions to
lexerthe ExprLexer to use for parsing tokens
Returns:
0 if successful, or a String pointer to the error message
Parameters:
predicateList,thePredicateList to add predicate expressions to
lexerthe txExprLexer to use for parsing tokens
Returns:
0 if successful, or a String pointer to the error message

Definition at line 953 of file ExprParser.cpp.

{
    nsAutoPtr<Expr> expr;
    nsresult rv = NS_OK;
    while (lexer.peek()->mType == Token::L_BRACKET) {
        //-- eat Token
        lexer.nextToken();

        rv = createExpr(lexer, aContext, getter_Transfers(expr));
        NS_ENSURE_SUCCESS(rv, rv);

        rv = aPredicateList->add(expr.forget());
        NS_ENSURE_SUCCESS(rv, rv);

        if (lexer.nextToken()->mType != Token::R_BRACKET) {
            lexer.pushBack();
            return NS_ERROR_XPATH_BRACKET_EXPECTED;
        }
    }
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

short txExprParser::precedence ( Token aToken) [static, protected, inherited]

Definition at line 1027 of file ExprParser.cpp.

{
    switch (aToken->mType) {
        case Token::OR_OP:
            return 1;
        case Token::AND_OP:
            return 2;
        //-- equality
        case Token::EQUAL_OP:
        case Token::NOT_EQUAL_OP:
            return 3;
        //-- relational
        case Token::LESS_THAN_OP:
        case Token::GREATER_THAN_OP:
        case Token::LESS_OR_EQUAL_OP:
        case Token::GREATER_OR_EQUAL_OP:
            return 4;
        //-- additive operators
        case Token::ADDITION_OP:
        case Token::SUBTRACTION_OP:
            return 5;
        //-- multiplicative
        case Token::DIVIDE_OP:
        case Token::MULTIPLY_OP:
        case Token::MODULUS_OP:
            return 6;
        default:
            break;
    }
    return 0;
}

Here is the caller graph for this function:

nsresult txExprParser::resolveQName ( const nsAString &  aQName,
nsIAtom **  aPrefix,
txIParseContext aContext,
nsIAtom **  aLocalName,
PRInt32 aNamespace,
PRBool  aIsNameTest = MB_FALSE 
) [static, protected, inherited]

Resolve a QName, given the mContext parse context.

Returns prefix and localName as well as namespace ID

Definition at line 1060 of file ExprParser.cpp.

{
    aNamespace = kNameSpaceID_None;
    PRInt32 idx = aQName.FindChar(':');
    if (idx > 0) {
        *aPrefix = NS_NewAtom(Substring(aQName, 0, (PRUint32)idx));
        if (!*aPrefix) {
            return NS_ERROR_OUT_OF_MEMORY;
        }
        *aLocalName = NS_NewAtom(Substring(aQName, (PRUint32)idx + 1,
                                           aQName.Length() - (idx + 1)));
        if (!*aLocalName) {
            NS_RELEASE(*aPrefix);
            return NS_ERROR_OUT_OF_MEMORY;
        }
        return aContext->resolveNamespacePrefix(*aPrefix, aNamespace);
    }
    // the lexer dealt with idx == 0
    *aPrefix = 0;
    if (aIsNameTest && aContext->caseInsensitiveNameTests()) {
        nsAutoString lcname;
        TX_ToLowerCase(aQName, lcname);
        *aLocalName = NS_NewAtom(lcname);
    }
    else {
        *aLocalName = NS_NewAtom(aQName);
    }
    if (!*aLocalName) {
        return NS_ERROR_OUT_OF_MEMORY;
    }
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files: