1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 * This class is used to parse XSL Expressions
12 #ifndef MITREXSL_EXPRPARSER_H
13 #define MITREXSL_EXPRPARSER_H
16 #include "mozilla/UniquePtr.h"
26 class txIParseContext
;
31 static nsresult
createExpr(const nsAString
& aExpression
,
32 txIParseContext
* aContext
, Expr
** aExpr
) {
33 return createExprInternal(aExpression
, 0, aContext
, aExpr
);
37 * Creates an Attribute Value Template using the given value
39 static nsresult
createAVT(const nsAString
& aAttrValue
,
40 txIParseContext
* aContext
, Expr
** aResult
);
43 static nsresult
createExprInternal(const nsAString
& aExpression
,
44 uint32_t aSubStringPos
,
45 txIParseContext
* aContext
, Expr
** aExpr
);
47 * Using nsAutoPtr& to optimize passing the ownership to the
48 * created binary expression objects.
50 static nsresult
createBinaryExpr(mozilla::UniquePtr
<Expr
>& left
,
51 mozilla::UniquePtr
<Expr
>& right
, Token
* op
,
53 static nsresult
createExpr(txExprLexer
& lexer
, txIParseContext
* aContext
,
55 static nsresult
createFilterOrStep(txExprLexer
& lexer
,
56 txIParseContext
* aContext
, Expr
** aResult
);
57 static nsresult
createFunctionCall(txExprLexer
& lexer
,
58 txIParseContext
* aContext
, Expr
** aResult
);
59 static nsresult
createLocationStep(txExprLexer
& lexer
,
60 txIParseContext
* aContext
, Expr
** aResult
);
61 static nsresult
createNodeTypeTest(txExprLexer
& lexer
, txNodeTest
** aResult
);
62 static nsresult
createPathExpr(txExprLexer
& lexer
, txIParseContext
* aContext
,
64 static nsresult
createUnionExpr(txExprLexer
& lexer
, txIParseContext
* aContext
,
67 static bool isLocationStepToken(Token
* aToken
);
69 static short precedence(Token
* aToken
);
72 * Resolve a QName, given the mContext parse context.
73 * Returns prefix and localName as well as namespace ID
75 static nsresult
resolveQName(const nsAString
& aQName
, nsAtom
** aPrefix
,
76 txIParseContext
* aContext
, nsAtom
** aLocalName
,
77 int32_t& aNamespace
, bool aIsNameTest
= false);
80 * Using the given lexer, parses the tokens if they represent a
82 * If an error occurs a non-zero String pointer will be returned
83 * containing the error message.
84 * @param predicateList, the PredicateList to add predicate expressions to
85 * @param lexer the ExprLexer to use for parsing tokens
86 * @return 0 if successful, or a String pointer to the error message
88 static nsresult
parsePredicates(PredicateList
* aPredicateList
,
90 txIParseContext
* aContext
);
91 static nsresult
parseParameters(FunctionCall
* aFnCall
, txExprLexer
& lexer
,
92 txIParseContext
* aContext
);