/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtXmlPatterns module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
/* A Bison parser, made by GNU Bison 3.0.2. */
/* Bison implementation for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* C LALR(1) parser skeleton written by Richard Stallman, by
simplifying the original so-called "semantic" parser. */
/* All symbols defined below should begin with yy or YY, to avoid
infringing on user name space. This should be done even for local
variables, as they might otherwise be expanded by user macros.
There are some unavoidable exceptions within include files to
define necessary library symbols; they are noted "INFRINGES ON
USER NAME SPACE" below. */
/* Identify Bison output. */
#define YYBISON 1
/* Bison version. */
#define YYBISON_VERSION "3.0.2"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
/* Pure parsers. */
#define YYPURE 1
/* Push parsers. */
#define YYPUSH 0
/* Pull parsers. */
#define YYPULL 1
/* Substitute the variable and function names. */
#define yyparse XPathparse
#define yylex XPathlex
#define yyerror XPatherror
#define yydebug XPathdebug
#define yynerrs XPathnerrs
/* Copy the first part of user declarations. */
#line 44 "querytransformparser.ypp" /* yacc.c:339 */
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtXmlPatterns module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
/*
* The cpp generated with bison 2.1 wants to
* redeclare the C-like prototypes of 'malloc' and 'free', so we avoid that.
*/
#define YYMALLOC malloc
#define YYFREE free
QT_BEGIN_NAMESPACE
/* Due to Qt's QT_BEGIN_NAMESPACE magic, we can't use `using namespace', for some
* undocumented reason. */
namespace QPatternist
{
/**
* "Macro that you define with #define in the Bison declarations
* section to request verbose, specific error message strings when
* yyerror is called."
*/
#define YYERROR_VERBOSE 1
#define YYLTYPE_IS_TRIVIAL 0
#define YYINITDEPTH 1
#define yyoverflow parseInfo->handleStackOverflow
/* Suppresses `warning: "YYENABLE_NLS" is not defined`
* @c YYENABLE_NLS enables Bison internationalization, and we don't
* use that, so disable it. See the Bison Manual, section 4.5 Parser Internationalization.
*/
#define YYENABLE_NLS 0
static inline QSourceLocation fromYYLTYPE(const YYLTYPE &sourceLocator,
const ParserContext *const parseInfo)
{
return QSourceLocation(parseInfo->tokenizer->queryURI(),
sourceLocator.first_line,
sourceLocator.first_column);
}
/**
* @internal
* @relates QXmlQuery
*/
typedef QFlags QueryLanguages;
/**
* @short Flags invalid expressions and declarations in the currently
* parsed language.
*
* Since this grammar is used for several languages: XQuery 1.0, XSL-T 2.0, and
* XPath 2.0 inside XSL-T, and field and selector patterns in W3C XML Schema's
* identity constraints, it is the union of all the constructs in these
* languages. However, when dealing with each language individually, we
* regularly need to disallow some expressions, such as direct element
* constructors when parsing XSL-T, or the typeswitch when parsing XPath.
*
* This is further complicated by that XSLTTokenizer sometimes generates code
* which is allowed in XQuery but not in XPath. For that reason the token
* INTERNAL is sometimes generated, which signals that an expression, for
* instance the @c let clause, should not be flagged as an error, because it's
* used for internal purposes.
*
* Hence, this function is called from each expression and declaration with @p
* allowedLanguages stating what languages it is allowed in.
*
* If @p isInternal is @c true, no error is raised. Otherwise, if the current
* language is not in @p allowedLanguages, an error is raised.
*/
static void allowedIn(const QueryLanguages allowedLanguages,
const ParserContext *const parseInfo,
const YYLTYPE &sourceLocator,
const bool isInternal = false)
{
/* We treat XPath 2.0 as a subset of XSL-T 2.0, so if XPath 2.0 is allowed
* and XSL-T is the language, it's ok. */
if(!isInternal &&
(!allowedLanguages.testFlag(parseInfo->languageAccent) && !(allowedLanguages.testFlag(QXmlQuery::XPath20) && parseInfo->languageAccent == QXmlQuery::XSLT20)))
{
QString langName;
switch(parseInfo->languageAccent)
{
case QXmlQuery::XPath20:
langName = QLatin1String("XPath 2.0");
break;
case QXmlQuery::XSLT20:
langName = QLatin1String("XSL-T 2.0");
break;
case QXmlQuery::XQuery10:
langName = QLatin1String("XQuery 1.0");
break;
case QXmlQuery::XmlSchema11IdentityConstraintSelector:
langName = QtXmlPatterns::tr("W3C XML Schema identity constraint selector");
break;
case QXmlQuery::XmlSchema11IdentityConstraintField:
langName = QtXmlPatterns::tr("W3C XML Schema identity constraint field");
break;
}
parseInfo->staticContext->error(QtXmlPatterns::tr("A construct was encountered "
"which is disallowed in the current language(%1).").arg(langName),
ReportContext::XPST0003,
fromYYLTYPE(sourceLocator, parseInfo));
}
}
static inline bool isVariableReference(const Expression::ID id)
{
return id == Expression::IDExpressionVariableReference
|| id == Expression::IDRangeVariableReference
|| id == Expression::IDArgumentReference;
}
class ReflectYYLTYPE : public SourceLocationReflection
{
public:
inline ReflectYYLTYPE(const YYLTYPE &sourceLocator,
const ParserContext *const pi) : m_sl(sourceLocator)
, m_parseInfo(pi)
{
}
virtual const SourceLocationReflection *actualReflection() const
{
return this;
}
virtual QSourceLocation sourceLocation() const
{
return fromYYLTYPE(m_sl, m_parseInfo);
}
virtual QString description() const
{
Q_ASSERT(false);
return QString();
}
private:
const YYLTYPE &m_sl;
const ParserContext *const m_parseInfo;
};
/**
* @short Centralizes a translation string for the purpose of increasing consistency.
*/
static inline QString unknownType()
{
return QtXmlPatterns::tr("%1 is an unknown schema type.");
}
static inline Expression::Ptr create(Expression *const expr,
const YYLTYPE &sourceLocator,
const ParserContext *const parseInfo)
{
parseInfo->staticContext->addLocation(expr, fromYYLTYPE(sourceLocator, parseInfo));
return Expression::Ptr(expr);
}
static inline Template::Ptr create(Template *const expr,
const YYLTYPE &sourceLocator,
const ParserContext *const parseInfo)
{
parseInfo->staticContext->addLocation(expr, fromYYLTYPE(sourceLocator, parseInfo));
return Template::Ptr(expr);
}
static inline Expression::Ptr create(const Expression::Ptr &expr,
const YYLTYPE &sourceLocator,
const ParserContext *const parseInfo)
{
parseInfo->staticContext->addLocation(expr.data(), fromYYLTYPE(sourceLocator, parseInfo));
return expr;
}
static Expression::Ptr createSimpleContent(const Expression::Ptr &source,
const YYLTYPE &sourceLocator,
const ParserContext *const parseInfo)
{
return create(parseInfo->isXSLT() ? new XSLTSimpleContentConstructor(source) : new SimpleContentConstructor(source),
sourceLocator,
parseInfo);
}
static void loadPattern(const Expression::Ptr &matchPattern,
TemplatePattern::Vector &ourPatterns,
const TemplatePattern::ID id,
const PatternPriority priority,
const Template::Ptr &temp)
{
Q_ASSERT(temp);
const PatternPriority effectivePriority = qIsNaN(priority) ? matchPattern->patternPriority() : priority;
ourPatterns.append(TemplatePattern::Ptr(new TemplatePattern(matchPattern, effectivePriority, id, temp)));
}
static Expression::Ptr typeCheckTemplateBody(const Expression::Ptr &body,
const SequenceType::Ptr &reqType,
const ParserContext *const parseInfo)
{
return TypeChecker::applyFunctionConversion(body, reqType,
parseInfo->staticContext,
ReportContext::XTTE0505,
TypeChecker::Options(TypeChecker::AutomaticallyConvert | TypeChecker::GeneratePromotion));
}
static void registerNamedTemplate(const QXmlName &name,
const Expression::Ptr &body,
ParserContext *const parseInfo,
const YYLTYPE &sourceLocator,
const Template::Ptr &temp)
{
Template::Ptr &e = parseInfo->namedTemplates[name];
if(e)
{
parseInfo->staticContext->error(QtXmlPatterns::tr("A template with name %1 "
"has already been declared.")
.arg(formatKeyword(parseInfo->staticContext->namePool(),
name)),
ReportContext::XTSE0660,
fromYYLTYPE(sourceLocator, parseInfo));
}
else
{
e = temp;
e->body = body;
}
}
/**
* @short Centralizes code for creating numeric literals.
*/
template
Expression::Ptr createNumericLiteral(const QString &in,
const YYLTYPE &sl,
const ParserContext *const parseInfo)
{
const Item num(TNumberClass::fromLexical(in));
if(num.template as()->hasError())
{
parseInfo->staticContext->error(QtXmlPatterns::tr("%1 is not a valid numeric literal.")
.arg(formatData(in)),
ReportContext::XPST0003, fromYYLTYPE(sl, parseInfo));
return Expression::Ptr(); /* Avoid compiler warning. */
}
else
return create(new Literal(num), sl, parseInfo);
}
/**
* @short The generated Bison parser calls this function when there is a parse error.
*
* It is not called, nor should be, for logical errors(which the Bison not know about). For those,
* ReportContext::error() is called.
*/
static int XPatherror(YYLTYPE *sourceLocator, const ParserContext *const parseInfo, const char *const msg)
{
Q_UNUSED(sourceLocator);
Q_ASSERT(parseInfo);
parseInfo->staticContext->error(escape(QLatin1String(msg)), ReportContext::XPST0003, fromYYLTYPE(*sourceLocator, parseInfo));
return 1;
}
/**
* When we want to connect the OrderBy and ReturnOrderBy, it might be that we have other expressions, such
* as @c where and @c let inbetween. We need to continue through them. This function does that.
*/
static ReturnOrderBy *locateReturnClause(const Expression::Ptr &expr)
{
Q_ASSERT(expr);
const Expression::ID id = expr->id();
if(id == Expression::IDLetClause || id == Expression::IDIfThenClause || id == Expression::IDForClause)
return locateReturnClause(expr->operands()[1]);
else if(id == Expression::IDReturnOrderBy)
return expr->as();
else
return 0;
}
static inline bool isPredicate(const Expression::ID id)
{
return id == Expression::IDGenericPredicate ||
id == Expression::IDFirstItemPredicate;
}
/**
* Assumes expr is an AxisStep wrapped in some kind of predicates or paths. Filters
* through the predicates and returns the AxisStep.
*/
static Expression::Ptr findAxisStep(const Expression::Ptr &expr,
const bool throughStructures = true)
{
Q_ASSERT(expr);
if(!throughStructures)
return expr;
Expression *candidate = expr.data();
Expression::ID id = candidate->id();
while(isPredicate(id) || id == Expression::IDPath)
{
const Expression::List &children = candidate->operands();
if(children.isEmpty())
return Expression::Ptr();
else
{
candidate = children.first().data();
id = candidate->id();
}
}
if(id == Expression::IDEmptySequence)
return Expression::Ptr();
else
{
Q_ASSERT(candidate->is(Expression::IDAxisStep));
return Expression::Ptr(candidate);
}
}
static void changeToTopAxis(const Expression::Ptr &op)
{
/* This axis must have been written away by now. */
Q_ASSERT(op->as()->axis() != QXmlNodeModelIndex::AxisChild);
if(op->as()->axis() != QXmlNodeModelIndex::AxisSelf)
op->as()->setAxis(QXmlNodeModelIndex::AxisAttributeOrTop);
}
/**
* @short Writes @p operand1 and @p operand2, two operands in an XSL-T pattern,
* into an equivalent XPath expression.
*
* Essentially, the following rewrite is done:
*
*
* axis1::test1(a)/axis2::test2(b)
* =>
* child-or-top::test2(b)[parent::test1(a)]
*
*
* Section 5.5.3 The Meaning of a Pattern talks about rewrites that are applied to
* only the first step in a pattern, but since we're doing rewrites more radically,
* its line of reasoning cannot be followed.
*
* Keep in mind the rewrites that non-terminal PatternStep do.
*
* @see createIdPatternPath()
*/
static inline Expression::Ptr createPatternPath(const Expression::Ptr &operand1,
const Expression::Ptr &operand2,
const QXmlNodeModelIndex::Axis axis,
const YYLTYPE &sl,
const ParserContext *const parseInfo)
{
const Expression::Ptr operandL(findAxisStep(operand1, false));
if(operandL->is(Expression::IDAxisStep))
operandL->as()->setAxis(axis);
else
findAxisStep(operand1)->as()->setAxis(axis);
return create(GenericPredicate::create(operand2, operandL,
parseInfo->staticContext, fromYYLTYPE(sl, parseInfo)), sl, parseInfo);
}
/**
* @short Performs the same role as createPatternPath(), but is tailored
* for @c fn:key() and @c fn:id().
*
* @c fn:key() and @c fn:id() can be part of path patterns(only as the first step,
* to be precise) and that poses a challenge to rewriting because what
* createPatternPath() is not possible to express, since the functions cannot be
* node tests. E.g, this rewrite is not possible:
*
*
* id-or-key/abc
* =>
* child-or-top::abc[parent::id-or-key]
*
*
* Our approach is to rewrite like this:
*
*
* id-or-key/abc
* =>
* child-or-top::abc[parent::node is id-or-key]
*
*
* @p operand1 is the call to @c fn:key() or @c fn:id(), @p operand2
* the right operand, and @p axis the target axis to rewrite to.
*
* @see createPatternPath()
*/
static inline Expression::Ptr createIdPatternPath(const Expression::Ptr &operand1,
const Expression::Ptr &operand2,
const QXmlNodeModelIndex::Axis axis,
const YYLTYPE &sl,
const ParserContext *const parseInfo)
{
const Expression::Ptr operandR(findAxisStep(operand2));
Q_ASSERT(operandR);
changeToTopAxis(operandR);
const Expression::Ptr parentStep(create(new AxisStep(axis, BuiltinTypes::node),
sl,
parseInfo));
const Expression::Ptr isComp(create(new NodeComparison(parentStep,
QXmlNodeModelIndex::Is,
operand1),
sl,
parseInfo));
return create(GenericPredicate::create(operandR, isComp,
parseInfo->staticContext, fromYYLTYPE(sl, parseInfo)), sl, parseInfo);
}
/**
* @short Centralizes a translation message, for the
* purpose of consistency and modularization.
*/
static inline QString prologMessage(const char *const msg)
{
Q_ASSERT(msg);
return QtXmlPatterns::tr("Only one %1 declaration can occur in the query prolog.").arg(formatKeyword(msg));
}
/**
* @short Resolves against the static base URI and checks that @p collation
* is a supported Unicode Collation.
*
* "If a default collation declaration specifies a collation by a
* relative URI, that relative URI is resolved to an absolute
* URI using the base URI in the static context."
*
* @returns the Unicode Collation properly resolved, if @p collation is a valid collation
*/
template
static QUrl resolveAndCheckCollation(const QString &collation,
const ParserContext *const parseInfo,
const YYLTYPE &sl)
{
Q_ASSERT(parseInfo);
const ReflectYYLTYPE ryy(sl, parseInfo);
QUrl uri(AnyURI::toQUrl(collation, parseInfo->staticContext, &ryy));
if(uri.isRelative())
uri = parseInfo->staticContext->baseURI().resolved(uri);
XPathHelper::checkCollationSupport(uri.toString(), parseInfo->staticContext, &ryy);
return uri;
}
/* The Bison generated parser declares macros that aren't used
* so suppress the warnings by fake usage of them.
*
* We do the same for some more defines in the first action. */
#if defined(YYLSP_NEEDED) \
|| defined(YYBISON) \
|| defined(YYBISON_VERSION) \
|| defined(YYPURE) \
|| defined(yydebug) \
|| defined(YYSKELETON_NAME)
#endif
/**
* Wraps @p operand with a CopyOf in case it makes any difference.
*
* There is no need to wrap the return value in a call to create(), it's
* already done.
*/
static Expression::Ptr createCopyOf(const Expression::Ptr &operand,
const ParserContext *const parseInfo,
const YYLTYPE &sl)
{
return create(new CopyOf(operand, parseInfo->inheritNamespacesMode,
parseInfo->preserveNamespacesMode), sl, parseInfo);
}
static Expression::Ptr createCompatStore(const Expression::Ptr &expr,
const YYLTYPE &sourceLocator,
const ParserContext *const parseInfo)
{
return create(new StaticCompatibilityStore(expr), sourceLocator, parseInfo);
}
/**
* @short Creates an Expression that corresponds to /. This is literally
* fn:root(self::node()) treat as document-node().
*/
static Expression::Ptr createRootExpression(const ParserContext *const parseInfo,
const YYLTYPE &sl)
{
Q_ASSERT(parseInfo);
const QXmlName name(StandardNamespaces::fn, StandardLocalNames::root);
Expression::List args;
args.append(create(new ContextItem(), sl, parseInfo));
const ReflectYYLTYPE ryy(sl, parseInfo);
const Expression::Ptr fnRoot(parseInfo->staticContext->functionSignatures()
->createFunctionCall(name, args, parseInfo->staticContext, &ryy));
Q_ASSERT(fnRoot);
return create(new TreatAs(create(fnRoot, sl, parseInfo), CommonSequenceTypes::ExactlyOneDocumentNode), sl, parseInfo);
}
static int XPathlex(YYSTYPE *lexVal, YYLTYPE *sourceLocator, const ParserContext *const parseInfo)
{
#ifdef Patternist_DEBUG_PARSER
/**
* "External integer variable set to zero by default. If yydebug
* is given a nonzero value, the parser will output information on
* input symbols and parser action. See section Debugging Your Parser."
*/
# define YYDEBUG 1
extern int XPathdebug;
XPathdebug = 1;
#endif
Q_ASSERT(parseInfo);
const Tokenizer::Token tok(parseInfo->tokenizer->nextToken(sourceLocator));
(*lexVal).sval = tok.value;
return static_cast(tok.type);
}
/**
* @short Creates a path expression which contains the step // between
* @p begin and and @p end.
*
* begin//end is a short form for: begin/descendant-or-self::node()/end
*
* This will be compiled as two-path expression: (/)/(//.)/step/
*/
static Expression::Ptr createSlashSlashPath(const Expression::Ptr &begin,
const Expression::Ptr &end,
const YYLTYPE &sourceLocator,
const ParserContext *const parseInfo)
{
const Expression::Ptr twoSlash(create(new AxisStep(QXmlNodeModelIndex::AxisDescendantOrSelf, BuiltinTypes::node), sourceLocator, parseInfo));
const Expression::Ptr p1(create(new Path(begin, twoSlash), sourceLocator, parseInfo));
return create(new Path(p1, end), sourceLocator, parseInfo);
}
/**
* @short Creates a call to fn:concat() with @p args as the arguments.
*/
static inline Expression::Ptr createConcatFN(const ParserContext *const parseInfo,
const Expression::List &args,
const YYLTYPE &sourceLocator)
{
Q_ASSERT(parseInfo);
const QXmlName name(StandardNamespaces::fn, StandardLocalNames::concat);
const ReflectYYLTYPE ryy(sourceLocator, parseInfo);
return create(parseInfo->staticContext->functionSignatures()->createFunctionCall(name, args, parseInfo->staticContext, &ryy),
sourceLocator, parseInfo);
}
static inline Expression::Ptr createDirAttributeValue(const Expression::List &content,
const ParserContext *const parseInfo,
const YYLTYPE &sourceLocator)
{
if(content.isEmpty())
return create(new EmptySequence(), sourceLocator, parseInfo);
else if(content.size() == 1)
return content.first();
else
return createConcatFN(parseInfo, content, sourceLocator);
}
/**
* @short Checks for variable initialization circularity.
*
* "A recursive function that checks for recursion is full of ironies."
*
* -- The Salsa Master
*
* Issues an error via @p parseInfo's StaticContext if the initialization
* expression @p checkee for the global variable @p var, contains a variable
* reference to @p var. That is, if there's a circularity.
*
* @see XQuery 1.0: An XML
* Query Language, err:XQST0054
*/
static void checkVariableCircularity(const VariableDeclaration::Ptr &var,
const Expression::Ptr &checkee,
const VariableDeclaration::Type type,
FunctionSignature::List &signList,
const ParserContext *const parseInfo)
{
Q_ASSERT(var);
Q_ASSERT(checkee);
Q_ASSERT(parseInfo);
const Expression::ID id = checkee->id();
if(id == Expression::IDExpressionVariableReference)
{
const ExpressionVariableReference *const ref =
static_cast(checkee.data());
if(var->slot == ref->slot() && type == ref->variableDeclaration()->type)
{
parseInfo->staticContext->error(QtXmlPatterns::tr("The initialization of variable %1 "
"depends on itself").arg(formatKeyword(var, parseInfo->staticContext->namePool())),
parseInfo->isXSLT() ? ReportContext::XTDE0640 : ReportContext::XQST0054, ref);
return;
}
else
{
/* If the variable we're checking is below another variable, it can be a recursive
* dependency through functions, so we need to check variable references too. */
checkVariableCircularity(var, ref->sourceExpression(), type, signList, parseInfo);
return;
}
}
else if(id == Expression::IDUserFunctionCallsite)
{
const UserFunctionCallsite::Ptr callsite(checkee);
const FunctionSignature::Ptr sign(callsite->callTargetDescription());
const FunctionSignature::List::const_iterator end(signList.constEnd());
FunctionSignature::List::const_iterator it(signList.constBegin());
bool noMatch = true;
for(; it != end; ++it)
{
if(*it == sign)
{
/* The variable we're checking is depending on a function that's recursive. The
* user has written a weird query, in other words. Since it's the second time
* we've encountered a callsite, we now skip it. */
noMatch = false;
break;
}
}
if(noMatch)
{
signList.append(sign);
/* Check the body of the function being called. */
checkVariableCircularity(var, callsite->body(), type, signList, parseInfo);
}
/* Continue with the operands, such that we also check the arguments of the callsite. */
}
else if(id == Expression::IDUnresolvedVariableReference)
{
/* We're called before it has rewritten itself. */
checkVariableCircularity(var, checkee->as()->replacement(), type, signList, parseInfo);
}
/* Check the operands. */
const Expression::List ops(checkee->operands());
if(ops.isEmpty())
return;
const Expression::List::const_iterator end(ops.constEnd());
Expression::List::const_iterator it(ops.constBegin());
for(; it != end; ++it)
checkVariableCircularity(var, *it, type, signList, parseInfo);
}
static void variableUnavailable(const QXmlName &variableName,
const ParserContext *const parseInfo,
const YYLTYPE &location)
{
parseInfo->staticContext->error(QtXmlPatterns::tr("No variable with name %1 exists")
.arg(formatKeyword(parseInfo->staticContext->namePool(), variableName)),
ReportContext::XPST0008, fromYYLTYPE(location, parseInfo));
}
/**
* The Cardinality in a TypeDeclaration for a variable in a quantification has no effect,
* and this function ensures this by changing @p type to Cardinality Cardinality::zeroOrMore().
*
* @see Bugzilla Bug 3305
* Cardinality + on range variables
* @see ParserContext::finalizePushedVariable()
*/
static inline SequenceType::Ptr quantificationType(const SequenceType::Ptr &type)
{
Q_ASSERT(type);
return makeGenericSequenceType(type->itemType(), Cardinality::zeroOrMore());
}
/**
* @p seqType and @p expr may be @c null.
*/
static Expression::Ptr pushVariable(const QXmlName name,
const SequenceType::Ptr &seqType,
const Expression::Ptr &expr,
const VariableDeclaration::Type type,
const YYLTYPE &sourceLocator,
ParserContext *const parseInfo,
const bool checkSource = true)
{
Q_ASSERT(!name.isNull());
Q_ASSERT(parseInfo);
/* -2 will cause Q_ASSERTs to trigger if it isn't changed. */
VariableSlotID slot = -2;
switch(type)
{
case VariableDeclaration::FunctionArgument:
/* Fallthrough. */
case VariableDeclaration::ExpressionVariable:
{
slot = parseInfo->allocateExpressionSlot();
break;
}
case VariableDeclaration::GlobalVariable:
{
slot = parseInfo->allocateGlobalVariableSlot();
break;
}
case VariableDeclaration::RangeVariable:
{
slot = parseInfo->staticContext->allocateRangeSlot();
break;
}
case VariableDeclaration::PositionalVariable:
{
slot = parseInfo->allocatePositionalSlot();
break;
}
case VariableDeclaration::TemplateParameter:
/* Fallthrough. We do nothing, template parameters
* doesn't use context slots at all, they're hashed
* on the name. */
case VariableDeclaration::ExternalVariable:
/* We do nothing, external variables doesn't use
*context slots/stack frames at all. */
;
}
const VariableDeclaration::Ptr var(new VariableDeclaration(name, slot, type, seqType));
Expression::Ptr checked;
if(checkSource && seqType)
{
if(expr)
{
/* We only want to add conversion for function arguments, and variables
* if we're XSL-T.
*
* We unconditionally skip TypeChecker::CheckFocus because the StaticContext we
* pass hasn't set up the focus yet, since that's the parent's responsibility. */
const TypeChecker::Options options(( type == VariableDeclaration::FunctionArgument
|| type == VariableDeclaration::TemplateParameter
|| parseInfo->isXSLT())
? TypeChecker::AutomaticallyConvert : TypeChecker::Options());
checked = TypeChecker::applyFunctionConversion(expr, seqType, parseInfo->staticContext,
parseInfo->isXSLT() ? ReportContext::XTTE0570 : ReportContext::XPTY0004,
options);
}
}
else
checked = expr;
/* Add an evaluation cache for all expression variables. No EvaluationCache is needed for
* positional variables because in the end they are calls to Iterator::position(). Similarly,
* no need to cache range variables either because they are calls to DynamicContext::rangeVariable().
*
* We don't do it for function arguments because the Expression being cached depends -- it depends
* on the callsite. UserFunctionCallsite is responsible for the evaluation caches in that case.
*
* In some cases the EvaluationCache instance isn't necessary, but in those cases EvaluationCache
* optimizes itself away. */
if(type == VariableDeclaration::ExpressionVariable)
checked = create(new EvaluationCache(checked, var, parseInfo->allocateCacheSlot()), sourceLocator, parseInfo);
else if(type == VariableDeclaration::GlobalVariable)
checked = create(new EvaluationCache(checked, var, parseInfo->allocateCacheSlot()), sourceLocator, parseInfo);
var->setExpression(checked);
parseInfo->variables.push(var);
return checked;
}
static inline VariableDeclaration::Ptr variableByName(const QXmlName name,
const ParserContext *const parseInfo)
{
Q_ASSERT(!name.isNull());
Q_ASSERT(parseInfo);
/* We walk the list backwards. */
const VariableDeclaration::Stack::const_iterator start(parseInfo->variables.constBegin());
VariableDeclaration::Stack::const_iterator it(parseInfo->variables.constEnd());
while(it != start)
{
--it;
Q_ASSERT(*it);
if((*it)->name == name)
return *it;
}
return VariableDeclaration::Ptr();
}
static Expression::Ptr resolveVariable(const QXmlName &name,
const YYLTYPE &sourceLocator,
ParserContext *const parseInfo,
const bool raiseErrorOnUnavailability)
{
const VariableDeclaration::Ptr var(variableByName(name, parseInfo));
Expression::Ptr retval;
if(var && var->type != VariableDeclaration::ExternalVariable)
{
switch(var->type)
{
case VariableDeclaration::RangeVariable:
{
retval = create(new RangeVariableReference(var->expression(), var->slot), sourceLocator, parseInfo);
break;
}
case VariableDeclaration::GlobalVariable:
/* Fallthrough. From the perspective of an ExpressionVariableReference, it can't tell
* a difference between a global and a local expression variable. However, the cache
* mechanism must. */
case VariableDeclaration::ExpressionVariable:
{
retval = create(new ExpressionVariableReference(var->slot, var), sourceLocator, parseInfo);
break;
}
case VariableDeclaration::FunctionArgument:
{
retval = create(new ArgumentReference(var->sequenceType, var->slot), sourceLocator, parseInfo);
break;
}
case VariableDeclaration::PositionalVariable:
{
retval = create(new PositionalVariableReference(var->slot), sourceLocator, parseInfo);
break;
}
case VariableDeclaration::TemplateParameter:
{
retval = create(new TemplateParameterReference(var), sourceLocator, parseInfo);
break;
}
case VariableDeclaration::ExternalVariable:
/* This code path will never be hit, but the case
* label silences a warning. See above. */
;
}
Q_ASSERT(retval);
var->references.append(retval);
}
else
{
/* Let's see if your external variable loader can provide us with one. */
const SequenceType::Ptr varType(parseInfo->staticContext->
externalVariableLoader()->announceExternalVariable(name, CommonSequenceTypes::ZeroOrMoreItems));
if(varType)
{
const Expression::Ptr extRef(create(new ExternalVariableReference(name, varType), sourceLocator, parseInfo));
const Expression::Ptr checked(TypeChecker::applyFunctionConversion(extRef, varType, parseInfo->staticContext));
retval = checked;
}
else if(!raiseErrorOnUnavailability && parseInfo->isXSLT())
{
/* In XSL-T, global variables are in scope for the whole
* stylesheet, so we must resolve this first at the end. */
retval = create(new UnresolvedVariableReference(name), sourceLocator, parseInfo);
parseInfo->unresolvedVariableReferences.insert(name, retval);
}
else
variableUnavailable(name, parseInfo, sourceLocator);
}
return retval;
}
static Expression::Ptr createReturnOrderBy(const OrderSpecTransfer::List &orderSpecTransfer,
const Expression::Ptr &returnExpr,
const OrderBy::Stability stability,
const YYLTYPE &sourceLocator,
const ParserContext *const parseInfo)
{
// TODO do resize(orderSpec.size() + 1)
Expression::List exprs;
OrderBy::OrderSpec::Vector orderSpecs;
exprs.append(returnExpr);
const int len = orderSpecTransfer.size();
for(int i = 0; i < len; ++i)
{
exprs.append(orderSpecTransfer.at(i).expression);
orderSpecs.append(orderSpecTransfer.at(i).orderSpec);
}
return create(new ReturnOrderBy(stability, orderSpecs, exprs), sourceLocator, parseInfo);
}
#line 1123 "qquerytransformparser.cpp" /* yacc.c:339 */
# ifndef YY_NULLPTR
# if defined __cplusplus && 201103L <= __cplusplus
# define YY_NULLPTR nullptr
# else
# define YY_NULLPTR 0
# endif
# endif
/* Enabling verbose error messages. */
#ifdef YYERROR_VERBOSE
# undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1
#else
# define YYERROR_VERBOSE 1
#endif
/* In a future release of Bison, this section will be replaced
by #include "qquerytransformparser_p.h". */
#ifndef YY_XPATH_QQUERYTRANSFORMPARSER_P_H_INCLUDED
# define YY_XPATH_QQUERYTRANSFORMPARSER_P_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int XPathdebug;
#endif
/* Token type. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
T_END_OF_FILE = 0,
T_STRING_LITERAL = 258,
T_NON_BOUNDARY_WS = 259,
T_XPATH2_STRING_LITERAL = 260,
T_QNAME = 261,
T_NCNAME = 262,
T_CLARK_NAME = 263,
T_ANY_LOCAL_NAME = 264,
T_ANY_PREFIX = 265,
T_NUMBER = 266,
T_XPATH2_NUMBER = 267,
T_ANCESTOR = 268,
T_ANCESTOR_OR_SELF = 269,
T_AND = 270,
T_APOS = 271,
T_APPLY_TEMPLATE = 272,
T_AS = 273,
T_ASCENDING = 274,
T_ASSIGN = 275,
T_AT = 276,
T_AT_SIGN = 277,
T_ATTRIBUTE = 278,
T_AVT = 279,
T_BAR = 280,
T_BASEURI = 281,
T_BEGIN_END_TAG = 282,
T_BOUNDARY_SPACE = 283,
T_BY = 284,
T_CALL_TEMPLATE = 285,
T_CASE = 286,
T_CASTABLE = 287,
T_CAST = 288,
T_CHILD = 289,
T_COLLATION = 290,
T_COLONCOLON = 291,
T_COMMA = 292,
T_COMMENT = 293,
T_COMMENT_START = 294,
T_CONSTRUCTION = 295,
T_COPY_NAMESPACES = 296,
T_CURLY_LBRACE = 297,
T_CURLY_RBRACE = 298,
T_DECLARE = 299,
T_DEFAULT = 300,
T_DESCENDANT = 301,
T_DESCENDANT_OR_SELF = 302,
T_DESCENDING = 303,
T_DIV = 304,
T_DOCUMENT = 305,
T_DOCUMENT_NODE = 306,
T_DOLLAR = 307,
T_DOT = 308,
T_DOTDOT = 309,
T_ELEMENT = 310,
T_ELSE = 311,
T_EMPTY = 312,
T_EMPTY_SEQUENCE = 313,
T_ENCODING = 314,
T_END_SORT = 315,
T_EQ = 316,
T_ERROR = 317,
T_EVERY = 318,
T_EXCEPT = 319,
T_EXTERNAL = 320,
T_FOLLOWING = 321,
T_FOLLOWING_SIBLING = 322,
T_FOLLOWS = 323,
T_FOR_APPLY_TEMPLATE = 324,
T_FOR = 325,
T_FUNCTION = 326,
T_GE = 327,
T_G_EQ = 328,
T_G_GE = 329,
T_G_GT = 330,
T_G_LE = 331,
T_G_LT = 332,
T_G_NE = 333,
T_GREATEST = 334,
T_GT = 335,
T_IDIV = 336,
T_IF = 337,
T_IMPORT = 338,
T_INHERIT = 339,
T_IN = 340,
T_INSTANCE = 341,
T_INTERSECT = 342,
T_IS = 343,
T_ITEM = 344,
T_LAX = 345,
T_LBRACKET = 346,
T_LEAST = 347,
T_LE = 348,
T_LET = 349,
T_LPAREN = 350,
T_LT = 351,
T_MAP = 352,
T_MATCHES = 353,
T_MINUS = 354,
T_MODE = 355,
T_MOD = 356,
T_MODULE = 357,
T_NAME = 358,
T_NAMESPACE = 359,
T_NE = 360,
T_NODE = 361,
T_NO_INHERIT = 362,
T_NO_PRESERVE = 363,
T_OF = 364,
T_OPTION = 365,
T_ORDERED = 366,
T_ORDERING = 367,
T_ORDER = 368,
T_OR = 369,
T_PARENT = 370,
T_PI_START = 371,
T_PLUS = 372,
T_POSITION_SET = 373,
T_PRAGMA_END = 374,
T_PRAGMA_START = 375,
T_PRECEDES = 376,
T_PRECEDING = 377,
T_PRECEDING_SIBLING = 378,
T_PRESERVE = 379,
T_PRIORITY = 380,
T_PROCESSING_INSTRUCTION = 381,
T_QUESTION = 382,
T_QUICK_TAG_END = 383,
T_QUOTE = 384,
T_RBRACKET = 385,
T_RETURN = 386,
T_RPAREN = 387,
T_SATISFIES = 388,
T_SCHEMA_ATTRIBUTE = 389,
T_SCHEMA_ELEMENT = 390,
T_SCHEMA = 391,
T_SELF = 392,
T_SEMI_COLON = 393,
T_SLASH = 394,
T_SLASHSLASH = 395,
T_SOME = 396,
T_SORT = 397,
T_STABLE = 398,
T_STAR = 399,
T_STRICT = 400,
T_STRIP = 401,
T_SUCCESS = 402,
T_COMMENT_CONTENT = 403,
T_PI_CONTENT = 404,
T_PI_TARGET = 405,
T_XSLT_VERSION = 406,
T_TEMPLATE = 407,
T_TEXT = 408,
T_THEN = 409,
T_TO = 410,
T_TREAT = 411,
T_TUNNEL = 412,
T_TYPESWITCH = 413,
T_UNION = 414,
T_UNORDERED = 415,
T_VALIDATE = 416,
T_VARIABLE = 417,
T_VERSION = 418,
T_WHERE = 419,
T_XQUERY = 420,
T_INTERNAL = 421,
T_INTERNAL_NAME = 422,
T_CURRENT = 423
};
#endif
/* Value type. */
/* Location type. */
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
typedef struct YYLTYPE YYLTYPE;
struct YYLTYPE
{
int first_line;
int first_column;
int last_line;
int last_column;
};
# define YYLTYPE_IS_DECLARED 1
# define YYLTYPE_IS_TRIVIAL 1
#endif
int XPathparse (QT_PREPEND_NAMESPACE(QPatternist)::ParserContext *const parseInfo);
#endif /* !YY_XPATH_QQUERYTRANSFORMPARSER_P_H_INCLUDED */
/* Copy the second part of user declarations. */
#line 1352 "qquerytransformparser.cpp" /* yacc.c:358 */
#ifdef short
# undef short
#endif
#ifdef YYTYPE_UINT8
typedef YYTYPE_UINT8 yytype_uint8;
#else
typedef unsigned char yytype_uint8;
#endif
#ifdef YYTYPE_INT8
typedef YYTYPE_INT8 yytype_int8;
#else
typedef signed char yytype_int8;
#endif
#ifdef YYTYPE_UINT16
typedef YYTYPE_UINT16 yytype_uint16;
#else
typedef unsigned short int yytype_uint16;
#endif
#ifdef YYTYPE_INT16
typedef YYTYPE_INT16 yytype_int16;
#else
typedef short int yytype_int16;
#endif
#ifndef YYSIZE_T
# ifdef __SIZE_TYPE__
# define YYSIZE_T __SIZE_TYPE__
# elif defined size_t
# define YYSIZE_T size_t
# elif ! defined YYSIZE_T
# include /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# else
# define YYSIZE_T unsigned int
# endif
#endif
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
#ifndef YY_
# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# include /* INFRINGES ON USER NAME SPACE */
# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
# endif
# endif
# ifndef YY_
# define YY_(Msgid) Msgid
# endif
#endif
#ifndef YY_ATTRIBUTE
# if (defined __GNUC__ \
&& (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
|| defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
# define YY_ATTRIBUTE(Spec) __attribute__(Spec)
# else
# define YY_ATTRIBUTE(Spec) /* empty */
# endif
#endif
#ifndef YY_ATTRIBUTE_PURE
# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
#endif
#ifndef YY_ATTRIBUTE_UNUSED
# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
#endif
#if !defined _Noreturn \
&& (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
# if defined _MSC_VER && 1200 <= _MSC_VER
# define _Noreturn __declspec (noreturn)
# else
# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
# endif
#endif
/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(E) /* empty */
#endif
#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
#else
# define YY_INITIAL_VALUE(Value) Value
#endif
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
#endif
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif
#if ! defined yyoverflow || YYERROR_VERBOSE
/* The parser invokes alloca or malloc; define the necessary symbols. */
# ifdef YYSTACK_USE_ALLOCA
# if YYSTACK_USE_ALLOCA
# ifdef __GNUC__
# define YYSTACK_ALLOC __builtin_alloca
# elif defined __BUILTIN_VA_ARG_INCR
# include /* INFRINGES ON USER NAME SPACE */
# elif defined _AIX
# define YYSTACK_ALLOC __alloca
# elif defined _MSC_VER
# include /* INFRINGES ON USER NAME SPACE */
# define alloca _alloca
# else
# define YYSTACK_ALLOC alloca
# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
# include /* INFRINGES ON USER NAME SPACE */
/* Use EXIT_SUCCESS as a witness for stdlib.h. */
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# endif
# endif
# endif
# endif
# endif
# ifdef YYSTACK_ALLOC
/* Pacify GCC's 'empty if-body' warning. */
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
# ifndef YYSTACK_ALLOC_MAXIMUM
/* The OS might guarantee only one guard page at the bottom of the stack,
and a page size can be as small as 4096 bytes. So we cannot safely
invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
to allow for a few compiler-allocated temporary stack slots. */
# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
# endif
# else
# define YYSTACK_ALLOC YYMALLOC
# define YYSTACK_FREE YYFREE
# ifndef YYSTACK_ALLOC_MAXIMUM
# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
# endif
# if (defined __cplusplus && ! defined EXIT_SUCCESS \
&& ! ((defined YYMALLOC || defined malloc) \
&& (defined YYFREE || defined free)))
# include /* INFRINGES ON USER NAME SPACE */
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# endif
# endif
# ifndef YYMALLOC
# define YYMALLOC malloc
# if ! defined malloc && ! defined EXIT_SUCCESS
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# ifndef YYFREE
# define YYFREE free
# if ! defined free && ! defined EXIT_SUCCESS
void free (void *); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# endif
#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
#if (! defined yyoverflow \
&& (! defined __cplusplus \
|| (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
&& defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */
union yyalloc
{
yytype_int16 yyss_alloc;
YYSTYPE yyvs_alloc;
YYLTYPE yyls_alloc;
};
/* The size of the maximum gap between one aligned stack and the next. */
# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
/* The size of an array large to enough to hold all stacks, each with
N elements. */
# define YYSTACK_BYTES(N) \
((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
+ 2 * YYSTACK_GAP_MAXIMUM)
# define YYCOPY_NEEDED 1
/* Relocate STACK from its old location to the new one. The
local variables YYSIZE and YYSTACKSIZE give the old and new number of
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
Stack = &yyptr->Stack_alloc; \
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
while (0)
#endif
#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
/* Copy COUNT objects from SRC to DST. The source and destination do
not overlap. */
# ifndef YYCOPY
# if defined __GNUC__ && 1 < __GNUC__
# define YYCOPY(Dst, Src, Count) \
__builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
# else
# define YYCOPY(Dst, Src, Count) \
do \
{ \
YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
(Dst)[yyi] = (Src)[yyi]; \
} \
while (0)
# endif
# endif
#endif /* !YYCOPY_NEEDED */
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 5
/* YYLAST -- Last index in YYTABLE. */
#define YYLAST 2052
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 169
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 237
/* YYNRULES -- Number of rules. */
#define YYNRULES 472
/* YYNSTATES -- Number of states. */
#define YYNSTATES 812
/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
by yylex, with out-of-bounds checking. */
#define YYUNDEFTOK 2
#define YYMAXUTOK 423
#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
as returned by yylex, without out-of-bounds checking. */
static const yytype_uint8 yytranslate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
165, 166, 167, 168
};
#if YYDEBUG
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
0, 1420, 1420, 1421, 1423, 1424, 1455, 1456, 1472, 1570,
1572, 1578, 1580, 1587, 1593, 1599, 1606, 1609, 1613, 1617,
1637, 1651, 1655, 1649, 1718, 1722, 1739, 1742, 1744, 1749,
1750, 1754, 1755, 1759, 1763, 1767, 1769, 1770, 1772, 1774,
1820, 1834, 1839, 1844, 1845, 1847, 1862, 1877, 1887, 1902,
1906, 1911, 1925, 1929, 1934, 1948, 1953, 1958, 1963, 1968,
1984, 2007, 2015, 2016, 2017, 2019, 2036, 2037, 2039, 2040,
2042, 2043, 2045, 2100, 2104, 2110, 2113, 2118, 2132, 2136,
2142, 2141, 2250, 2253, 2259, 2280, 2286, 2290, 2292, 2297,
2307, 2308, 2313, 2314, 2323, 2393, 2404, 2405, 2409, 2414,
2483, 2484, 2488, 2493, 2537, 2538, 2543, 2550, 2556, 2557,
2558, 2559, 2560, 2561, 2567, 2572, 2578, 2581, 2586, 2592,
2598, 2602, 2627, 2628, 2632, 2636, 2630, 2677, 2680, 2675,
2696, 2697, 2698, 2701, 2705, 2713, 2712, 2726, 2725, 2734,
2735, 2736, 2738, 2746, 2757, 2760, 2762, 2767, 2774, 2781,
2787, 2807, 2812, 2818, 2821, 2823, 2824, 2831, 2837, 2841,
2846, 2847, 2850, 2854, 2849, 2864, 2868, 2863, 2876, 2879,
2883, 2878, 2893, 2897, 2892, 2905, 2907, 2935, 2934, 2946,
2954, 2945, 2965, 2966, 2969, 2973, 2978, 2983, 2982, 2998,
3004, 3005, 3011, 3012, 3018, 3019, 3020, 3021, 3023, 3024,
3030, 3031, 3037, 3038, 3040, 3041, 3047, 3048, 3049, 3050,
3052, 3053, 3063, 3064, 3070, 3071, 3073, 3077, 3082, 3083,
3090, 3091, 3097, 3098, 3104, 3105, 3111, 3112, 3118, 3122,
3127, 3128, 3129, 3131, 3137, 3138, 3139, 3140, 3141, 3142,
3144, 3149, 3150, 3151, 3152, 3153, 3154, 3156, 3161, 3162,
3163, 3165, 3179, 3180, 3181, 3183, 3200, 3204, 3209, 3210,
3212, 3217, 3218, 3220, 3226, 3230, 3236, 3239, 3240, 3244,
3253, 3258, 3262, 3263, 3268, 3267, 3282, 3290, 3289, 3305,
3313, 3313, 3322, 3324, 3327, 3332, 3334, 3338, 3404, 3407,
3413, 3416, 3425, 3429, 3433, 3438, 3439, 3444, 3445, 3448,
3447, 3477, 3479, 3480, 3482, 3526, 3527, 3528, 3529, 3530,
3531, 3532, 3533, 3534, 3535, 3536, 3537, 3540, 3539, 3550,
3561, 3566, 3568, 3573, 3574, 3579, 3583, 3585, 3589, 3598,
3605, 3606, 3612, 3613, 3614, 3615, 3616, 3617, 3618, 3619,
3629, 3630, 3635, 3640, 3646, 3652, 3657, 3662, 3667, 3673,
3678, 3683, 3713, 3717, 3724, 3726, 3730, 3735, 3736, 3737,
3771, 3780, 3769, 4021, 4025, 4045, 4048, 4054, 4059, 4064,
4070, 4073, 4083, 4090, 4094, 4100, 4114, 4120, 4137, 4142,
4155, 4156, 4157, 4158, 4159, 4160, 4161, 4163, 4171, 4170,
4210, 4213, 4218, 4233, 4238, 4245, 4257, 4261, 4257, 4267,
4269, 4273, 4275, 4290, 4294, 4303, 4308, 4312, 4318, 4321,
4326, 4331, 4336, 4337, 4338, 4339, 4341, 4342, 4343, 4344,
4349, 4385, 4386, 4387, 4388, 4389, 4390, 4391, 4393, 4398,
4403, 4409, 4410, 4412, 4417, 4422, 4427, 4432, 4448, 4449,
4451, 4456, 4461, 4465, 4477, 4490, 4500, 4505, 4510, 4515,
4529, 4543, 4544, 4546, 4556, 4558, 4563, 4570, 4577, 4579,
4581, 4582, 4584, 4588, 4593, 4594, 4596, 4602, 4604, 4606,
4610, 4615, 4627
};
#endif
#if YYDEBUG || YYERROR_VERBOSE || 1
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
{
"\"end of file\"", "error", "$undefined", "\"\"",
"\"\"", "\"\"",
"\"QName\"", "\"NCName\"", "\"ClarkName\"", "T_ANY_LOCAL_NAME",
"T_ANY_PREFIX", "\"\"",
"\"\"", "\"ancestor\"",
"\"ancestor-or-self\"", "\"and\"", "\"'\"", "\"apply-template\"",
"\"as\"", "\"ascending\"", "\":=\"", "\"at\"", "\"@\"", "\"attribute\"",
"T_AVT", "\"|\"", "\"base-uri\"", "\"\"", "\"boundary-space\"",
"\"by\"", "\"call-template\"", "\"case\"", "\"castable\"", "\"cast\"",
"\"child\"", "\"collation\"", "\"::\"", "\",\"", "\"comment\"",
"\"