Bug 1935611 - Fix libyuv/libpng link failed for loongarch64. r=glandium,tnikkel,ng
[gecko.git] / dom / xslt / xpath / txExprParser.h
blob06c07cf2329bdf578aaa07059af1d65f67b04aa4
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/. */
6 /**
7 * ExprParser
8 * This class is used to parse XSL Expressions
9 * @see ExprLexer
10 **/
12 #ifndef MITREXSL_EXPRPARSER_H
13 #define MITREXSL_EXPRPARSER_H
15 #include "txCore.h"
16 #include "mozilla/UniquePtr.h"
17 #include "nsString.h"
19 class Expr;
20 class txExprLexer;
21 class FunctionCall;
22 class LocationStep;
23 class nsAtom;
24 class PredicateList;
25 class Token;
26 class txIParseContext;
27 class txNodeTest;
29 class txExprParser {
30 public:
31 static nsresult createExpr(const nsAString& aExpression,
32 txIParseContext* aContext, Expr** aExpr) {
33 return createExprInternal(aExpression, 0, aContext, aExpr);
36 /**
37 * Creates an Attribute Value Template using the given value
39 static nsresult createAVT(const nsAString& aAttrValue,
40 txIParseContext* aContext, Expr** aResult);
42 protected:
43 static nsresult createExprInternal(const nsAString& aExpression,
44 uint32_t aSubStringPos,
45 txIParseContext* aContext, Expr** aExpr);
46 /**
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,
52 Expr** aResult);
53 static nsresult createExpr(txExprLexer& lexer, txIParseContext* aContext,
54 Expr** aResult);
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,
63 Expr** aResult);
64 static nsresult createUnionExpr(txExprLexer& lexer, txIParseContext* aContext,
65 Expr** aResult);
67 static bool isLocationStepToken(Token* aToken);
69 static short precedence(Token* aToken);
71 /**
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);
79 /**
80 * Using the given lexer, parses the tokens if they represent a
81 * predicate list
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,
89 txExprLexer& lexer,
90 txIParseContext* aContext);
91 static nsresult parseParameters(FunctionCall* aFnCall, txExprLexer& lexer,
92 txIParseContext* aContext);
95 #endif