summaryrefslogtreecommitdiffstats
path: root/dom/xslt/xpath/txExprParser.h
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/xslt/xpath/txExprParser.h
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/xslt/xpath/txExprParser.h')
-rw-r--r--dom/xslt/xpath/txExprParser.h109
1 files changed, 109 insertions, 0 deletions
diff --git a/dom/xslt/xpath/txExprParser.h b/dom/xslt/xpath/txExprParser.h
new file mode 100644
index 000000000..238e03399
--- /dev/null
+++ b/dom/xslt/xpath/txExprParser.h
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/**
+ * ExprParser
+ * This class is used to parse XSL Expressions
+ * @see ExprLexer
+**/
+
+#ifndef MITREXSL_EXPRPARSER_H
+#define MITREXSL_EXPRPARSER_H
+
+#include "txCore.h"
+#include "nsAutoPtr.h"
+#include "nsString.h"
+
+class Expr;
+class txExprLexer;
+class FunctionCall;
+class LocationStep;
+class nsIAtom;
+class PredicateList;
+class Token;
+class txIParseContext;
+class txNodeTest;
+
+class txExprParser
+{
+public:
+
+ static nsresult createExpr(const nsSubstring& aExpression,
+ txIParseContext* aContext, Expr** aExpr)
+ {
+ return createExprInternal(aExpression, 0, aContext, aExpr);
+ }
+
+ /**
+ * Creates an Attribute Value Template using the given value
+ */
+ static nsresult createAVT(const nsSubstring& aAttrValue,
+ txIParseContext* aContext,
+ Expr** aResult);
+
+
+protected:
+ static nsresult createExprInternal(const nsSubstring& aExpression,
+ uint32_t aSubStringPos,
+ txIParseContext* aContext,
+ Expr** aExpr);
+ /**
+ * Using nsAutoPtr& to optimize passing the ownership to the
+ * created binary expression objects.
+ */
+ static nsresult createBinaryExpr(nsAutoPtr<Expr>& left,
+ nsAutoPtr<Expr>& right, Token* op,
+ Expr** aResult);
+ static nsresult createExpr(txExprLexer& lexer, txIParseContext* aContext,
+ Expr** aResult);
+ static nsresult createFilterOrStep(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);
+ static nsresult createPathExpr(txExprLexer& lexer,
+ txIParseContext* aContext,
+ Expr** aResult);
+ static nsresult createUnionExpr(txExprLexer& lexer,
+ txIParseContext* aContext,
+ Expr** aResult);
+
+ static bool isLocationStepToken(Token* aToken);
+
+ static short precedence(Token* aToken);
+
+ /**
+ * Resolve a QName, given the mContext parse context.
+ * Returns prefix and localName as well as namespace ID
+ */
+ static nsresult resolveQName(const nsAString& aQName, nsIAtom** aPrefix,
+ txIParseContext* aContext,
+ nsIAtom** aLocalName, int32_t& aNamespace,
+ bool aIsNameTest = false);
+
+ /**
+ * 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.
+ * @param predicateList, the PredicateList to add predicate expressions to
+ * @param lexer the ExprLexer to use for parsing tokens
+ * @return 0 if successful, or a String pointer to the error message
+ */
+ static nsresult parsePredicates(PredicateList* aPredicateList,
+ txExprLexer& lexer,
+ txIParseContext* aContext);
+ static nsresult parseParameters(FunctionCall* aFnCall, txExprLexer& lexer,
+ txIParseContext* aContext);
+
+};
+
+#endif