Qt 4.8
qquerytransformparser.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 /* A Bison parser, made by GNU Bison 2.3a. */
43 
44 /* Skeleton implementation for Bison's Yacc-like parsers in C
45 
46  Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
47  Free Software Foundation, Inc.
48 
49  This program is free software; you can redistribute it and/or modify
50  it under the terms of the GNU General Public License as published by
51  the Free Software Foundation; either version 2, or (at your option)
52  any later version.
53 
54  This program is distributed in the hope that it will be useful,
55  but WITHOUT ANY WARRANTY; without even the implied warranty of
56  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57  GNU General Public License for more details.
58 
59  You should have received a copy of the GNU General Public License
60  along with this program; if not, write to the Free Software
61  Foundation, Inc., 51 Franklin Street, Fifth Floor,
62  Boston, MA 02110-1301, USA. */
63 
64 /* As a special exception, you may create a larger work that contains
65  part or all of the Bison parser skeleton and distribute that work
66  under terms of your choice, so long as that work isn't itself a
67  parser generator using the skeleton or a modified version thereof
68  as a parser skeleton. Alternatively, if you modify or redistribute
69  the parser skeleton itself, you may (at your option) remove this
70  special exception, which will cause the skeleton and the resulting
71  Bison output files to be licensed under the GNU General Public
72  License without this special exception.
73 
74  This special exception was added by the Free Software Foundation in
75  version 2.2 of Bison. */
76 
77 /* C LALR(1) parser skeleton written by Richard Stallman, by
78  simplifying the original so-called "semantic" parser. */
79 
80 /* All symbols defined below should begin with yy or YY, to avoid
81  infringing on user name space. This should be done even for local
82  variables, as they might otherwise be expanded by user macros.
83  There are some unavoidable exceptions within include files to
84  define necessary library symbols; they are noted "INFRINGES ON
85  USER NAME SPACE" below. */
86 
87 /* Identify Bison output. */
88 #define YYBISON 1
89 
90 /* Bison version. */
91 #define YYBISON_VERSION "2.3a"
92 
93 /* Skeleton name. */
94 #define YYSKELETON_NAME "yacc.c"
95 
96 /* Pure parsers. */
97 #define YYPURE 1
98 
99 /* Using locations. */
100 #define YYLSP_NEEDED 1
101 
102 /* Substitute the variable and function names. */
103 #define yyparse XPathparse
104 #define yylex XPathlex
105 #define yyerror XPatherror
106 #define yylval XPathlval
107 #define yychar XPathchar
108 #define yydebug XPathdebug
109 #define yynerrs XPathnerrs
110 #define yylloc XPathlloc
111 
112 /* Copy the first part of user declarations. */
113 /* Line 164 of yacc.c. */
114 #line 22 "querytransformparser.ypp"
115 
116 #include <limits>
117 
118 #include <QUrl>
119 
120 #include "qabstractfloat_p.h"
121 #include "qandexpression_p.h"
122 #include "qanyuri_p.h"
123 #include "qapplytemplate_p.h"
124 #include "qargumentreference_p.h"
125 #include "qarithmeticexpression_p.h"
126 #include "qatomicstring_p.h"
127 #include "qattributeconstructor_p.h"
129 #include "qaxisstep_p.h"
130 #include "qbuiltintypes_p.h"
131 #include "qcalltemplate_p.h"
132 #include "qcastableas_p.h"
133 #include "qcastas_p.h"
134 #include "qcombinenodes_p.h"
135 #include "qcommentconstructor_p.h"
136 #include "qcommonnamespaces_p.h"
137 #include "qcommonsequencetypes_p.h"
138 #include "qcommonvalues_p.h"
140 #include "qcontextitem_p.h"
141 #include "qcopyof_p.h"
142 #include "qcurrentitemstore_p.h"
143 #include "qdebug_p.h"
145 #include "qdocumentconstructor_p.h"
146 #include "qelementconstructor_p.h"
147 #include "qemptysequence_p.h"
148 #include "qemptysequencetype_p.h"
149 #include "qevaluationcache_p.h"
150 #include "qexpressionfactory_p.h"
151 #include "qexpressionsequence_p.h"
154 #include "qforclause_p.h"
155 #include "qfunctioncall_p.h"
156 #include "qfunctionfactory_p.h"
157 #include "qfunctionsignature_p.h"
158 #include "qgeneralcomparison_p.h"
159 #include "qgenericpredicate_p.h"
160 #include "qgenericsequencetype_p.h"
161 #include "qifthenclause_p.h"
162 #include "qinstanceof_p.h"
163 #include "qletclause_p.h"
164 #include "qliteral_p.h"
165 #include "qlocalnametest_p.h"
166 #include "qnamespaceconstructor_p.h"
167 #include "qnamespacenametest_p.h"
168 #include "qncnameconstructor_p.h"
169 #include "qnodecomparison_p.h"
170 #include "qnodesort_p.h"
171 #include "qorderby_p.h"
172 #include "qorexpression_p.h"
173 #include "qparsercontext_p.h"
174 #include "qpath_p.h"
175 #include "qpatternistlocale_p.h"
178 #include "qqnameconstructor_p.h"
179 #include "qqnametest_p.h"
180 #include "qqnamevalue_p.h"
181 #include "qquantifiedexpression_p.h"
182 #include "qrangeexpression_p.h"
184 #include "qreturnorderby_p.h"
185 #include "qschemanumeric_p.h"
186 #include "qschematypefactory_p.h"
188 #include "qstaticbaseuristore_p.h"
191 #include "qtemplate_p.h"
192 #include "qtextnodeconstructor_p.h"
193 #include "qtokenizer_p.h"
194 #include "qtreatas_p.h"
195 #include "qtypechecker_p.h"
196 #include "qunaryexpression_p.h"
198 #include "quserfunctioncallsite_p.h"
199 #include "qvaluecomparison_p.h"
200 #include "qxpathhelper_p.h"
202 
203 /*
204  * The cpp generated with bison 2.1 wants to
205  * redeclare the C-like prototypes of 'malloc' and 'free', so we avoid that.
206  */
207 #define YYMALLOC malloc
208 #define YYFREE free
209 
211 
212 /* Due to Qt's QT_BEGIN_NAMESPACE magic, we can't use `using namespace', for some
213  * undocumented reason. */
214 namespace QPatternist
215 {
216 
222 #define YYERROR_VERBOSE 1
223 
224 #undef YYLTYPE_IS_TRIVIAL
225 #define YYLTYPE_IS_TRIVIAL 0
226 
227 /* Suppresses `warning: "YYENABLE_NLS" is not defined`
228  * @c YYENABLE_NLS enables Bison internationalization, and we don't
229  * use that, so disable it. See the Bison Manual, section 4.5 Parser Internationalization.
230  */
231 #define YYENABLE_NLS 0
232 
233 static inline QSourceLocation fromYYLTYPE(const YYLTYPE &sourceLocator,
234  const ParserContext *const parseInfo)
235 {
236  return QSourceLocation(parseInfo->tokenizer->queryURI(),
237  sourceLocator.first_line,
238  sourceLocator.first_column);
239 }
240 
246 
270 static void allowedIn(const QueryLanguages allowedLanguages,
271  const ParserContext *const parseInfo,
272  const YYLTYPE &sourceLocator,
273  const bool isInternal = false)
274 {
275  /* We treat XPath 2.0 as a subset of XSL-T 2.0, so if XPath 2.0 is allowed
276  * and XSL-T is the language, it's ok. */
277  if(!isInternal &&
278  (!allowedLanguages.testFlag(parseInfo->languageAccent) && !(allowedLanguages.testFlag(QXmlQuery::XPath20) && parseInfo->languageAccent == QXmlQuery::XSLT20)))
279  {
280 
281  QString langName;
282 
283  switch(parseInfo->languageAccent)
284  {
285  case QXmlQuery::XPath20:
286  langName = QLatin1String("XPath 2.0");
287  break;
288  case QXmlQuery::XSLT20:
289  langName = QLatin1String("XSL-T 2.0");
290  break;
291  case QXmlQuery::XQuery10:
292  langName = QLatin1String("XQuery 1.0");
293  break;
295  langName = QtXmlPatterns::tr("W3C XML Schema identity constraint selector");
296  break;
298  langName = QtXmlPatterns::tr("W3C XML Schema identity constraint field");
299  break;
300  }
301 
302  parseInfo->staticContext->error(QtXmlPatterns::tr("A construct was encountered "
303  "which is disallowed in the current language(%1).").arg(langName),
305  fromYYLTYPE(sourceLocator, parseInfo));
306 
307  }
308 }
309 
310 static inline bool isVariableReference(const Expression::ID id)
311 {
315 }
316 
318 {
319 public:
320  inline ReflectYYLTYPE(const YYLTYPE &sourceLocator,
321  const ParserContext *const pi) : m_sl(sourceLocator)
322  , m_parseInfo(pi)
323  {
324  }
325 
327  {
328  return this;
329  }
330 
332  {
333  return fromYYLTYPE(m_sl, m_parseInfo);
334  }
335 
336  virtual QString description() const
337  {
338  Q_ASSERT(false);
339  return QString();
340  }
341 
342 private:
343  const YYLTYPE &m_sl;
345 };
346 
350 static inline QString unknownType()
351 {
352  return QtXmlPatterns::tr("%1 is an unknown schema type.");
353 }
354 
355 static inline Expression::Ptr create(Expression *const expr,
356  const YYLTYPE &sourceLocator,
357  const ParserContext *const parseInfo)
358 {
359  parseInfo->staticContext->addLocation(expr, fromYYLTYPE(sourceLocator, parseInfo));
360  return Expression::Ptr(expr);
361 }
362 
363 static inline Template::Ptr create(Template *const expr,
364  const YYLTYPE &sourceLocator,
365  const ParserContext *const parseInfo)
366 {
367  parseInfo->staticContext->addLocation(expr, fromYYLTYPE(sourceLocator, parseInfo));
368  return Template::Ptr(expr);
369 }
370 
371 static inline Expression::Ptr create(const Expression::Ptr &expr,
372  const YYLTYPE &sourceLocator,
373  const ParserContext *const parseInfo)
374 {
375  parseInfo->staticContext->addLocation(expr.data(), fromYYLTYPE(sourceLocator, parseInfo));
376  return expr;
377 }
378 
380  const YYLTYPE &sourceLocator,
381  const ParserContext *const parseInfo)
382 {
383  return create(parseInfo->isXSLT() ? new XSLTSimpleContentConstructor(source) : new SimpleContentConstructor(source),
384  sourceLocator,
385  parseInfo);
386 }
387 
388 static void loadPattern(const Expression::Ptr &matchPattern,
389  TemplatePattern::Vector &ourPatterns,
390  const TemplatePattern::ID id,
391  const PatternPriority priority,
392  const Template::Ptr &temp)
393 {
394  Q_ASSERT(temp);
395 
396  const PatternPriority effectivePriority = qIsNaN(priority) ? matchPattern->patternPriority() : priority;
397 
398  ourPatterns.append(TemplatePattern::Ptr(new TemplatePattern(matchPattern, effectivePriority, id, temp)));
399 }
400 
402  const SequenceType::Ptr &reqType,
403  const ParserContext *const parseInfo)
404 {
405  return TypeChecker::applyFunctionConversion(body, reqType,
406  parseInfo->staticContext,
409 }
410 
412  const Expression::Ptr &body,
413  ParserContext *const parseInfo,
414  const YYLTYPE &sourceLocator,
415  const Template::Ptr &temp)
416 {
417  Template::Ptr &e = parseInfo->namedTemplates[name];
418 
419  if(e)
420  {
421  parseInfo->staticContext->error(QtXmlPatterns::tr("A template with name %1 "
422  "has already been declared.")
423  .arg(formatKeyword(parseInfo->staticContext->namePool(),
424  name)),
426  fromYYLTYPE(sourceLocator, parseInfo));
427  }
428  else
429  {
430  e = temp;
431  e->body = body;
432  }
433 }
434 
438 template<typename TNumberClass>
440  const YYLTYPE &sl,
441  const ParserContext *const parseInfo)
442 {
443  const Item num(TNumberClass::fromLexical(in));
444 
445  if(num.template as<AtomicValue>()->hasError())
446  {
447  parseInfo->staticContext->error(QtXmlPatterns::tr("%1 is not a valid numeric literal.")
448  .arg(formatData(in)),
449  ReportContext::XPST0003, fromYYLTYPE(sl, parseInfo));
450  return Expression::Ptr(); /* Avoid compiler warning. */
451  }
452  else
453  return create(new Literal(num), sl, parseInfo);
454 }
455 
462 static int XPatherror(YYLTYPE *sourceLocator, const ParserContext *const parseInfo, const char *const msg)
463 {
464  Q_UNUSED(sourceLocator);
465  Q_ASSERT(parseInfo);
466 
467  parseInfo->staticContext->error(escape(QLatin1String(msg)), ReportContext::XPST0003, fromYYLTYPE(*sourceLocator, parseInfo));
468  return 1;
469 }
470 
476 {
477  Q_ASSERT(expr);
478 
479  const Expression::ID id = expr->id();
481  return locateReturnClause(expr->operands()[1]);
482  else if(id == Expression::IDReturnOrderBy)
483  return expr->as<ReturnOrderBy>();
484  else
485  return 0;
486 }
487 
488 static inline bool isPredicate(const Expression::ID id)
489 {
490  return id == Expression::IDGenericPredicate ||
492 }
493 
499  const bool throughStructures = true)
500 {
501  Q_ASSERT(expr);
502 
503  if(!throughStructures)
504  return expr;
505 
506  Expression *candidate = expr.data();
507  Expression::ID id = candidate->id();
508 
509  while(isPredicate(id) || id == Expression::IDPath)
510  {
511  const Expression::List &children = candidate->operands();
512  if(children.isEmpty())
513  return Expression::Ptr();
514  else
515  {
516  candidate = children.first().data();
517  id = candidate->id();
518  }
519  }
520 
522  return Expression::Ptr();
523  else
524  {
525  Q_ASSERT(candidate->is(Expression::IDAxisStep));
526  return Expression::Ptr(candidate);
527  }
528 }
529 
530 static void changeToTopAxis(const Expression::Ptr &op)
531 {
532  /* This axis must have been written away by now. */
534 
535  if(op->as<AxisStep>()->axis() != QXmlNodeModelIndex::AxisSelf)
537 }
538 
559 static inline Expression::Ptr createPatternPath(const Expression::Ptr &operand1,
560  const Expression::Ptr &operand2,
561  const QXmlNodeModelIndex::Axis axis,
562  const YYLTYPE &sl,
563  const ParserContext *const parseInfo)
564 {
565  const Expression::Ptr operandL(findAxisStep(operand1, false));
566 
567  if(operandL->is(Expression::IDAxisStep))
568  operandL->as<AxisStep>()->setAxis(axis);
569  else
570  findAxisStep(operand1)->as<AxisStep>()->setAxis(axis);
571 
572  return create(GenericPredicate::create(operand2, operandL,
573  parseInfo->staticContext, fromYYLTYPE(sl, parseInfo)), sl, parseInfo);
574 }
575 
605  const Expression::Ptr &operand2,
606  const QXmlNodeModelIndex::Axis axis,
607  const YYLTYPE &sl,
608  const ParserContext *const parseInfo)
609 {
610  const Expression::Ptr operandR(findAxisStep(operand2));
611  Q_ASSERT(operandR);
612  changeToTopAxis(operandR);
613 
614  const Expression::Ptr parentStep(create(new AxisStep(axis, BuiltinTypes::node),
615  sl,
616  parseInfo));
617  const Expression::Ptr isComp(create(new NodeComparison(parentStep,
619  operand1),
620  sl,
621  parseInfo));
622 
623  return create(GenericPredicate::create(operandR, isComp,
624  parseInfo->staticContext, fromYYLTYPE(sl, parseInfo)), sl, parseInfo);
625 }
626 
631 static inline QString prologMessage(const char *const msg)
632 {
633  Q_ASSERT(msg);
634  return QtXmlPatterns::tr("Only one %1 declaration can occur in the query prolog.").arg(formatKeyword(msg));
635 }
636 
647 template<const ReportContext::ErrorCode errorCode>
648 static QUrl resolveAndCheckCollation(const QString &collation,
649  const ParserContext *const parseInfo,
650  const YYLTYPE &sl)
651 {
652  Q_ASSERT(parseInfo);
653  const ReflectYYLTYPE ryy(sl, parseInfo);
654 
655  QUrl uri(AnyURI::toQUrl<ReportContext::XQST0046>(collation, parseInfo->staticContext, &ryy));
656 
657  if(uri.isRelative())
658  uri = parseInfo->staticContext->baseURI().resolved(uri);
659 
660  XPathHelper::checkCollationSupport<errorCode>(uri.toString(), parseInfo->staticContext, &ryy);
661 
662  return uri;
663 }
664 
665 /* The Bison generated parser declares macros that aren't used
666  * so suppress the warnings by fake usage of them.
667  *
668  * We do the same for some more defines in the first action. */
669 #if defined(YYLSP_NEEDED) \
670  || defined(YYBISON) \
671  || defined(YYBISON_VERSION) \
672  || defined(YYPURE) \
673  || defined(yydebug) \
674  || defined(YYSKELETON_NAME)
675 #endif
676 
684  const ParserContext *const parseInfo,
685  const YYLTYPE &sl)
686 {
687  return create(new CopyOf(operand, parseInfo->inheritNamespacesMode,
688  parseInfo->preserveNamespacesMode), sl, parseInfo);
689 }
690 
692  const YYLTYPE &sourceLocator,
693  const ParserContext *const parseInfo)
694 {
695  return create(new StaticCompatibilityStore(expr), sourceLocator, parseInfo);
696 }
697 
702 static Expression::Ptr createRootExpression(const ParserContext *const parseInfo,
703  const YYLTYPE &sl)
704 {
705  Q_ASSERT(parseInfo);
707 
708  Expression::List args;
709  args.append(create(new ContextItem(), sl, parseInfo));
710 
711  const ReflectYYLTYPE ryy(sl, parseInfo);
712 
713  const Expression::Ptr fnRoot(parseInfo->staticContext->functionSignatures()
714  ->createFunctionCall(name, args, parseInfo->staticContext, &ryy));
715  Q_ASSERT(fnRoot);
716 
717  return create(new TreatAs(create(fnRoot, sl, parseInfo), CommonSequenceTypes::ExactlyOneDocumentNode), sl, parseInfo);
718 }
719 
720 static int XPathlex(YYSTYPE *lexVal, YYLTYPE *sourceLocator, const ParserContext *const parseInfo)
721 {
722 #ifdef Patternist_DEBUG_PARSER
723 
728 # define YYDEBUG 1
729 
730  extern int XPathdebug;
731  XPathdebug = 1;
732 #endif
733 
734  Q_ASSERT(parseInfo);
735 
736  const Tokenizer::Token tok(parseInfo->tokenizer->nextToken(sourceLocator));
737 
738  (*lexVal).sval = tok.value;
739 
740  return static_cast<int>(tok.type);
741 }
742 
752  const Expression::Ptr &end,
753  const YYLTYPE &sourceLocator,
754  const ParserContext *const parseInfo)
755 {
756  const Expression::Ptr twoSlash(create(new AxisStep(QXmlNodeModelIndex::AxisDescendantOrSelf, BuiltinTypes::node), sourceLocator, parseInfo));
757  const Expression::Ptr p1(create(new Path(begin, twoSlash), sourceLocator, parseInfo));
758 
759  return create(new Path(p1, end), sourceLocator, parseInfo);
760 }
761 
765 static inline Expression::Ptr createConcatFN(const ParserContext *const parseInfo,
766  const Expression::List &args,
767  const YYLTYPE &sourceLocator)
768 {
769  Q_ASSERT(parseInfo);
771  const ReflectYYLTYPE ryy(sourceLocator, parseInfo);
772 
773  return create(parseInfo->staticContext->functionSignatures()->createFunctionCall(name, args, parseInfo->staticContext, &ryy),
774  sourceLocator, parseInfo);
775 }
776 
778  const ParserContext *const parseInfo,
779  const YYLTYPE &sourceLocator)
780 {
781  if(content.isEmpty())
782  return create(new EmptySequence(), sourceLocator, parseInfo);
783  else if(content.size() == 1)
784  return content.first();
785  else
786  return createConcatFN(parseInfo, content, sourceLocator);
787 }
788 
804  const Expression::Ptr &checkee,
806  FunctionSignature::List &signList,
807  const ParserContext *const parseInfo)
808 {
809  Q_ASSERT(var);
810  Q_ASSERT(checkee);
811  Q_ASSERT(parseInfo);
812 
813  const Expression::ID id = checkee->id();
814 
816  {
817  const ExpressionVariableReference *const ref =
818  static_cast<const ExpressionVariableReference *>(checkee.data());
819 
820  if(var->slot == ref->slot() && type == ref->variableDeclaration()->type)
821  {
822  parseInfo->staticContext->error(QtXmlPatterns::tr("The initialization of variable %1 "
823  "depends on itself").arg(formatKeyword(var, parseInfo->staticContext->namePool())),
825  return;
826  }
827  else
828  {
829  /* If the variable we're checking is below another variable, it can be a recursive
830  * dependency through functions, so we need to check variable references too. */
831  checkVariableCircularity(var, ref->sourceExpression(), type, signList, parseInfo);
832  return;
833  }
834  }
836  {
837  const UserFunctionCallsite::Ptr callsite(checkee);
838  const FunctionSignature::Ptr sign(callsite->callTargetDescription());
841  bool noMatch = true;
842 
843  for(; it != end; ++it)
844  {
845  if(*it == sign)
846  {
847  /* The variable we're checking is depending on a function that's recursive. The
848  * user has written a weird query, in other words. Since it's the second time
849  * we've encountered a callsite, we now skip it. */
850  noMatch = false;
851  break;
852  }
853  }
854 
855  if(noMatch)
856  {
857  signList.append(sign);
858  /* Check the body of the function being called. */
859  checkVariableCircularity(var, callsite->body(), type, signList, parseInfo);
860  }
861  /* Continue with the operands, such that we also check the arguments of the callsite. */
862  }
864  {
865  /* We're called before it has rewritten itself. */
866  checkVariableCircularity(var, checkee->as<UnresolvedVariableReference>()->replacement(), type, signList, parseInfo);
867  }
868 
869  /* Check the operands. */
870  const Expression::List ops(checkee->operands());
871  if(ops.isEmpty())
872  return;
873 
874  const Expression::List::const_iterator end(ops.constEnd());
875  Expression::List::const_iterator it(ops.constBegin());
876 
877  for(; it != end; ++it)
878  checkVariableCircularity(var, *it, type, signList, parseInfo);
879 }
880 
881 static void variableUnavailable(const QXmlName &variableName,
882  const ParserContext *const parseInfo,
883  const YYLTYPE &location)
884 {
885  parseInfo->staticContext->error(QtXmlPatterns::tr("No variable with name %1 exists")
886  .arg(formatKeyword(parseInfo->staticContext->namePool(), variableName)),
887  ReportContext::XPST0008, fromYYLTYPE(location, parseInfo));
888 }
889 
899 {
900  Q_ASSERT(type);
901  return makeGenericSequenceType(type->itemType(), Cardinality::zeroOrMore());
902 }
903 
908  const SequenceType::Ptr &seqType,
909  const Expression::Ptr &expr,
911  const YYLTYPE &sourceLocator,
912  ParserContext *const parseInfo,
913  const bool checkSource = true)
914 {
915  Q_ASSERT(!name.isNull());
916  Q_ASSERT(parseInfo);
917 
918  /* -2 will cause Q_ASSERTs to trigger if it isn't changed. */
919  VariableSlotID slot = -2;
920 
921  switch(type)
922  {
924  /* Fallthrough. */
926  {
927  slot = parseInfo->allocateExpressionSlot();
928  break;
929  }
931  {
932  slot = parseInfo->allocateGlobalVariableSlot();
933  break;
934  }
936  {
937  slot = parseInfo->staticContext->allocateRangeSlot();
938  break;
939  }
941  {
942  slot = parseInfo->allocatePositionalSlot();
943  break;
944  }
946  /* Fallthrough. We do nothing, template parameters
947  * doesn't use context slots at all, they're hashed
948  * on the name. */
950  /* We do nothing, external variables doesn't use
951  *context slots/stack frames at all. */
952  ;
953  }
954 
955  const VariableDeclaration::Ptr var(new VariableDeclaration(name, slot, type, seqType));
956 
957  Expression::Ptr checked;
958 
959  if(checkSource && seqType)
960  {
961  if(expr)
962  {
963  /* We only want to add conversion for function arguments, and variables
964  * if we're XSL-T.
965  *
966  * We unconditionally skip TypeChecker::CheckFocus because the StaticContext we
967  * pass hasn't set up the focus yet, since that's the parent's responsibility. */
970  || parseInfo->isXSLT())
972 
973  checked = TypeChecker::applyFunctionConversion(expr, seqType, parseInfo->staticContext,
975  options);
976  }
977  }
978  else
979  checked = expr;
980 
981  /* Add an evaluation cache for all expression variables. No EvaluationCache is needed for
982  * positional variables because in the end they are calls to Iterator::position(). Similarly,
983  * no need to cache range variables either because they are calls to DynamicContext::rangeVariable().
984  *
985  * We don't do it for function arguments because the Expression being cached depends -- it depends
986  * on the callsite. UserFunctionCallsite is responsible for the evaluation caches in that case.
987  *
988  * In some cases the EvaluationCache instance isn't necessary, but in those cases EvaluationCache
989  * optimizes itself away. */
991  checked = create(new EvaluationCache<false>(checked, var.data(), parseInfo->allocateCacheSlot()), sourceLocator, parseInfo);
992  else if(type == VariableDeclaration::GlobalVariable)
993  checked = create(new EvaluationCache<true>(checked, var.data(), parseInfo->allocateCacheSlot()), sourceLocator, parseInfo);
994 
995  var->setExpression(checked);
996 
997  parseInfo->variables.push(var);
998  return checked;
999 }
1000 
1002  const ParserContext *const parseInfo)
1003 {
1004  Q_ASSERT(!name.isNull());
1005  Q_ASSERT(parseInfo);
1006 
1007  /* We walk the list backwards. */
1010 
1011  while(it != start)
1012  {
1013  --it;
1014  Q_ASSERT(*it);
1015  if((*it)->name == name)
1016  return *it;
1017  }
1018 
1019  return VariableDeclaration::Ptr();
1020 }
1021 
1023  const YYLTYPE &sourceLocator,
1024  ParserContext *const parseInfo,
1025  const bool raiseErrorOnUnavailability)
1026 {
1027  const VariableDeclaration::Ptr var(variableByName(name, parseInfo));
1028  Expression::Ptr retval;
1029 
1030  if(var && var->type != VariableDeclaration::ExternalVariable)
1031  {
1032  switch(var->type)
1033  {
1035  {
1036  retval = create(new RangeVariableReference(var->expression(), var->slot), sourceLocator, parseInfo);
1037  break;
1038  }
1040  /* Fallthrough. From the perspective of an ExpressionVariableReference, it can't tell
1041  * a difference between a global and a local expression variable. However, the cache
1042  * mechanism must. */
1044  {
1045  retval = create(new ExpressionVariableReference(var->slot, var.data()), sourceLocator, parseInfo);
1046  break;
1047  }
1049  {
1050  retval = create(new ArgumentReference(var->sequenceType, var->slot), sourceLocator, parseInfo);
1051  break;
1052  }
1054  {
1055  retval = create(new PositionalVariableReference(var->slot), sourceLocator, parseInfo);
1056  break;
1057  }
1059  {
1060  retval = create(new TemplateParameterReference(var.data()), sourceLocator, parseInfo);
1061  break;
1062  }
1064  /* This code path will never be hit, but the case
1065  * label silences a warning. See above. */
1066  ;
1067  }
1068  Q_ASSERT(retval);
1069  var->references.append(retval);
1070  }
1071  else
1072  {
1073  /* Let's see if your external variable loader can provide us with one. */
1074  const SequenceType::Ptr varType(parseInfo->staticContext->
1075  externalVariableLoader()->announceExternalVariable(name, CommonSequenceTypes::ZeroOrMoreItems));
1076 
1077  if(varType)
1078  {
1079  const Expression::Ptr extRef(create(new ExternalVariableReference(name, varType), sourceLocator, parseInfo));
1080  const Expression::Ptr checked(TypeChecker::applyFunctionConversion(extRef, varType, parseInfo->staticContext));
1081  retval = checked;
1082  }
1083  else if(!raiseErrorOnUnavailability && parseInfo->isXSLT())
1084  {
1085  /* In XSL-T, global variables are in scope for the whole
1086  * stylesheet, so we must resolve this first at the end. */
1087  retval = create(new UnresolvedVariableReference(name), sourceLocator, parseInfo);
1088  parseInfo->unresolvedVariableReferences.insert(name, retval);
1089  }
1090  else
1091  variableUnavailable(name, parseInfo, sourceLocator);
1092  }
1093 
1094  return retval;
1095 }
1096 
1098  const Expression::Ptr &returnExpr,
1099  const OrderBy::Stability stability,
1100  const YYLTYPE &sourceLocator,
1101  const ParserContext *const parseInfo)
1102 {
1103  // TODO do resize(orderSpec.size() + 1)
1104  Expression::List exprs;
1105  OrderBy::OrderSpec::Vector orderSpecs;
1106 
1107  exprs.append(returnExpr);
1108 
1109  const int len = orderSpecTransfer.size();
1110 
1111  for(int i = 0; i < len; ++i)
1112  {
1113  exprs.append(orderSpecTransfer.at(i).expression);
1114  orderSpecs.append(orderSpecTransfer.at(i).orderSpec);
1115  }
1116 
1117  return create(new ReturnOrderBy(stability, orderSpecs, exprs), sourceLocator, parseInfo);
1118 }
1119 
1120 
1121 
1122 /* Enabling traces. */
1123 #ifndef YYDEBUG
1124 # define YYDEBUG 0
1125 #endif
1126 
1127 /* Enabling verbose error messages. */
1128 #ifdef YYERROR_VERBOSE
1129 # undef YYERROR_VERBOSE
1130 # define YYERROR_VERBOSE 1
1131 #else
1132 # define YYERROR_VERBOSE 1
1133 #endif
1134 
1135 /* Enabling the token table. */
1136 #ifndef YYTOKEN_TABLE
1137 # define YYTOKEN_TABLE 0
1138 #endif
1139 
1140 
1141 /* Tokens. */
1142 #ifndef YYTOKENTYPE
1143 # define YYTOKENTYPE
1144  /* Put the tokens into the symbol table, so that GDB and other debuggers
1145  know about them. */
1146  enum yytokentype {
1147  END_OF_FILE = 0,
1148  STRING_LITERAL = 258,
1149  NON_BOUNDARY_WS = 259,
1150  XPATH2_STRING_LITERAL = 260,
1151  QNAME = 261,
1152  NCNAME = 262,
1153  CLARK_NAME = 263,
1154  ANY_LOCAL_NAME = 264,
1155  ANY_PREFIX = 265,
1156  NUMBER = 266,
1157  XPATH2_NUMBER = 267,
1158  ANCESTOR = 268,
1159  ANCESTOR_OR_SELF = 269,
1160  AND = 270,
1161  APOS = 271,
1162  APPLY_TEMPLATE = 272,
1163  AS = 273,
1164  ASCENDING = 274,
1165  ASSIGN = 275,
1166  AT = 276,
1167  AT_SIGN = 277,
1168  ATTRIBUTE = 278,
1169  AVT = 279,
1170  BAR = 280,
1171  BASEURI = 281,
1172  BEGIN_END_TAG = 282,
1173  BOUNDARY_SPACE = 283,
1174  BY = 284,
1175  CALL_TEMPLATE = 285,
1176  CASE = 286,
1177  CASTABLE = 287,
1178  CAST = 288,
1179  CHILD = 289,
1180  COLLATION = 290,
1181  COLONCOLON = 291,
1182  COMMA = 292,
1183  COMMENT = 293,
1184  COMMENT_START = 294,
1185  CONSTRUCTION = 295,
1186  COPY_NAMESPACES = 296,
1187  CURLY_LBRACE = 297,
1188  CURLY_RBRACE = 298,
1189  DECLARE = 299,
1190  DEFAULT = 300,
1191  DESCENDANT = 301,
1192  DESCENDANT_OR_SELF = 302,
1193  DESCENDING = 303,
1194  DIV = 304,
1195  DOCUMENT = 305,
1196  DOCUMENT_NODE = 306,
1197  DOLLAR = 307,
1198  DOT = 308,
1199  DOTDOT = 309,
1200  ELEMENT = 310,
1201  ELSE = 311,
1202  EMPTY = 312,
1203  EMPTY_SEQUENCE = 313,
1204  ENCODING = 314,
1205  END_SORT = 315,
1206  EQ = 316,
1207  ERROR = 317,
1208  EVERY = 318,
1209  EXCEPT = 319,
1210  EXTERNAL = 320,
1211  FOLLOWING = 321,
1212  FOLLOWING_SIBLING = 322,
1213  FOLLOWS = 323,
1214  FOR_APPLY_TEMPLATE = 324,
1215  FOR = 325,
1216  FUNCTION = 326,
1217  GE = 327,
1218  G_EQ = 328,
1219  G_GE = 329,
1220  G_GT = 330,
1221  G_LE = 331,
1222  G_LT = 332,
1223  G_NE = 333,
1224  GREATEST = 334,
1225  GT = 335,
1226  IDIV = 336,
1227  IF = 337,
1228  IMPORT = 338,
1229  INHERIT = 339,
1230  IN = 340,
1231  INSTANCE = 341,
1232  INTERSECT = 342,
1233  IS = 343,
1234  ITEM = 344,
1235  LAX = 345,
1236  LBRACKET = 346,
1237  LEAST = 347,
1238  LE = 348,
1239  LET = 349,
1240  LPAREN = 350,
1241  LT = 351,
1242  MAP = 352,
1243  MATCHES = 353,
1244  MINUS = 354,
1245  MODE = 355,
1246  MOD = 356,
1247  MODULE = 357,
1248  NAME = 358,
1249  NAMESPACE = 359,
1250  NE = 360,
1251  NODE = 361,
1252  NO_INHERIT = 362,
1253  NO_PRESERVE = 363,
1254  OF = 364,
1255  OPTION = 365,
1256  ORDERED = 366,
1257  ORDERING = 367,
1258  ORDER = 368,
1259  OR = 369,
1260  PARENT = 370,
1261  PI_START = 371,
1262  PLUS = 372,
1263  POSITION_SET = 373,
1264  PRAGMA_END = 374,
1265  PRAGMA_START = 375,
1266  PRECEDES = 376,
1267  PRECEDING = 377,
1268  PRECEDING_SIBLING = 378,
1269  PRESERVE = 379,
1270  PRIORITY = 380,
1271  PROCESSING_INSTRUCTION = 381,
1272  QUESTION = 382,
1273  QUICK_TAG_END = 383,
1274  QUOTE = 384,
1275  RBRACKET = 385,
1276  RETURN = 386,
1277  RPAREN = 387,
1278  SATISFIES = 388,
1279  SCHEMA_ATTRIBUTE = 389,
1280  SCHEMA_ELEMENT = 390,
1281  SCHEMA = 391,
1282  SELF = 392,
1283  SEMI_COLON = 393,
1284  SLASH = 394,
1285  SLASHSLASH = 395,
1286  SOME = 396,
1287  SORT = 397,
1288  STABLE = 398,
1289  STAR = 399,
1290  STRICT = 400,
1291  STRIP = 401,
1292  SUCCESS = 402,
1293  COMMENT_CONTENT = 403,
1294  PI_CONTENT = 404,
1295  PI_TARGET = 405,
1296  XSLT_VERSION = 406,
1297  TEMPLATE = 407,
1298  TEXT = 408,
1299  THEN = 409,
1300  TO = 410,
1301  TREAT = 411,
1302  TUNNEL = 412,
1303  TYPESWITCH = 413,
1304  UNION = 414,
1305  UNORDERED = 415,
1306  VALIDATE = 416,
1307  VARIABLE = 417,
1308  VERSION = 418,
1309  WHERE = 419,
1310  XQUERY = 420,
1311  INTERNAL = 421,
1312  INTERNAL_NAME = 422,
1313  CURRENT = 423
1314  };
1315 #endif
1316 
1317 
1318 
1319 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
1320 
1321 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
1322 # define YYSTYPE_IS_DECLARED 1
1323 #endif
1324 
1325 #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
1326 typedef struct YYLTYPE
1327 {
1328  int first_line;
1329  int first_column;
1330  int last_line;
1331  int last_column;
1332 } YYLTYPE;
1333 # define yyltype YYLTYPE /* obsolescent; will be withdrawn */
1334 # define YYLTYPE_IS_DECLARED 1
1335 # define YYLTYPE_IS_TRIVIAL 1
1336 #endif
1337 
1338 
1339 /* Copy the second part of user declarations. */
1340 
1341 /* Line 221 of yacc.c. */
1342 #line 1323 "qquerytransformparser.cpp"
1343 
1344 #ifdef short
1345 # undef short
1346 #endif
1347 
1348 #ifdef YYTYPE_UINT8
1349 typedef YYTYPE_UINT8 yytype_uint8;
1350 #else
1351 typedef unsigned char yytype_uint8;
1352 #endif
1353 
1354 #ifdef YYTYPE_INT8
1355 typedef YYTYPE_INT8 yytype_int8;
1356 #elif (defined __STDC__ || defined __C99__FUNC__ \
1357  || defined __cplusplus || defined _MSC_VER)
1358 typedef signed char yytype_int8;
1359 #else
1360 typedef short int yytype_int8;
1361 #endif
1362 
1363 #ifdef YYTYPE_UINT16
1364 typedef YYTYPE_UINT16 yytype_uint16;
1365 #else
1366 typedef unsigned short int yytype_uint16;
1367 #endif
1368 
1369 #ifdef YYTYPE_INT16
1370 typedef YYTYPE_INT16 yytype_int16;
1371 #else
1372 typedef short int yytype_int16;
1373 #endif
1374 
1375 #ifndef YYSIZE_T
1376 # ifdef __SIZE_TYPE__
1377 # define YYSIZE_T __SIZE_TYPE__
1378 # elif defined size_t
1379 # define YYSIZE_T size_t
1380 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
1381  || defined __cplusplus || defined _MSC_VER)
1382 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1383 # define YYSIZE_T size_t
1384 # else
1385 # define YYSIZE_T unsigned int
1386 # endif
1387 #endif
1388 
1389 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
1390 
1391 #ifndef YY_
1392 # if YYENABLE_NLS
1393 # if ENABLE_NLS
1394 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
1395 # define YY_(msgid) dgettext ("bison-runtime", msgid)
1396 # endif
1397 # endif
1398 # ifndef YY_
1399 # define YY_(msgid) msgid
1400 # endif
1401 #endif
1402 
1403 /* Suppress unused-variable warnings by "using" E. */
1404 #if ! defined lint || defined __GNUC__
1405 # define YYUSE(e) ((void) (e))
1406 #else
1407 # define YYUSE(e) /* empty */
1408 #endif
1409 
1410 /* Identity function, used to suppress warnings about constant conditions. */
1411 #ifndef lint
1412 # define YYID(n) (n)
1413 #else
1414 #if (defined __STDC__ || defined __C99__FUNC__ \
1415  || defined __cplusplus || defined _MSC_VER)
1416 static int
1417 YYID (int yyi)
1418 #else
1419 static int
1420 YYID (yyi)
1421  int yyi;
1422 #endif
1423 {
1424  return yyi;
1425 }
1426 #endif
1427 
1428 #if ! defined yyoverflow || YYERROR_VERBOSE
1429 
1430 /* The parser invokes alloca or malloc; define the necessary symbols. */
1431 
1432 # ifdef YYSTACK_USE_ALLOCA
1433 # if YYSTACK_USE_ALLOCA
1434 # ifdef __GNUC__
1435 # define YYSTACK_ALLOC __builtin_alloca
1436 # elif defined __BUILTIN_VA_ARG_INCR
1437 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
1438 # elif defined _AIX
1439 # define YYSTACK_ALLOC __alloca
1440 # elif defined _MSC_VER
1441 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
1442 # define alloca _alloca
1443 # else
1444 # define YYSTACK_ALLOC alloca
1445 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1446  || defined __cplusplus || defined _MSC_VER)
1447 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1448 # ifndef _STDLIB_H
1449 # define _STDLIB_H 1
1450 # endif
1451 # endif
1452 # endif
1453 # endif
1454 # endif
1455 
1456 # ifdef YYSTACK_ALLOC
1457  /* Pacify GCC's `empty if-body' warning. */
1458 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
1459 # ifndef YYSTACK_ALLOC_MAXIMUM
1460  /* The OS might guarantee only one guard page at the bottom of the stack,
1461  and a page size can be as small as 4096 bytes. So we cannot safely
1462  invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
1463  to allow for a few compiler-allocated temporary stack slots. */
1464 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
1465 # endif
1466 # else
1467 # define YYSTACK_ALLOC YYMALLOC
1468 # define YYSTACK_FREE YYFREE
1469 # ifndef YYSTACK_ALLOC_MAXIMUM
1470 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
1471 # endif
1472 # if (defined __cplusplus && ! defined _STDLIB_H \
1473  && ! ((defined YYMALLOC || defined malloc) \
1474  && (defined YYFREE || defined free)))
1475 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
1476 # ifndef _STDLIB_H
1477 # define _STDLIB_H 1
1478 # endif
1479 # endif
1480 # ifndef YYMALLOC
1481 # define YYMALLOC malloc
1482 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1483  || defined __cplusplus || defined _MSC_VER)
1484 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
1485 # endif
1486 # endif
1487 # ifndef YYFREE
1488 # define YYFREE free
1489 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
1490  || defined __cplusplus || defined _MSC_VER)
1491 void free (void *); /* INFRINGES ON USER NAME SPACE */
1492 # endif
1493 # endif
1494 # endif
1495 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
1496 
1497 
1498 #if (! defined yyoverflow \
1499  && (! defined __cplusplus \
1500  || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
1501  && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
1502 
1503 /* A type that is properly aligned for any stack member. */
1504 union yyalloc
1505 {
1506  yytype_int16 yyss;
1507  YYSTYPE yyvs;
1508  YYLTYPE yyls;
1509 };
1510 
1511 /* The size of the maximum gap between one aligned stack and the next. */
1512 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
1513 
1514 /* The size of an array large to enough to hold all stacks, each with
1515  N elements. */
1516 # define YYSTACK_BYTES(N) \
1517  ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
1518  + 2 * YYSTACK_GAP_MAXIMUM)
1519 
1520 /* Copy COUNT objects from FROM to TO. The source and destination do
1521  not overlap. */
1522 # ifndef YYCOPY
1523 # if defined __GNUC__ && 1 < __GNUC__
1524 # define YYCOPY(To, From, Count) \
1525  __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
1526 # else
1527 # define YYCOPY(To, From, Count) \
1528  do \
1529  { \
1530  YYSIZE_T yyi; \
1531  for (yyi = 0; yyi < (Count); yyi++) \
1532  (To)[yyi] = (From)[yyi]; \
1533  } \
1534  while (YYID (0))
1535 # endif
1536 # endif
1537 
1538 /* Relocate STACK from its old location to the new one. The
1539  local variables YYSIZE and YYSTACKSIZE give the old and new number of
1540  elements in the stack, and YYPTR gives the new location of the
1541  stack. Advance YYPTR to a properly aligned location for the next
1542  stack. */
1543 # define YYSTACK_RELOCATE(Stack) \
1544  do \
1545  { \
1546  YYSIZE_T yynewbytes; \
1547  YYCOPY (&yyptr->Stack, Stack, yysize); \
1548  Stack = &yyptr->Stack; \
1549  yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
1550  yyptr += yynewbytes / sizeof (*yyptr); \
1551  } \
1552  while (YYID (0))
1553 
1554 #endif
1555 
1556 /* YYFINAL -- State number of the termination state. */
1557 #define YYFINAL 5
1558 /* YYLAST -- Last index in YYTABLE. */
1559 #define YYLAST 2052
1560 
1561 /* YYNTOKENS -- Number of terminals. */
1562 #define YYNTOKENS 169
1563 /* YYNNTS -- Number of nonterminals. */
1564 #define YYNNTS 237
1565 /* YYNRULES -- Number of rules. */
1566 #define YYNRULES 472
1567 /* YYNRULES -- Number of states. */
1568 #define YYNSTATES 812
1569 
1570 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
1571 #define YYUNDEFTOK 2
1572 #define YYMAXUTOK 423
1573 
1574 #define YYTRANSLATE(YYX) \
1575  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
1576 
1577 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
1578 static const yytype_uint8 yytranslate[] =
1579 {
1580  0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1581  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1582  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1583  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1584  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1585  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1586  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1587  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1588  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1589  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1590  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1591  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1592  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1593  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1594  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1595  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1596  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1597  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1598  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1599  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1600  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1601  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1602  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1603  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1604  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1605  2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
1606  5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
1607  15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1608  25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
1609  35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
1610  45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1611  55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
1612  65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
1613  75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
1614  85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
1615  95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
1616  105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
1617  115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
1618  125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
1619  135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
1620  145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
1621  155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
1622  165, 166, 167, 168
1623 };
1624 
1625 #if YYDEBUG
1626 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
1627  YYRHS. */
1628 static const yytype_uint16 yyprhs[] =
1629 {
1630  0, 0, 3, 6, 9, 10, 16, 17, 20, 23,
1631  26, 33, 34, 37, 40, 43, 46, 49, 52, 55,
1632  58, 66, 67, 68, 84, 85, 88, 89, 91, 94,
1633  96, 98, 100, 102, 104, 106, 108, 110, 112, 114,
1634  122, 127, 129, 131, 133, 135, 142, 149, 155, 160,
1635  162, 164, 170, 173, 176, 183, 185, 187, 189, 191,
1636  197, 203, 210, 211, 215, 219, 226, 227, 231, 232,
1637  235, 237, 241, 251, 253, 256, 257, 260, 265, 267,
1638  269, 270, 282, 283, 285, 289, 293, 295, 297, 301,
1639  303, 305, 309, 311, 313, 316, 319, 321, 325, 329,
1640  331, 333, 337, 341, 343, 345, 347, 351, 355, 357,
1641  359, 361, 363, 365, 370, 371, 374, 375, 378, 380,
1642  384, 386, 388, 390, 392, 393, 394, 405, 406, 407,
1643  418, 420, 422, 424, 425, 429, 430, 440, 441, 450,
1644  452, 454, 456, 460, 466, 467, 469, 472, 476, 478,
1645  483, 484, 486, 488, 489, 491, 492, 495, 499, 503,
1646  506, 508, 510, 511, 512, 522, 523, 524, 534, 536,
1647  537, 538, 548, 549, 550, 560, 562, 565, 566, 573,
1648  574, 575, 584, 586, 588, 589, 593, 597, 598, 605,
1649  614, 616, 620, 622, 626, 628, 630, 632, 634, 636,
1650  640, 642, 646, 648, 650, 652, 656, 658, 660, 662,
1651  664, 666, 670, 672, 676, 678, 680, 682, 684, 686,
1652  691, 693, 698, 700, 705, 707, 712, 714, 717, 719,
1653  721, 723, 725, 727, 731, 733, 735, 737, 739, 741,
1654  743, 747, 749, 751, 753, 755, 757, 759, 763, 765,
1655  767, 769, 772, 774, 777, 780, 783, 786, 790, 793,
1656  795, 800, 801, 803, 806, 809, 811, 813, 815, 819,
1657  827, 831, 833, 835, 838, 839, 843, 849, 850, 860,
1658  866, 867, 870, 871, 873, 877, 878, 882, 888, 889,
1659  891, 892, 895, 897, 899, 901, 903, 908, 910, 912,
1660  913, 917, 919, 921, 923, 926, 928, 930, 932, 934,
1661  936, 938, 940, 942, 944, 946, 948, 950, 951, 955,
1662  957, 959, 961, 963, 965, 967, 969, 971, 973, 975,
1663  977, 979, 984, 986, 988, 990, 992, 994, 996, 998,
1664  1004, 1006, 1008, 1010, 1012, 1015, 1017, 1019, 1023, 1026,
1665  1028, 1031, 1036, 1037, 1039, 1041, 1043, 1045, 1047, 1049,
1666  1051, 1052, 1053, 1062, 1064, 1070, 1071, 1074, 1078, 1082,
1667  1086, 1087, 1090, 1093, 1094, 1097, 1100, 1103, 1106, 1109,
1668  1113, 1115, 1117, 1119, 1121, 1123, 1125, 1127, 1131, 1132,
1669  1138, 1139, 1141, 1146, 1150, 1154, 1158, 1159, 1160, 1164,
1670  1166, 1168, 1170, 1172, 1174, 1176, 1180, 1182, 1185, 1186,
1671  1189, 1192, 1195, 1196, 1198, 1200, 1202, 1204, 1206, 1208,
1672  1211, 1213, 1215, 1217, 1219, 1221, 1223, 1225, 1227, 1230,
1673  1233, 1238, 1240, 1242, 1245, 1248, 1251, 1256, 1261, 1263,
1674  1265, 1268, 1273, 1278, 1285, 1292, 1297, 1300, 1305, 1310,
1675  1318, 1326, 1327, 1329, 1334, 1337, 1339, 1341, 1343, 1345,
1676  1347, 1349, 1351, 1353, 1356, 1358, 1360, 1362, 1364, 1366,
1677  1368, 1370, 1372
1678 };
1679 
1680 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
1681 static const yytype_int16 yyrhs[] =
1682 {
1683  170, 0, -1, 171, 174, -1, 171, 173, -1, -1,
1684  165, 163, 404, 172, 185, -1, -1, 59, 404, -1,
1685  176, 219, -1, 175, 176, -1, 102, 104, 7, 73,
1686  403, 185, -1, -1, 176, 189, -1, 176, 183, -1,
1687  176, 186, -1, 176, 184, -1, 176, 177, -1, 176,
1688  208, -1, 176, 213, -1, 176, 192, -1, 44, 152,
1689  182, 317, 377, 305, 185, -1, -1, -1, 44, 152,
1690  181, 98, 95, 178, 220, 179, 132, 228, 180, 317,
1691  377, 305, 185, -1, -1, 125, 404, -1, -1, 182,
1692  -1, 103, 397, -1, 187, -1, 200, -1, 201, -1,
1693  211, -1, 193, -1, 195, -1, 197, -1, 202, -1,
1694  204, -1, 138, -1, 44, 104, 7, 73, 403, 364,
1695  185, -1, 44, 28, 188, 185, -1, 146, -1, 124,
1696  -1, 190, -1, 191, -1, 44, 45, 55, 104, 403,
1697  185, -1, 44, 45, 71, 104, 403, 185, -1, 44,
1698  110, 397, 404, 185, -1, 44, 112, 194, 185, -1,
1699  111, -1, 160, -1, 44, 45, 113, 196, 185, -1,
1700  57, 92, -1, 57, 79, -1, 44, 41, 198, 37,
1701  199, 185, -1, 124, -1, 108, -1, 84, -1, 107,
1702  -1, 44, 45, 35, 404, 185, -1, 44, 26, 364,
1703  403, 185, -1, 83, 136, 203, 403, 206, 185, -1,
1704  -1, 45, 55, 104, -1, 104, 7, 73, -1, 83,
1705  102, 205, 403, 206, 185, -1, -1, 104, 7, 73,
1706  -1, -1, 21, 207, -1, 403, -1, 207, 37, 403,
1707  -1, 44, 162, 364, 52, 341, 377, 209, 210, 185,
1708  -1, 65, -1, 20, 227, -1, -1, 20, 227, -1,
1709  44, 40, 212, 185, -1, 146, -1, 124, -1, -1,
1710  44, 71, 364, 399, 95, 215, 132, 214, 377, 217,
1711  185, -1, -1, 216, -1, 215, 37, 216, -1, 52,
1712  341, 377, -1, 65, -1, 218, -1, 42, 225, 43,
1713  -1, 225, -1, 221, -1, 220, 25, 221, -1, 223,
1714  -1, 139, -1, 139, 223, -1, 140, 223, -1, 222,
1715  -1, 222, 139, 223, -1, 222, 140, 223, -1, 345,
1716  -1, 224, -1, 223, 139, 224, -1, 223, 140, 224,
1717  -1, 322, -1, 227, -1, 226, -1, 227, 37, 227,
1718  -1, 226, 37, 227, -1, 277, -1, 232, -1, 253,
1719  -1, 267, -1, 276, -1, 24, 95, 356, 132, -1,
1720  -1, 100, 230, -1, -1, 100, 231, -1, 231, -1,
1721  230, 37, 231, -1, 405, -1, 7, -1, 233, -1,
1722  240, -1, -1, -1, 70, 52, 341, 377, 239, 85,
1723  227, 234, 235, 236, -1, -1, -1, 37, 52, 341,
1724  377, 239, 85, 227, 237, 238, 236, -1, 244, -1,
1725  233, -1, 240, -1, -1, 21, 52, 341, -1, -1,
1726  94, 364, 52, 341, 377, 20, 227, 241, 242, -1,
1727  -1, 37, 52, 341, 377, 20, 227, 243, 242, -1,
1728  244, -1, 233, -1, 240, -1, 245, 131, 227, -1,
1729  164, 227, 245, 131, 227, -1, -1, 246, -1, 252,
1730  247, -1, 247, 37, 248, -1, 248, -1, 227, 249,
1731  250, 251, -1, -1, 19, -1, 48, -1, -1, 196,
1732  -1, -1, 35, 403, -1, 166, 35, 227, -1, 143,
1733  113, 29, -1, 113, 29, -1, 254, -1, 260, -1,
1734  -1, -1, 141, 52, 341, 377, 85, 227, 255, 256,
1735  257, -1, -1, -1, 37, 52, 341, 377, 85, 227,
1736  258, 259, 257, -1, 266, -1, -1, -1, 63, 52,
1737  341, 377, 85, 227, 261, 262, 263, -1, -1, -1,
1738  37, 52, 341, 377, 85, 227, 264, 265, 263, -1,
1739  266, -1, 133, 227, -1, -1, 158, 95, 225, 132,
1740  268, 269, -1, -1, -1, 31, 273, 378, 270, 131,
1741  227, 271, 272, -1, 269, -1, 274, -1, -1, 52,
1742  397, 18, -1, 45, 131, 227, -1, -1, 45, 52,
1743  397, 275, 131, 227, -1, 82, 95, 225, 132, 154,
1744  227, 56, 227, -1, 278, -1, 277, 114, 278, -1,
1745  279, -1, 278, 15, 279, -1, 280, -1, 298, -1,
1746  296, -1, 300, -1, 281, -1, 281, 155, 281, -1,
1747  283, -1, 281, 282, 283, -1, 117, -1, 99, -1,
1748  285, -1, 283, 284, 285, -1, 144, -1, 49, -1,
1749  81, -1, 101, -1, 286, -1, 285, 287, 286, -1,
1750  289, -1, 286, 288, 289, -1, 159, -1, 25, -1,
1751  87, -1, 64, -1, 290, -1, 290, 86, 109, 378,
1752  -1, 291, -1, 291, 156, 18, 378, -1, 292, -1,
1753  292, 32, 18, 376, -1, 293, -1, 293, 33, 18,
1754  376, -1, 295, -1, 294, 293, -1, 117, -1, 99,
1755  -1, 302, -1, 309, -1, 304, -1, 280, 297, 280,
1756  -1, 73, -1, 78, -1, 74, -1, 75, -1, 76,
1757  -1, 77, -1, 280, 299, 280, -1, 61, -1, 105,
1758  -1, 72, -1, 80, -1, 93, -1, 96, -1, 280,
1759  301, 280, -1, 88, -1, 121, -1, 68, -1, 303,
1760  218, -1, 161, -1, 161, 145, -1, 161, 90, -1,
1761  306, 305, -1, 42, 43, -1, 42, 225, 43, -1,
1762  306, 307, -1, 307, -1, 120, 402, 308, 119, -1,
1763  -1, 404, -1, 139, 310, -1, 140, 310, -1, 139,
1764  -1, 310, -1, 311, -1, 310, 321, 311, -1, 310,
1765  321, 142, 246, 131, 311, 60, -1, 310, 140, 311,
1766  -1, 322, -1, 336, -1, 168, 218, -1, -1, 151,
1767  312, 218, -1, 26, 404, 42, 225, 43, -1, -1,
1768  44, 104, 7, 73, 3, 42, 313, 225, 43, -1,
1769  30, 397, 95, 314, 132, -1, -1, 315, 316, -1,
1770  -1, 318, -1, 316, 37, 318, -1, -1, 95, 316,
1771  132, -1, 319, 52, 341, 377, 320, -1, -1, 157,
1772  -1, -1, 20, 227, -1, 139, -1, 97, -1, 69,
1773  -1, 323, -1, 322, 91, 225, 130, -1, 324, -1,
1774  331, -1, -1, 327, 325, 326, -1, 329, -1, 333,
1775  -1, 389, -1, 328, 36, -1, 14, -1, 13, -1,
1776  23, -1, 34, -1, 47, -1, 46, -1, 66, -1,
1777  122, -1, 67, -1, 123, -1, 115, -1, 137, -1,
1778  -1, 22, 330, 333, -1, 333, -1, 389, -1, 332,
1779  -1, 54, -1, 334, -1, 382, -1, 397, -1, 335,
1780  -1, 144, -1, 9, -1, 10, -1, 337, -1, 336,
1781  91, 225, 130, -1, 338, -1, 340, -1, 342, -1,
1782  343, -1, 345, -1, 344, -1, 347, -1, 17, 229,
1783  95, 314, 132, -1, 339, -1, 404, -1, 12, -1,
1784  11, -1, 52, 341, -1, 7, -1, 405, -1, 95,
1785  225, 132, -1, 95, 132, -1, 53, -1, 194, 218,
1786  -1, 399, 95, 346, 132, -1, -1, 227, -1, 226,
1787  -1, 348, -1, 360, -1, 349, -1, 358, -1, 359,
1788  -1, -1, -1, 77, 401, 350, 353, 351, 118, 353,
1789  352, -1, 128, -1, 75, 357, 27, 397, 75, -1,
1790  -1, 353, 354, -1, 401, 73, 355, -1, 129, 356,
1791  129, -1, 16, 356, 16, -1, -1, 218, 356, -1,
1792  404, 356, -1, -1, 357, 348, -1, 357, 404, -1,
1793  357, 4, -1, 357, 218, -1, 39, 148, -1, 116,
1794  150, 149, -1, 361, -1, 362, -1, 365, -1, 366,
1795  -1, 367, -1, 368, -1, 375, -1, 50, 364, 218,
1796  -1, -1, 55, 364, 372, 363, 305, -1, -1, 166,
1797  -1, 23, 364, 369, 305, -1, 153, 364, 218, -1,
1798  38, 364, 218, -1, 126, 374, 305, -1, -1, -1,
1799  370, 397, 371, -1, 373, -1, 397, -1, 373, -1,
1800  218, -1, 7, -1, 218, -1, 104, 218, 218, -1,
1801  381, -1, 381, 127, -1, -1, 18, 378, -1, 380,
1802  379, -1, 58, 395, -1, -1, 117, -1, 144, -1,
1803  127, -1, 381, -1, 382, -1, 389, -1, 89, 395,
1804  -1, 397, -1, 384, -1, 392, -1, 394, -1, 388,
1805  -1, 387, -1, 386, -1, 383, -1, 106, 395, -1,
1806  51, 395, -1, 51, 95, 385, 132, -1, 392, -1,
1807  394, -1, 153, 395, -1, 38, 395, -1, 126, 395,
1808  -1, 126, 95, 7, 132, -1, 126, 95, 404, 132,
1809  -1, 390, -1, 391, -1, 23, 395, -1, 23, 95,
1810  144, 132, -1, 23, 95, 396, 132, -1, 23, 95,
1811  396, 37, 398, 132, -1, 23, 95, 144, 37, 398,
1812  132, -1, 134, 95, 397, 132, -1, 55, 395, -1,
1813  55, 95, 144, 132, -1, 55, 95, 397, 132, -1,
1814  55, 95, 397, 37, 398, 393, 132, -1, 55, 95,
1815  144, 37, 398, 393, 132, -1, -1, 127, -1, 135,
1816  95, 397, 132, -1, 95, 132, -1, 7, -1, 405,
1817  -1, 7, -1, 405, -1, 397, -1, 400, -1, 405,
1818  -1, 7, -1, 167, 7, -1, 7, -1, 6, -1,
1819  7, -1, 405, -1, 404, -1, 3, -1, 5, -1,
1820  6, -1, 8, -1
1821 };
1822 
1823 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
1824 static const yytype_uint16 yyrline[] =
1825 {
1826  0, 1375, 1375, 1376, 1378, 1379, 1410, 1411, 1427, 1525,
1827  1527, 1533, 1535, 1542, 1548, 1554, 1561, 1564, 1568, 1572,
1828  1592, 1606, 1610, 1604, 1673, 1677, 1694, 1697, 1699, 1704,
1829  1705, 1709, 1710, 1714, 1718, 1722, 1724, 1725, 1727, 1729,
1830  1775, 1789, 1794, 1799, 1800, 1802, 1817, 1832, 1842, 1857,
1831  1861, 1866, 1880, 1884, 1889, 1903, 1908, 1913, 1918, 1923,
1832  1939, 1962, 1970, 1971, 1972, 1974, 1991, 1992, 1994, 1995,
1833  1997, 1998, 2000, 2055, 2059, 2065, 2068, 2073, 2087, 2091,
1834  2097, 2096, 2205, 2208, 2214, 2235, 2241, 2245, 2247, 2252,
1835  2262, 2263, 2268, 2269, 2278, 2348, 2359, 2360, 2364, 2369,
1836  2438, 2439, 2443, 2448, 2492, 2493, 2498, 2505, 2511, 2512,
1837  2513, 2514, 2515, 2516, 2522, 2527, 2533, 2536, 2541, 2547,
1838  2553, 2557, 2582, 2583, 2587, 2591, 2585, 2632, 2635, 2630,
1839  2651, 2652, 2653, 2656, 2660, 2668, 2667, 2681, 2680, 2689,
1840  2690, 2691, 2693, 2701, 2712, 2715, 2717, 2722, 2729, 2736,
1841  2742, 2762, 2767, 2773, 2776, 2778, 2779, 2786, 2792, 2796,
1842  2801, 2802, 2805, 2809, 2804, 2819, 2823, 2818, 2831, 2834,
1843  2838, 2833, 2848, 2852, 2847, 2860, 2862, 2890, 2889, 2901,
1844  2909, 2900, 2920, 2921, 2924, 2928, 2933, 2938, 2937, 2953,
1845  2959, 2960, 2966, 2967, 2973, 2974, 2975, 2976, 2978, 2979,
1846  2985, 2986, 2992, 2993, 2995, 2996, 3002, 3003, 3004, 3005,
1847  3007, 3008, 3018, 3019, 3025, 3026, 3028, 3032, 3037, 3038,
1848  3045, 3046, 3052, 3053, 3059, 3060, 3066, 3067, 3073, 3077,
1849  3082, 3083, 3084, 3086, 3092, 3093, 3094, 3095, 3096, 3097,
1850  3099, 3104, 3105, 3106, 3107, 3108, 3109, 3111, 3116, 3117,
1851  3118, 3120, 3134, 3135, 3136, 3138, 3155, 3159, 3164, 3165,
1852  3167, 3172, 3173, 3175, 3181, 3185, 3191, 3194, 3195, 3199,
1853  3208, 3213, 3217, 3218, 3223, 3222, 3237, 3245, 3244, 3260,
1854  3268, 3268, 3277, 3279, 3282, 3287, 3289, 3293, 3359, 3362,
1855  3368, 3371, 3380, 3384, 3388, 3393, 3394, 3399, 3400, 3403,
1856  3402, 3432, 3434, 3435, 3437, 3481, 3482, 3483, 3484, 3485,
1857  3486, 3487, 3488, 3489, 3490, 3491, 3492, 3495, 3494, 3505,
1858  3516, 3521, 3523, 3528, 3529, 3534, 3538, 3540, 3544, 3553,
1859  3560, 3561, 3567, 3568, 3569, 3570, 3571, 3572, 3573, 3574,
1860  3584, 3585, 3590, 3595, 3601, 3607, 3612, 3617, 3622, 3628,
1861  3633, 3638, 3668, 3672, 3679, 3681, 3685, 3690, 3691, 3692,
1862  3726, 3735, 3724, 3976, 3980, 4000, 4003, 4009, 4014, 4019,
1863  4025, 4028, 4038, 4045, 4049, 4055, 4069, 4075, 4092, 4097,
1864  4110, 4111, 4112, 4113, 4114, 4115, 4116, 4118, 4126, 4125,
1865  4165, 4168, 4173, 4188, 4193, 4200, 4212, 4216, 4212, 4222,
1866  4224, 4228, 4230, 4245, 4249, 4258, 4263, 4267, 4273, 4276,
1867  4281, 4286, 4291, 4292, 4293, 4294, 4296, 4297, 4298, 4299,
1868  4304, 4340, 4341, 4342, 4343, 4344, 4345, 4346, 4348, 4353,
1869  4358, 4364, 4365, 4367, 4372, 4377, 4382, 4387, 4403, 4404,
1870  4406, 4411, 4416, 4420, 4432, 4445, 4455, 4460, 4465, 4470,
1871  4484, 4498, 4499, 4501, 4511, 4513, 4518, 4525, 4532, 4534,
1872  4536, 4537, 4539, 4543, 4548, 4549, 4551, 4557, 4559, 4561,
1873  4565, 4570, 4582
1874 };
1875 #endif
1876 
1877 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1878 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1879  First, the terminals, then, starting at YYNTOKENS, nonterminals. */
1880 static const char *const yytname[] =
1881 {
1882  "\"end of file\"", "error", "$undefined", "\"<string literal>\"",
1883  "\"<non-boundary text node>\"", "\"<string literal(XPath 2.0)>\"",
1884  "\"QName\"", "\"NCName\"", "\"ClarkName\"", "ANY_LOCAL_NAME",
1885  "ANY_PREFIX", "\"<number literal>\"", "\"<number literal(XPath 2.0)>\"",
1886  "\"ancestor\"", "\"ancestor-or-self\"", "\"and\"", "\"'\"",
1887  "\"apply-template\"", "\"as\"", "\"ascending\"", "\":=\"", "\"at\"",
1888  "\"@\"", "\"attribute\"", "AVT", "\"|\"", "\"base-uri\"", "\"</\"",
1889  "\"boundary-space\"", "\"by\"", "\"call-template\"", "\"case\"",
1890  "\"castable\"", "\"cast\"", "\"child\"", "\"collation\"", "\"::\"",
1891  "\",\"", "\"comment\"", "\"<!--\"", "\"construction\"",
1892  "\"copy-namespaces\"", "\"{\"", "\"}\"", "\"declare\"", "\"default\"",
1893  "\"descendant\"", "\"descendant-or-self\"", "\"descending\"", "\"div\"",
1894  "\"document\"", "\"document-node\"", "\"$\"", "\".\"", "\"..\"",
1895  "\"element\"", "\"else\"", "\"empty\"", "\"empty-sequence\"",
1896  "\"encoding\"", "\"end_sort\"", "\"eq\"", "\"unknown keyword\"",
1897  "\"every\"", "\"except\"", "\"external\"", "\"following\"",
1898  "\"following-sibling\"", "\">>\"", "\"for-apply-template\"", "\"for\"",
1899  "\"function\"", "\"ge\"", "\"=\"", "\">=\"", "\">\"", "\"<=\"", "\"<\"",
1900  "\"!=\"", "\"greatest\"", "\"gt\"", "\"idiv\"", "\"if\"", "\"import\"",
1901  "\"inherit\"", "\"in\"", "\"instance\"", "\"intersect\"", "\"is\"",
1902  "\"item\"", "\"lax\"", "\"[\"", "\"least\"", "\"le\"", "\"let\"",
1903  "\"(\"", "\"lt\"", "\"map\"", "\"matches\"", "\"-\"", "\"mode\"",
1904  "\"mod\"", "\"module\"", "\"name\"", "\"namespace\"", "\"ne\"",
1905  "\"node\"", "\"no-inherit\"", "\"no-preserve\"", "\"of\"", "\"option\"",
1906  "\"ordered\"", "\"ordering\"", "\"order\"", "\"or\"", "\"parent\"",
1907  "\"<?\"", "\"+\"", "POSITION_SET", "\"#)\"", "\"(#\"", "\"<<\"",
1908  "\"preceding\"", "\"preceding-sibling\"", "\"preserve\"", "\"priority\"",
1909  "\"processing-instruction\"", "\"?\"", "\"/>\"", "\"\\\"\"", "\"]\"",
1910  "\"return\"", "\")\"", "\"satisfies\"", "\"schema-attribute\"",
1911  "\"schema-element\"", "\"schema\"", "\"self\"", "\";\"", "\"/\"",
1912  "\"//\"", "\"some\"", "\"sort\"", "\"stable\"", "\"*\"", "\"strict\"",
1913  "\"strip\"", "SUCCESS", "COMMENT_CONTENT", "PI_CONTENT", "PI_TARGET",
1914  "XSLT_VERSION", "\"template\"", "\"text\"", "\"then\"", "\"to\"",
1915  "\"treat\"", "\"tunnel\"", "\"typeswitch\"", "\"union\"",
1916  "\"unordered\"", "\"validate\"", "\"variable\"", "\"version\"",
1917  "\"where\"", "\"xquery\"", "\"internal\"", "\"internal-name\"",
1918  "\"current\"", "$accept", "Module", "VersionDecl", "Encoding",
1919  "MainModule", "LibraryModule", "ModuleDecl", "Prolog", "TemplateDecl",
1920  "@1", "@2", "OptionalPriority", "OptionalTemplateName", "TemplateName",
1921  "Setter", "Import", "Separator", "NamespaceDecl", "BoundarySpaceDecl",
1922  "BoundarySpacePolicy", "DefaultNamespaceDecl",
1923  "DeclareDefaultElementNamespace", "DeclareDefaultFunctionNamespace",
1924  "OptionDecl", "OrderingModeDecl", "OrderingMode", "EmptyOrderDecl",
1925  "OrderingEmptySequence", "CopyNamespacesDecl", "PreserveMode",
1926  "InheritMode", "DefaultCollationDecl", "BaseURIDecl", "SchemaImport",
1927  "SchemaPrefix", "ModuleImport", "ModuleNamespaceDecl", "FileLocations",
1928  "FileLocation", "VarDecl", "VariableValue", "OptionalDefaultValue",
1929  "ConstructionDecl", "ConstructionMode", "FunctionDecl", "@3",
1930  "ParamList", "Param", "FunctionBody", "EnclosedExpr", "QueryBody",
1931  "Pattern", "PathPattern", "IdKeyPattern", "RelativePathPattern",
1932  "PatternStep", "Expr", "ExpressionSequence", "ExprSingle",
1933  "OptionalModes", "OptionalMode", "Modes", "Mode", "FLWORExpr",
1934  "ForClause", "@4", "@5", "ForTail", "@6", "@7", "PositionalVar",
1935  "LetClause", "@8", "LetTail", "@9", "WhereClause", "OrderByClause",
1936  "MandatoryOrderByClause", "OrderSpecList", "OrderSpec",
1937  "DirectionModifier", "EmptynessModifier", "CollationModifier",
1938  "OrderByInputOrder", "QuantifiedExpr", "SomeQuantificationExpr", "@10",
1939  "@11", "SomeQuantificationTail", "@12", "@13", "EveryQuantificationExpr",
1940  "@14", "@15", "EveryQuantificationTail", "@16", "@17", "SatisfiesClause",
1941  "TypeswitchExpr", "@18", "CaseClause", "@19", "@20", "CaseTail",
1942  "CaseVariable", "CaseDefault", "@21", "IfExpr", "OrExpr", "AndExpr",
1943  "ComparisonExpr", "RangeExpr", "AdditiveExpr", "AdditiveOperator",
1944  "MultiplicativeExpr", "MultiplyOperator", "UnionExpr",
1945  "IntersectExceptExpr", "UnionOperator", "IntersectOperator",
1946  "InstanceOfExpr", "TreatExpr", "CastableExpr", "CastExpr", "UnaryExpr",
1947  "UnaryOperator", "ValueExpr", "GeneralComp", "GeneralComparisonOperator",
1948  "ValueComp", "ValueComparisonOperator", "NodeComp", "NodeOperator",
1949  "ValidateExpr", "ValidationMode", "ExtensionExpr",
1950  "EnclosedOptionalExpr", "Pragmas", "Pragma", "PragmaContents",
1951  "PathExpr", "RelativePathExpr", "StepExpr", "@22", "@23",
1952  "TemplateWithParameters", "@24", "TemplateParameters",
1953  "OptionalTemplateParameters", "TemplateParameter", "IsTunnel",
1954  "OptionalAssign", "MapOrSlash", "FilteredAxisStep", "AxisStep",
1955  "ForwardStep", "@25", "NodeTestInAxisStep", "Axis", "AxisToken",
1956  "AbbrevForwardStep", "@26", "ReverseStep", "AbbrevReverseStep",
1957  "NodeTest", "NameTest", "WildCard", "FilterExpr", "PrimaryExpr",
1958  "Literal", "NumericLiteral", "VarRef", "VarName", "ParenthesizedExpr",
1959  "ContextItemExpr", "OrderingExpr", "FunctionCallExpr",
1960  "FunctionArguments", "Constructor", "DirectConstructor",
1961  "DirElemConstructor", "@27", "@28", "DirElemConstructorTail",
1962  "DirAttributeList", "Attribute", "DirAttributeValue", "AttrValueContent",
1963  "DirElemContent", "DirCommentConstructor", "DirPIConstructor",
1964  "ComputedConstructor", "CompDocConstructor", "CompElemConstructor",
1965  "@29", "IsInternal", "CompAttrConstructor", "CompTextConstructor",
1966  "CompCommentConstructor", "CompPIConstructor", "CompAttributeName",
1967  "@30", "@31", "CompElementName", "CompNameExpr", "CompPIName",
1968  "CompNamespaceConstructor", "SingleType", "TypeDeclaration",
1969  "SequenceType", "OccurrenceIndicator", "ItemType", "AtomicType",
1970  "KindTest", "AnyKindTest", "DocumentTest", "AnyElementTest", "TextTest",
1971  "CommentTest", "PITest", "AnyAttributeTest", "AttributeTest",
1972  "SchemaAttributeTest", "ElementTest", "OptionalQuestionMark",
1973  "SchemaElementTest", "EmptyParanteses", "AttributeName", "ElementName",
1974  "TypeName", "FunctionName", "NCName", "LexicalName", "PragmaName",
1975  "URILiteral", "StringLiteral", "QName", 0
1976 };
1977 #endif
1978 
1979 # ifdef YYPRINT
1980 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
1981  token YYLEX-NUM. */
1982 static const yytype_uint16 yytoknum[] =
1983 {
1984  0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1985  265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1986  275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
1987  285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
1988  295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
1989  305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
1990  315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
1991  325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
1992  335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
1993  345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
1994  355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
1995  365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
1996  375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
1997  385, 386, 387, 388, 389, 390, 391, 392, 393, 394,
1998  395, 396, 397, 398, 399, 400, 401, 402, 403, 404,
1999  405, 406, 407, 408, 409, 410, 411, 412, 413, 414,
2000  415, 416, 417, 418, 419, 420, 421, 422, 423
2001 };
2002 # endif
2003 
2004 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
2005 static const yytype_uint16 yyr1[] =
2006 {
2007  0, 169, 170, 170, 171, 171, 172, 172, 173, 174,
2008  175, 176, 176, 176, 176, 176, 176, 176, 176, 176,
2009  177, 178, 179, 177, 180, 180, 181, 181, 182, 183,
2010  183, 183, 183, 183, 183, 183, 184, 184, 185, 186,
2011  187, 188, 188, 189, 189, 190, 191, 192, 193, 194,
2012  194, 195, 196, 196, 197, 198, 198, 199, 199, 200,
2013  201, 202, 203, 203, 203, 204, 205, 205, 206, 206,
2014  207, 207, 208, 209, 209, 210, 210, 211, 212, 212,
2015  214, 213, 215, 215, 215, 216, 217, 217, 218, 219,
2016  220, 220, 221, 221, 221, 221, 221, 221, 221, 222,
2017  223, 223, 223, 224, 225, 225, 226, 226, 227, 227,
2018  227, 227, 227, 227, 228, 228, 229, 229, 230, 230,
2019  231, 231, 232, 232, 234, 235, 233, 237, 238, 236,
2020  236, 236, 236, 239, 239, 241, 240, 243, 242, 242,
2021  242, 242, 244, 244, 245, 245, 246, 247, 247, 248,
2022  249, 249, 249, 250, 250, 251, 251, 251, 252, 252,
2023  253, 253, 255, 256, 254, 258, 259, 257, 257, 261,
2024  262, 260, 264, 265, 263, 263, 266, 268, 267, 270,
2025  271, 269, 272, 272, 273, 273, 274, 275, 274, 276,
2026  277, 277, 278, 278, 279, 279, 279, 279, 280, 280,
2027  281, 281, 282, 282, 283, 283, 284, 284, 284, 284,
2028  285, 285, 286, 286, 287, 287, 288, 288, 289, 289,
2029  290, 290, 291, 291, 292, 292, 293, 293, 294, 294,
2030  295, 295, 295, 296, 297, 297, 297, 297, 297, 297,
2031  298, 299, 299, 299, 299, 299, 299, 300, 301, 301,
2032  301, 302, 303, 303, 303, 304, 305, 305, 306, 306,
2033  307, 308, 308, 309, 309, 309, 309, 310, 310, 310,
2034  310, 311, 311, 311, 312, 311, 311, 313, 311, 311,
2035  315, 314, 316, 316, 316, 317, 317, 318, 319, 319,
2036  320, 320, 321, 321, 321, 322, 322, 323, 323, 325,
2037  324, 324, 326, 326, 327, 328, 328, 328, 328, 328,
2038  328, 328, 328, 328, 328, 328, 328, 330, 329, 329,
2039  329, 331, 332, 333, 333, 334, 334, 335, 335, 335,
2040  336, 336, 337, 337, 337, 337, 337, 337, 337, 337,
2041  338, 338, 339, 339, 340, 341, 341, 342, 342, 343,
2042  344, 345, 346, 346, 346, 347, 347, 348, 348, 348,
2043  350, 351, 349, 352, 352, 353, 353, 354, 355, 355,
2044  356, 356, 356, 357, 357, 357, 357, 357, 358, 359,
2045  360, 360, 360, 360, 360, 360, 360, 361, 363, 362,
2046  364, 364, 365, 366, 367, 368, 370, 371, 369, 369,
2047  372, 372, 373, 374, 374, 375, 376, 376, 377, 377,
2048  378, 378, 379, 379, 379, 379, 380, 380, 380, 380,
2049  381, 382, 382, 382, 382, 382, 382, 382, 383, 384,
2050  384, 385, 385, 386, 387, 388, 388, 388, 389, 389,
2051  390, 390, 390, 390, 390, 391, 392, 392, 392, 392,
2052  392, 393, 393, 394, 395, 396, 396, 397, 397, 398,
2053  399, 399, 400, 400, 401, 401, 402, 402, 403, 404,
2054  404, 405, 405
2055 };
2056 
2057 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
2058 static const yytype_uint8 yyr2[] =
2059 {
2060  0, 2, 2, 2, 0, 5, 0, 2, 2, 2,
2061  6, 0, 2, 2, 2, 2, 2, 2, 2, 2,
2062  7, 0, 0, 15, 0, 2, 0, 1, 2, 1,
2063  1, 1, 1, 1, 1, 1, 1, 1, 1, 7,
2064  4, 1, 1, 1, 1, 6, 6, 5, 4, 1,
2065  1, 5, 2, 2, 6, 1, 1, 1, 1, 5,
2066  5, 6, 0, 3, 3, 6, 0, 3, 0, 2,
2067  1, 3, 9, 1, 2, 0, 2, 4, 1, 1,
2068  0, 11, 0, 1, 3, 3, 1, 1, 3, 1,
2069  1, 3, 1, 1, 2, 2, 1, 3, 3, 1,
2070  1, 3, 3, 1, 1, 1, 3, 3, 1, 1,
2071  1, 1, 1, 4, 0, 2, 0, 2, 1, 3,
2072  1, 1, 1, 1, 0, 0, 10, 0, 0, 10,
2073  1, 1, 1, 0, 3, 0, 9, 0, 8, 1,
2074  1, 1, 3, 5, 0, 1, 2, 3, 1, 4,
2075  0, 1, 1, 0, 1, 0, 2, 3, 3, 2,
2076  1, 1, 0, 0, 9, 0, 0, 9, 1, 0,
2077  0, 9, 0, 0, 9, 1, 2, 0, 6, 0,
2078  0, 8, 1, 1, 0, 3, 3, 0, 6, 8,
2079  1, 3, 1, 3, 1, 1, 1, 1, 1, 3,
2080  1, 3, 1, 1, 1, 3, 1, 1, 1, 1,
2081  1, 3, 1, 3, 1, 1, 1, 1, 1, 4,
2082  1, 4, 1, 4, 1, 4, 1, 2, 1, 1,
2083  1, 1, 1, 3, 1, 1, 1, 1, 1, 1,
2084  3, 1, 1, 1, 1, 1, 1, 3, 1, 1,
2085  1, 2, 1, 2, 2, 2, 2, 3, 2, 1,
2086  4, 0, 1, 2, 2, 1, 1, 1, 3, 7,
2087  3, 1, 1, 2, 0, 3, 5, 0, 9, 5,
2088  0, 2, 0, 1, 3, 0, 3, 5, 0, 1,
2089  0, 2, 1, 1, 1, 1, 4, 1, 1, 0,
2090  3, 1, 1, 1, 2, 1, 1, 1, 1, 1,
2091  1, 1, 1, 1, 1, 1, 1, 0, 3, 1,
2092  1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2093  1, 4, 1, 1, 1, 1, 1, 1, 1, 5,
2094  1, 1, 1, 1, 2, 1, 1, 3, 2, 1,
2095  2, 4, 0, 1, 1, 1, 1, 1, 1, 1,
2096  0, 0, 8, 1, 5, 0, 2, 3, 3, 3,
2097  0, 2, 2, 0, 2, 2, 2, 2, 2, 3,
2098  1, 1, 1, 1, 1, 1, 1, 3, 0, 5,
2099  0, 1, 4, 3, 3, 3, 0, 0, 3, 1,
2100  1, 1, 1, 1, 1, 3, 1, 2, 0, 2,
2101  2, 2, 0, 1, 1, 1, 1, 1, 1, 2,
2102  1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
2103  4, 1, 1, 2, 2, 2, 4, 4, 1, 1,
2104  2, 4, 4, 6, 6, 4, 2, 4, 4, 7,
2105  7, 0, 1, 4, 2, 1, 1, 1, 1, 1,
2106  1, 1, 1, 2, 1, 1, 1, 1, 1, 1,
2107  1, 1, 1
2108 };
2109 
2110 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
2111  STATE-NUM when YYTABLE doesn't specify something else to do. Zero
2112  means the default is an error. */
2113 static const yytype_uint16 yydefact[] =
2114 {
2115  4, 0, 0, 11, 0, 1, 0, 3, 2, 11,
2116  0, 469, 470, 6, 0, 9, 471, 457, 472, 328,
2117  329, 343, 342, 306, 305, 116, 317, 390, 0, 0,
2118  0, 308, 390, 0, 0, 310, 309, 390, 0, 0,
2119  349, 322, 390, 0, 311, 313, 0, 0, 0, 0,
2120  390, 0, 229, 0, 0, 49, 315, 0, 228, 0,
2121  312, 314, 0, 0, 0, 316, 265, 0, 0, 327,
2122  274, 390, 0, 50, 252, 0, 0, 16, 13, 15,
2123  14, 29, 12, 43, 44, 19, 33, 0, 34, 35,
2124  30, 31, 36, 37, 17, 32, 18, 8, 89, 105,
2125  104, 109, 122, 123, 110, 160, 161, 111, 112, 108,
2126  190, 192, 194, 198, 200, 204, 210, 212, 218, 220,
2127  222, 224, 0, 226, 196, 195, 197, 230, 0, 232,
2128  0, 259, 231, 266, 267, 271, 295, 297, 299, 0,
2129  301, 298, 321, 319, 323, 326, 272, 330, 332, 340,
2130  333, 334, 335, 337, 336, 338, 355, 357, 358, 359,
2131  356, 380, 381, 382, 383, 384, 385, 386, 324, 427,
2132  421, 426, 425, 424, 320, 438, 439, 422, 423, 325,
2133  0, 460, 341, 458, 0, 0, 0, 0, 0, 0,
2134  0, 0, 391, 396, 440, 370, 0, 457, 0, 458,
2135  0, 0, 434, 378, 390, 0, 0, 0, 0, 390,
2136  0, 0, 0, 26, 390, 0, 0, 429, 345, 344,
2137  346, 0, 0, 446, 0, 0, 465, 464, 360, 0,
2138  66, 62, 0, 0, 348, 0, 0, 0, 428, 0,
2139  466, 261, 467, 403, 0, 404, 0, 435, 0, 0,
2140  263, 264, 0, 0, 0, 433, 0, 254, 253, 463,
2141  273, 350, 0, 0, 0, 0, 241, 250, 243, 234,
2142  236, 237, 238, 239, 235, 244, 248, 245, 246, 242,
2143  249, 0, 0, 0, 203, 202, 0, 0, 207, 208,
2144  209, 206, 0, 215, 214, 0, 217, 216, 0, 0,
2145  0, 0, 0, 227, 251, 0, 255, 258, 294, 293,
2146  292, 0, 0, 0, 0, 304, 0, 352, 7, 38,
2147  5, 0, 0, 121, 117, 120, 280, 0, 0, 0,
2148  0, 318, 455, 454, 0, 0, 456, 402, 0, 0,
2149  399, 370, 0, 370, 0, 280, 394, 0, 42, 41,
2150  0, 79, 78, 0, 56, 55, 0, 0, 0, 0,
2151  0, 0, 0, 0, 0, 0, 0, 285, 0, 387,
2152  0, 431, 432, 0, 0, 388, 401, 400, 408, 408,
2153  365, 0, 0, 0, 0, 0, 0, 0, 0, 347,
2154  0, 405, 379, 0, 262, 0, 0, 395, 0, 0,
2155  408, 275, 393, 0, 107, 106, 191, 193, 233, 240,
2156  247, 199, 201, 205, 211, 213, 0, 0, 0, 0,
2157  256, 0, 270, 0, 268, 0, 0, 300, 302, 303,
2158  0, 354, 353, 0, 0, 468, 0, 0, 282, 0,
2159  441, 0, 442, 392, 397, 371, 113, 372, 0, 0,
2160  0, 40, 77, 0, 0, 0, 0, 0, 0, 462,
2161  0, 461, 0, 0, 48, 28, 0, 282, 408, 0,
2162  430, 0, 447, 0, 448, 0, 0, 0, 133, 361,
2163  0, 0, 68, 0, 0, 68, 408, 0, 88, 260,
2164  436, 437, 445, 453, 0, 177, 0, 0, 219, 412,
2165  416, 417, 418, 420, 221, 223, 406, 225, 257, 0,
2166  0, 0, 0, 296, 331, 351, 10, 0, 339, 289,
2167  281, 283, 0, 459, 0, 0, 398, 276, 279, 60,
2168  57, 58, 0, 59, 0, 0, 53, 52, 51, 82,
2169  469, 390, 47, 21, 0, 0, 408, 451, 451, 389,
2170  409, 0, 0, 0, 0, 366, 0, 0, 67, 0,
2171  0, 63, 64, 0, 0, 0, 0, 0, 411, 419,
2172  413, 415, 414, 410, 407, 159, 0, 0, 150, 146,
2173  148, 288, 0, 444, 443, 54, 45, 46, 0, 0,
2174  83, 277, 0, 0, 286, 0, 0, 452, 0, 0,
2175  169, 0, 0, 365, 0, 0, 69, 70, 65, 61,
2176  0, 0, 162, 184, 178, 158, 0, 151, 152, 153,
2177  0, 284, 408, 408, 0, 80, 0, 39, 307, 93,
2178  0, 22, 90, 96, 92, 100, 103, 99, 20, 0,
2179  73, 75, 450, 449, 170, 134, 124, 0, 370, 370,
2180  367, 0, 0, 135, 163, 0, 0, 269, 154, 155,
2181  147, 290, 85, 84, 408, 0, 94, 95, 0, 0,
2182  0, 0, 0, 0, 74, 0, 0, 0, 125, 373,
2183  363, 362, 0, 0, 189, 71, 144, 0, 0, 179,
2184  0, 0, 149, 0, 287, 0, 278, 91, 114, 97,
2185  98, 101, 102, 76, 72, 0, 0, 171, 175, 144,
2186  0, 369, 368, 0, 0, 140, 141, 136, 139, 0,
2187  145, 0, 164, 168, 185, 0, 156, 0, 291, 86,
2188  0, 87, 0, 24, 0, 176, 0, 131, 126, 132,
2189  130, 376, 0, 377, 374, 375, 0, 144, 0, 0,
2190  0, 157, 81, 115, 118, 0, 285, 408, 0, 0,
2191  408, 0, 142, 408, 180, 0, 25, 408, 0, 408,
2192  364, 0, 0, 0, 0, 119, 0, 0, 133, 0,
2193  143, 0, 0, 182, 181, 183, 0, 172, 0, 137,
2194  165, 0, 0, 23, 173, 0, 144, 166, 187, 186,
2195  0, 127, 138, 0, 0, 174, 128, 167, 0, 144,
2196  188, 129
2197 };
2198 
2199 /* YYDEFGOTO[NTERM-NUM]. */
2200 static const yytype_int16 yydefgoto[] =
2201 {
2202  -1, 2, 3, 185, 7, 8, 9, 10, 77, 593,
2203  669, 756, 366, 367, 78, 79, 320, 80, 81, 350,
2204  82, 83, 84, 85, 86, 87, 88, 458, 89, 356,
2205  532, 90, 91, 92, 386, 93, 383, 560, 606, 94,
2206  641, 676, 95, 353, 96, 664, 589, 590, 730, 341,
2207  97, 631, 632, 633, 634, 635, 98, 99, 100, 733,
2208  189, 753, 324, 101, 102, 678, 709, 738, 806, 809,
2209  553, 103, 686, 717, 796, 718, 719, 720, 579, 580,
2210  619, 659, 692, 512, 104, 105, 654, 687, 722, 797,
2211  803, 106, 644, 677, 707, 794, 800, 708, 107, 567,
2212  614, 725, 774, 784, 656, 785, 804, 108, 109, 110,
2213  111, 112, 113, 287, 114, 292, 115, 116, 295, 298,
2214  117, 118, 119, 120, 121, 122, 123, 124, 281, 125,
2215  282, 126, 283, 127, 128, 129, 306, 130, 131, 393,
2216  132, 133, 134, 253, 626, 437, 438, 520, 468, 521,
2217  522, 694, 312, 135, 136, 137, 314, 427, 138, 139,
2218  140, 190, 141, 142, 143, 144, 145, 146, 147, 148,
2219  149, 150, 219, 151, 152, 153, 154, 433, 155, 156,
2220  157, 380, 554, 681, 479, 555, 650, 342, 710, 158,
2221  159, 160, 161, 162, 475, 193, 163, 164, 165, 166,
2222  338, 339, 526, 375, 340, 246, 167, 505, 477, 498,
2223  573, 499, 500, 168, 169, 170, 370, 171, 172, 173,
2224  174, 175, 176, 177, 598, 178, 194, 335, 179, 524,
2225  180, 181, 556, 241, 541, 182, 183
2226 };
2227 
2228 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
2229  STATE-NUM. */
2230 #define YYPACT_NINF -668
2231 static const yytype_int16 yypact[] =
2232 {
2233  -63, -28, 185, 86, 337, -668, 117, -668, -668, -668,
2234  734, -668, -668, 181, 253, 156, -668, 213, -668, -668,
2235  -668, -668, -668, -668, -668, 212, -668, -12, 230, 337,
2236  342, -668, -38, 189, 298, -668, -668, 188, 272, 353,
2237  -668, -668, 71, 316, -668, -668, 318, 239, 276, 134,
2238  188, 900, -668, 334, 282, -668, -668, 233, -668, 367,
2239  -668, -668, 133, 290, 295, -668, 1730, 1730, 345, -668,
2240  -668, -38, 305, -668, -36, 396, 334, -668, -668, -668,
2241  -668, -668, -668, -668, -668, -668, -668, 334, -668, -668,
2242  -668, -668, -668, -668, -668, -668, -668, -668, -668, 369,
2243  370, -668, -668, -668, -668, -668, -668, -668, -668, 307,
2244  389, -668, 601, 173, 24, -22, 32, -668, 338, 267,
2245  393, 394, 1398, -668, -668, -668, -668, -668, 334, -668,
2246  59, -668, -668, 166, -668, 339, -668, -668, -668, 395,
2247  -668, -668, -668, -668, -668, -668, 341, -668, -668, -668,
2248  -668, -668, -668, -668, -668, -668, -668, -668, -668, -668,
2249  -668, -668, -668, -668, -668, -668, -668, -668, -668, -668,
2250  -668, -668, -668, -668, -668, -668, -668, -668, -668, -668,
2251  340, -668, -668, 347, 337, 291, 360, 493, 373, 349,
2252  1885, 64, -668, 334, -668, 226, 392, -668, 358, -668,
2253  304, 334, -668, -668, 188, 167, 174, 206, 21, 188,
2254  430, 342, -53, 351, 188, 334, 6, -668, -668, -668,
2255  -668, 79, 287, -668, 353, 353, -668, -668, -668, 1232,
2256  336, 18, 403, 344, -668, 324, 1232, 334, -668, 308,
2257  -668, 337, -668, -668, 23, -668, 416, -668, 342, 342,
2258  166, 166, 353, 334, 334, -668, 1232, -668, -668, -668,
2259  -668, -668, 1232, 1232, 1398, 1398, -668, -668, -668, -668,
2260  -668, -668, -668, -668, -668, -668, -668, -668, -668, -668,
2261  -668, 1398, 1398, 1398, -668, -668, 1398, 1398, -668, -668,
2262  -668, -668, 1398, -668, -668, 1398, -668, -668, 1398, 352,
2263  447, 448, 449, -668, -668, 1066, -668, -668, -668, -668,
2264  -668, 1730, 1564, 1232, 108, -668, 1232, 1232, -668, -668,
2265  -668, 337, 461, -668, -668, -668, -668, 282, 374, 378,
2266  282, -668, -668, -668, 0, 51, -668, -668, 416, 342,
2267  -668, 226, 343, 226, 1232, -668, -668, 337, -668, -668,
2268  291, -668, -668, 291, -668, -668, 437, 337, 372, 376,
2269  421, 26, 408, 337, 291, 342, 384, -1, 431, -668,
2270  355, -668, -668, 52, 69, -668, -668, -668, 466, 466,
2271  -668, 356, 482, 337, 435, 484, 337, 353, 485, -668,
2272  453, -668, -668, 379, -668, 365, 368, -668, 371, 377,
2273  466, -668, -668, 380, -668, -668, 389, -668, -668, -668,
2274  -668, 168, 24, -22, 32, -668, 456, 456, 342, 342,
2275  -668, 459, -668, 191, -668, 375, 404, -668, -668, -668,
2276  383, 369, 370, 386, 291, -668, 442, 388, -6, 342,
2277  -668, 342, -668, -668, -668, -668, -668, -668, 465, 391,
2278  291, -668, -668, 157, 291, 337, 337, 16, 291, -668,
2279  409, -668, 348, 291, -668, -668, 415, -6, 466, 353,
2280  -668, 342, -668, 342, -668, 416, 456, 440, 495, 239,
2281  381, 454, 507, 425, 457, 507, 466, 463, -668, -668,
2282  -668, -668, -668, -668, 462, -668, 282, 282, -668, 121,
2283  -668, -668, -668, -668, -668, -668, 412, -668, -668, 512,
2284  433, 417, 1232, -668, -668, -668, -668, 337, -668, -668,
2285  513, -668, 497, -668, 422, 423, -668, -668, -668, -668,
2286  -668, -668, 291, -668, 291, 291, -668, -668, -668, 504,
2287  515, 188, -668, -668, 83, 416, 466, 432, 432, -668,
2288  -668, 1232, 508, 476, 450, -668, 492, 1232, -668, 337,
2289  291, -668, -668, 291, 547, 566, 1232, 539, -668, -668,
2290  -668, -668, -668, -668, -668, -668, 543, 1730, 62, 536,
2291  -668, 419, 353, -668, -668, -668, -668, -668, 353, 84,
2292  -668, -668, 291, 1804, -668, 291, 46, -668, 445, 446,
2293  -668, 353, 1232, -668, 33, 524, 550, -668, -668, -668,
2294  1232, 515, -668, 537, -668, -668, 528, -668, -668, 421,
2295  1232, -668, 466, 466, 504, -668, 1232, -668, 404, 1899,
2296  1899, 567, -668, 140, 148, -668, 339, -668, -668, 1232,
2297  -668, 573, -668, -668, -668, -668, -668, 92, 226, 226,
2298  -668, 1232, 337, -668, -668, 342, 456, -668, -668, -23,
2299  -668, 574, -668, -668, 466, 552, 148, 148, 1804, 464,
2300  1899, 1899, 1899, 1899, -668, 1232, 291, 11, -668, -668,
2301  -668, -668, 582, 472, -668, -668, 10, 47, 584, -668,
2302  337, 569, -668, 1232, -668, 234, -668, -668, 506, 148,
2303  148, -668, -668, -668, -668, 555, 1232, -668, -668, 63,
2304  250, -668, -668, 556, 1232, -668, -668, -668, -668, 479,
2305  -668, 559, -668, -668, -668, 481, -668, 1232, -668, -668,
2306  291, -668, 373, 488, 353, -668, 562, -668, -668, -668,
2307  -668, -668, 342, -668, -668, -668, 353, 191, 1232, 353,
2308  1232, -668, -668, 578, -668, 337, 521, 466, 353, 542,
2309  466, 487, -668, 466, -668, 373, -668, 466, 534, 466,
2310  -668, 600, 1232, 538, 125, -668, 416, 1232, 495, 1232,
2311  -668, 1232, -2, -668, -668, -668, 291, -668, 544, -668,
2312  -668, 342, 1232, -668, -668, 1232, 10, -668, -668, -668,
2313  11, -668, -668, 47, 490, -668, -668, -668, 1232, 63,
2314  -668, -668
2315 };
2316 
2317 /* YYPGOTO[NTERM-NUM]. */
2318 static const yytype_int16 yypgoto[] =
2319 {
2320  -668, -668, -668, -668, -668, -668, -668, 613, -668, -668,
2321  -668, -668, -668, -668, -668, -668, -285, -668, -668, -668,
2322  -668, -668, -668, -668, -668, 418, -668, 5, -668, -668,
2323  -668, -668, -668, -668, -668, -668, -668, 142, -668, -668,
2324  -668, -668, -668, -668, -668, -668, -668, 4, -668, -51,
2325  -668, -668, -35, -668, -397, -340, -47, 317, -255, -668,
2326  -668, -668, -641, -668, -619, -668, -668, -174, -668, -668,
2327  -142, -583, -668, -159, -668, -657, -109, 216, -668, 27,
2328  -668, -668, -668, -668, -668, -668, -668, -668, -157, -668,
2329  -668, -668, -668, -668, -152, -668, -668, -667, -668, -668,
2330  -125, -668, -668, -668, -668, -668, -668, -668, -668, 387,
2331  385, 131, 366, -668, 397, -668, 361, 359, -668, -668,
2332  362, -668, -668, -668, 535, -668, -668, -668, -668, -668,
2333  -668, -668, -668, -668, -668, -668, -245, -668, 526, -668,
2334  -668, 279, -294, -668, -668, 313, -668, 194, -91, 85,
2335  -668, -668, -668, -87, -668, -668, -668, -668, -668, -668,
2336  -668, -668, -668, -668, -175, -668, -668, -668, -668, -668,
2337  -668, -668, -183, -668, -668, -668, -538, -668, -668, -42,
2338  -668, -668, -668, -668, 67, -668, -668, -327, -668, -668,
2339  -668, -668, -668, -668, -668, 3, -668, -668, -668, -668,
2340  -668, -668, -668, -668, 458, -668, -668, 252, -341, -412,
2341  -668, -668, -55, -394, -668, -668, -668, -668, -668, -668,
2342  -304, -668, -668, 467, 124, 469, -11, -668, -24, -170,
2343  321, -668, 639, -668, -308, 15, -30
2344 };
2345 
2346 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
2347  positive, shift that token. If negative, reduce the rule which
2348  number is the opposite. If zero, do what YYDEFACT says.
2349  If YYTABLE_NINF, syntax error. */
2350 #define YYTABLE_NINF -463
2351 static const yytype_int16 yytable[] =
2352 {
2353  199, 397, 237, 293, 235, 504, 198, 404, 405, 220,
2354  429, 245, 690, 434, 445, 331, 447, 422, 424, 13,
2355  723, 202, 501, 501, -307, 260, 11, 217, 12, 242,
2356  395, 223, 16, 459, 18, 201, 261, 439, 478, 450,
2357  215, 378, 379, 238, 196, 222, -288, 713, 705, 648,
2358  791, 247, 740, 232, 257, 637, 357, 200, 55, 494,
2359  255, 328, 432, 384, 550, 451, 639, 715, 452, 400,
2360  16, 332, 18, 288, 254, 482, 358, 304, 485, 464,
2361  46, 617, 501, 191, 721, 16, 197, 18, 441, 471,
2362  737, 754, 359, 443, 467, 536, 296, -27, 226, 227,
2363  736, 305, 1, 716, 50, 289, 473, 73, 537, 258,
2364  618, 640, 502, 502, 16, 197, 18, 19, 20, 297,
2365  581, 624, 385, 509, 775, 290, 739, 545, 192, 792,
2366  637, 426, 440, 46, 360, 4, 723, 294, 333, 428,
2367  243, 64, 337, 691, 706, 564, 327, 534, 535, 516,
2368  346, 519, 740, 510, 192, 333, 613, 50, 325, 38,
2369  199, 336, 649, 328, 369, 529, 221, 679, 291, 533,
2370  782, 337, 502, 538, 714, 236, 509, 715, 542, 59,
2371  706, 199, 381, 442, 472, 5, 391, 363, 6, 390,
2372  737, 199, 199, 75, 220, 220, 333, 374, 377, 318,
2373  187, 474, 401, 402, 486, 596, 510, 347, 334, 403,
2374  343, 333, 361, 716, 54, 594, 625, 368, 199, 199,
2375  680, 14, 220, 373, 398, 399, 739, 714, 244, 11,
2376  549, 12, 666, 667, 329, 308, 230, 192, 570, 49,
2377  184, 530, 63, 64, 689, 226, 227, 585, 571, 586,
2378  587, 607, 69, 11, 741, 12, 394, 578, 421, 396,
2379  186, 330, 501, 309, 531, 572, 425, 284, 236, 430,
2380  231, 525, 284, 699, 700, 608, 236, 742, 609, 670,
2381  671, 661, 662, 616, 199, 285, 546, 672, 673, 33,
2382  285, 348, 236, 16, 197, 18, 600, 448, 351, 729,
2383  595, 547, 605, 548, 509, 310, 311, 627, -462, 199,
2384  638, 612, 188, 349, 354, 444, 202, 223, 247, 255,
2385  352, 682, 683, 695, 204, 195, 205, 47, 286, 236,
2386  355, 461, 701, 702, 510, 199, 435, 203, 206, 207,
2387  11, 465, 12, 208, 685, 250, 251, 646, 16, 197,
2388  18, 540, 502, 12, 192, 653, 343, 220, 343, 16,
2389  218, 18, 435, 506, 506, 578, 57, 216, 224, 209,
2390  225, 229, 454, 16, 240, 18, 236, 200, 463, 16,
2391  323, 18, 726, 239, 674, 248, 199, 199, 199, 199,
2392  249, 704, 503, 503, 503, 503, 684, 252, 435, 622,
2393  256, 435, 210, 259, 265, 623, 262, 263, 211, 199,
2394  212, 199, 408, 409, 410, 523, 768, 523, 645, 771,
2395  703, 264, 773, 300, 299, 301, 776, 302, 778, 319,
2396  313, 315, 316, 321, 344, 317, 333, 362, 728, 220,
2397  382, 199, -461, 199, 326, 752, 199, 523, 388, 523,
2398  213, 735, 503, 345, 365, 387, 389, 392, 305, 747,
2399  214, 416, 16, 197, 18, 417, 418, 419, 436, 221,
2400  435, 435, 751, 244, 453, 446, 455, 435, 457, 426,
2401  456, 462, 466, 469, 476, 568, 569, 470, 480, 481,
2402  483, 484, 487, 762, 327, 764, 488, 490, 489, 191,
2403  491, 793, 508, 492, 539, 513, 636, 38, 527, 493,
2404  543, 328, 495, 514, 496, 517, 552, 780, 515, 204,
2405  518, 205, 787, 528, 789, 551, 790, 558, 559, 561,
2406  562, 786, 435, 206, 207, 557, 565, 799, 208, 574,
2407  801, 575, 636, 636, 592, 497, 576, 566, 577, 582,
2408  581, 757, 220, 810, 583, 584, 588, 591, 220, 597,
2409  601, 602, 54, 760, 209, 604, 763, 610, 603, 611,
2410  613, 220, 615, 620, 435, 769, 519, 642, 643, 665,
2411  651, 636, 329, 636, 636, 636, 636, 652, 657, 655,
2412  63, 64, 668, 675, 693, 696, 698, 322, 711, 199,
2413  199, 712, 724, 211, 727, 212, 732, 734, 746, 330,
2414  748, 749, 750, 755, 758, 765, 467, 770, 772, 777,
2415  779, 808, 15, 781, 658, 199, 199, 563, 663, 795,
2416  364, 688, 503, 697, 431, 811, 788, 802, 761, 511,
2417  199, 199, 199, 199, 731, 213, 807, 660, 805, 783,
2418  407, 406, 411, 413, 414, 214, 307, 303, 449, 743,
2419  415, 544, 266, 343, 343, 767, 621, 435, 744, 267,
2420  647, 507, 599, 268, 269, 270, 271, 272, 273, 274,
2421  376, 275, 460, 371, 412, 372, 228, 0, 0, 276,
2422  0, 0, 0, 0, 277, 0, 0, 278, 0, 0,
2423  0, 0, 325, 0, 220, 435, 279, 0, 0, 0,
2424  0, 0, 199, 0, 0, 0, 220, 0, 759, 220,
2425  0, 0, 280, 0, 0, 745, 0, 0, 220, 0,
2426  0, 0, 0, 0, 0, 325, 0, 11, 0, 12,
2427  16, 17, 18, 19, 20, 21, 22, 23, 24, 0,
2428  0, 25, 0, 0, 0, 0, 26, 27, 28, 0,
2429  29, 199, 0, 0, 30, 0, 0, 798, 31, 0,
2430  766, 0, 32, 33, 0, 0, 0, 0, 34, 0,
2431  35, 36, 0, 0, 37, 38, 39, 40, 41, 42,
2432  0, 0, 0, 0, 0, 0, 0, 43, 0, 0,
2433  44, 45, 0, 0, 46, 0, 0, 0, 0, 0,
2434  0, 47, 0, 0, 0, 0, 48, 49, 0, 0,
2435  0, 0, 0, 0, 0, 0, 0, 0, 50, 51,
2436  0, 0, 0, 52, 0, 0, 0, 0, 53, 0,
2437  54, 0, 0, 0, 0, 55, 0, 0, 0, 56,
2438  57, 58, 0, 0, 59, 0, 60, 61, 0, 0,
2439  62, 0, 0, 0, 0, 0, 0, 0, 63, 64,
2440  0, 65, 0, 66, 67, 68, 0, 0, 69, 0,
2441  0, 0, 0, 0, 0, 70, 0, 71, 0, 0,
2442  0, 0, 72, 0, 73, 74, 0, 0, 0, 0,
2443  0, 75, 76, 11, 0, 12, 16, 17, 18, 19,
2444  20, 21, 22, 23, 24, 0, 0, 25, 0, 0,
2445  0, 0, 26, 27, 28, 0, 29, 0, 0, 0,
2446  30, 0, 0, 0, 31, 0, 0, 0, 32, 33,
2447  0, 0, 0, 0, 233, 0, 35, 36, 0, 0,
2448  37, 38, 39, 40, 41, 42, 0, 0, 0, 0,
2449  0, 0, 0, 43, 0, 0, 44, 45, 0, 0,
2450  46, 0, 0, 0, 0, 0, 0, 47, 0, 0,
2451  0, 0, 48, 0, 0, 0, 0, 0, 0, 0,
2452  0, 0, 0, 0, 50, 51, 0, 0, 0, 52,
2453  0, 0, 0, 0, 53, 0, 54, 0, 0, 0,
2454  0, 55, 0, 0, 0, 56, 57, 58, 0, 0,
2455  59, 0, 60, 61, 0, 0, 62, 0, 0, 0,
2456  0, 0, 234, 0, 63, 64, 0, 65, 0, 66,
2457  67, 68, 0, 0, 69, 0, 0, 0, 0, 0,
2458  0, 70, 0, 71, 0, 0, 0, 0, 72, 0,
2459  73, 74, 0, 0, 0, 0, 0, 75, 76, 11,
2460  0, 12, 16, 17, 18, 19, 20, 21, 22, 23,
2461  24, 0, 0, 25, 0, 0, 0, 0, 26, 27,
2462  28, 0, 29, 0, 0, 0, 30, 0, 0, 0,
2463  31, 0, 0, 0, 32, 33, 0, 0, 0, 420,
2464  233, 0, 35, 36, 0, 0, 37, 38, 39, 40,
2465  41, 42, 0, 0, 0, 0, 0, 0, 0, 43,
2466  0, 0, 44, 45, 0, 0, 46, 0, 0, 0,
2467  0, 0, 0, 47, 0, 0, 0, 0, 48, 0,
2468  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2469  50, 51, 0, 0, 0, 52, 0, 0, 0, 0,
2470  53, 0, 54, 0, 0, 0, 0, 55, 0, 0,
2471  0, 56, 57, 58, 0, 0, 59, 0, 60, 61,
2472  0, 0, 62, 0, 0, 0, 0, 0, 0, 0,
2473  63, 64, 0, 65, 0, 66, 67, 68, 0, 0,
2474  69, 0, 0, 0, 0, 0, 0, 70, 0, 71,
2475  0, 0, 0, 0, 72, 0, 73, 74, 0, 0,
2476  0, 0, 0, 75, 76, 11, 0, 12, 16, 17,
2477  18, 19, 20, 21, 22, 23, 24, 0, 0, 25,
2478  0, 0, 0, 0, 26, 27, 28, 0, 29, 0,
2479  0, 0, 30, 0, 0, 0, 31, 0, 0, 0,
2480  32, 33, 0, 0, 0, 0, 233, 0, 35, 36,
2481  0, 0, 37, 38, 39, 40, 41, 42, 0, 0,
2482  0, 0, 0, 0, 0, 43, 0, 0, 44, 45,
2483  0, 0, 46, 0, 0, 0, 0, 0, 0, 47,
2484  0, 0, 0, 0, 48, 0, 0, 0, 0, 0,
2485  0, 0, 0, 0, 0, 0, 50, 51, 0, 0,
2486  0, 52, 0, 0, 0, 0, 53, 0, 54, 0,
2487  0, 0, 0, 55, 0, 0, 0, 56, 57, 58,
2488  0, 0, 59, 0, 60, 61, 0, 0, 62, 0,
2489  0, 0, 0, 0, 0, 0, 63, 64, 0, 65,
2490  0, 66, 67, 68, 0, 0, 69, 0, 0, 0,
2491  0, 0, 0, 70, 0, 71, 0, 0, 0, 0,
2492  72, 0, 73, 74, 0, 0, 0, 0, 0, 75,
2493  76, 11, 0, 12, 16, 17, 18, 19, 20, 21,
2494  22, 23, 24, 0, 0, 25, 0, 0, 0, 0,
2495  26, 27, 0, 0, 29, 0, 0, 0, 30, 0,
2496  0, 0, 31, 0, 0, 0, 32, 33, 0, 0,
2497  0, 0, 233, 0, 35, 36, 0, 0, 37, 38,
2498  39, 40, 41, 42, 0, 0, 0, 0, 0, 0,
2499  0, 0, 0, 0, 44, 45, 0, 0, 0, 0,
2500  0, 0, 0, 0, 0, 47, 0, 0, 0, 0,
2501  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2502  0, 0, 0, 51, 0, 0, 0, 52, 0, 0,
2503  0, 0, 53, 0, 54, 0, 0, 0, 0, 55,
2504  0, 0, 0, 56, 57, 58, 0, 0, 59, 0,
2505  60, 61, 0, 0, 62, 0, 0, 0, 0, 0,
2506  0, 0, 63, 64, 0, 65, 0, 66, 67, 0,
2507  0, 0, 69, 0, 0, 0, 0, 0, 0, 70,
2508  0, 71, 0, 0, 0, 0, 0, 0, 73, 74,
2509  0, 0, 0, 0, 0, 75, 76, 11, 0, 12,
2510  16, 17, 18, 19, 20, 21, 22, 23, 24, 0,
2511  0, 25, 0, 0, 0, 0, 26, 27, 0, 0,
2512  29, 0, 0, 0, 30, 0, 0, 0, 31, 0,
2513  0, 0, 32, 33, 0, 0, 0, 0, 233, 0,
2514  35, 36, 0, 0, 37, 38, 39, 40, 41, 42,
2515  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2516  44, 45, 0, 0, 0, 0, 0, 0, 0, 0,
2517  0, 47, 0, 0, 0, 0, 0, 0, 0, 0,
2518  0, 0, 0, 0, 0, 0, 0, 0, 0, 51,
2519  0, 0, 0, 0, 0, 0, 0, 0, 53, 0,
2520  54, 0, 0, 0, 0, 55, 0, 0, 0, 56,
2521  57, 0, 0, 0, 0, 0, 60, 61, 0, 0,
2522  62, 0, 0, 0, 0, 0, 0, 0, 63, 64,
2523  0, 65, 0, 0, 0, 0, 423, 0, 69, 0,
2524  0, 0, 0, 0, 0, 70, 0, 71, 0, 0,
2525  0, 0, 0, 0, 73, 0, 0, 0, 0, 0,
2526  0, 75, 76, 11, 0, 12, 16, 17, 18, 19,
2527  20, 21, 22, 23, 24, 0, 0, 25, 0, 0,
2528  0, 0, 26, 27, 0, 0, 29, 0, 0, 0,
2529  30, 0, 0, 0, 31, 0, 0, 0, 32, 33,
2530  0, 0, 0, 0, 233, 0, 35, 36, 0, 0,
2531  37, 38, 39, 40, 41, 42, 0, 0, 0, 0,
2532  0, 0, 0, 0, 0, 0, 44, 45, 0, 0,
2533  0, 0, 0, 0, 0, 0, 0, 47, 0, 0,
2534  16, 17, 18, 19, 20, 0, 0, 23, 24, 0,
2535  0, 0, 0, 0, 0, 51, 26, 628, 0, 0,
2536  0, 0, 0, 0, 53, 0, 54, 0, 31, 0,
2537  0, 55, 327, 0, 0, 56, 57, 0, 0, 0,
2538  35, 36, 60, 61, 0, 38, 62, 0, 41, 328,
2539  0, 0, 0, 0, 63, 64, 0, 65, 0, 0,
2540  44, 45, 0, 0, 69, 0, 0, 0, 0, 0,
2541  0, 70, 0, 71, 0, 0, 0, 0, 0, 0,
2542  73, 16, 197, 18, 19, 20, 0, 75, 76, 0,
2543  0, 0, 0, 0, 0, 16, 197, 18, 19, 20,
2544  54, 0, 23, 24, 0, 0, 0, 0, 0, 56,
2545  0, 26, 628, 327, 0, 0, 60, 61, 0, 0,
2546  329, 0, 0, 31, 0, 0, 38, 327, 63, 64,
2547  328, 65, 0, 629, 630, 35, 36, 0, 69, 0,
2548  38, 0, 0, 41, 328, 0, 0, 330, 0, 0,
2549  0, 0, 0, 0, 0, 44, 45, 0, 0, 0,
2550  0, 75, 0, 0, 0, 0, 0, 0, 0, 0,
2551  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2552  0, 54, 0, 0, 0, 0, 0, 0, 0, 0,
2553  0, 0, 0, 0, 0, 54, 0, 0, 0, 0,
2554  0, 329, 0, 0, 56, 0, 0, 0, 0, 0,
2555  64, 60, 61, 0, 0, 329, 0, 0, 0, 69,
2556  0, 0, 0, 63, 64, 0, 65, 0, 330, 0,
2557  0, 0, 0, 69, 0, 0, 0, 0, 0, 0,
2558  0, 0, 330
2559 };
2560 
2561 static const yytype_int16 yycheck[] =
2562 {
2563  30, 246, 53, 25, 51, 417, 30, 262, 263, 39,
2564  314, 62, 35, 321, 341, 190, 343, 311, 312, 4,
2565  687, 32, 416, 417, 36, 76, 3, 38, 5, 59,
2566  7, 42, 6, 7, 8, 32, 87, 37, 379, 347,
2567  37, 224, 225, 54, 29, 42, 52, 37, 37, 16,
2568  52, 62, 709, 50, 90, 593, 35, 95, 111, 400,
2569  71, 55, 317, 45, 476, 350, 20, 686, 353, 252,
2570  6, 7, 8, 49, 71, 383, 55, 128, 386, 364,
2571  70, 19, 476, 95, 37, 6, 7, 8, 37, 37,
2572  709, 732, 71, 338, 95, 79, 64, 98, 6, 7,
2573  37, 42, 165, 686, 94, 81, 37, 160, 92, 145,
2574  48, 65, 416, 417, 6, 7, 8, 9, 10, 87,
2575  37, 37, 104, 113, 765, 101, 709, 468, 166, 131,
2576  668, 23, 132, 70, 113, 163, 803, 159, 132, 314,
2577  7, 135, 193, 166, 133, 486, 38, 455, 456, 434,
2578  201, 157, 809, 143, 166, 132, 31, 94, 188, 51,
2579  190, 191, 129, 55, 215, 450, 95, 75, 144, 454,
2580  45, 222, 476, 458, 164, 42, 113, 796, 463, 120,
2581  133, 211, 229, 132, 132, 0, 237, 211, 102, 236,
2582  809, 221, 222, 167, 224, 225, 132, 221, 222, 184,
2583  44, 132, 253, 254, 387, 546, 143, 204, 144, 256,
2584  195, 132, 209, 796, 106, 132, 132, 214, 248, 249,
2585  128, 104, 252, 144, 248, 249, 809, 164, 95, 3,
2586  475, 5, 629, 630, 126, 69, 102, 166, 117, 83,
2587  59, 84, 134, 135, 656, 6, 7, 532, 127, 534,
2588  535, 559, 144, 3, 4, 5, 241, 512, 305, 244,
2589  7, 153, 656, 97, 107, 144, 313, 99, 42, 316,
2590  136, 441, 99, 670, 671, 560, 42, 27, 563, 139,
2591  140, 622, 623, 577, 314, 117, 469, 139, 140, 39,
2592  117, 124, 42, 6, 7, 8, 551, 344, 124, 65,
2593  545, 471, 557, 473, 113, 139, 140, 592, 95, 339,
2594  595, 566, 100, 146, 108, 339, 327, 328, 329, 330,
2595  146, 648, 649, 664, 26, 95, 28, 77, 155, 42,
2596  124, 361, 672, 673, 143, 365, 321, 148, 40, 41,
2597  3, 365, 5, 45, 652, 66, 67, 602, 6, 7,
2598  8, 3, 656, 5, 166, 610, 341, 387, 343, 6,
2599  7, 8, 347, 418, 419, 620, 116, 95, 52, 71,
2600  52, 95, 357, 6, 7, 8, 42, 95, 363, 6,
2601  7, 8, 690, 150, 639, 95, 416, 417, 418, 419,
2602  95, 676, 416, 417, 418, 419, 651, 52, 383, 582,
2603  95, 386, 104, 7, 15, 588, 37, 37, 110, 439,
2604  112, 441, 281, 282, 283, 439, 757, 441, 601, 760,
2605  675, 114, 763, 156, 86, 32, 767, 33, 769, 138,
2606  91, 36, 91, 73, 42, 95, 132, 7, 693, 469,
2607  104, 471, 95, 473, 95, 730, 476, 471, 104, 473,
2608  152, 706, 476, 95, 103, 52, 132, 149, 42, 714,
2609  162, 109, 6, 7, 8, 18, 18, 18, 7, 95,
2610  455, 456, 727, 95, 37, 132, 104, 462, 57, 23,
2611  104, 73, 98, 52, 18, 496, 497, 132, 132, 7,
2612  55, 7, 7, 748, 38, 750, 43, 132, 119, 95,
2613  132, 786, 43, 132, 95, 130, 593, 51, 43, 132,
2614  95, 55, 132, 130, 58, 73, 21, 772, 132, 26,
2615  132, 28, 777, 132, 779, 85, 781, 73, 21, 104,
2616  73, 776, 517, 40, 41, 154, 73, 792, 45, 127,
2617  795, 29, 629, 630, 541, 89, 113, 85, 131, 52,
2618  37, 734, 582, 808, 132, 132, 52, 42, 588, 127,
2619  52, 85, 106, 746, 71, 73, 749, 20, 118, 3,
2620  31, 601, 29, 37, 559, 758, 157, 132, 132, 626,
2621  56, 668, 126, 670, 671, 672, 673, 37, 60, 52,
2622  134, 135, 25, 20, 20, 43, 132, 104, 16, 629,
2623  630, 129, 18, 110, 35, 112, 100, 52, 52, 153,
2624  131, 52, 131, 125, 52, 37, 95, 75, 131, 85,
2625  20, 131, 9, 85, 619, 655, 656, 485, 624, 85,
2626  212, 655, 656, 668, 317, 809, 778, 796, 747, 423,
2627  670, 671, 672, 673, 695, 152, 803, 620, 800, 774,
2628  265, 264, 286, 292, 295, 162, 130, 122, 345, 710,
2629  298, 467, 61, 648, 649, 756, 581, 652, 710, 68,
2630  603, 419, 548, 72, 73, 74, 75, 76, 77, 78,
2631  222, 80, 361, 216, 287, 216, 47, -1, -1, 88,
2632  -1, -1, -1, -1, 93, -1, -1, 96, -1, -1,
2633  -1, -1, 732, -1, 734, 690, 105, -1, -1, -1,
2634  -1, -1, 742, -1, -1, -1, 746, -1, 742, 749,
2635  -1, -1, 121, -1, -1, 710, -1, -1, 758, -1,
2636  -1, -1, -1, -1, -1, 765, -1, 3, -1, 5,
2637  6, 7, 8, 9, 10, 11, 12, 13, 14, -1,
2638  -1, 17, -1, -1, -1, -1, 22, 23, 24, -1,
2639  26, 791, -1, -1, 30, -1, -1, 791, 34, -1,
2640  755, -1, 38, 39, -1, -1, -1, -1, 44, -1,
2641  46, 47, -1, -1, 50, 51, 52, 53, 54, 55,
2642  -1, -1, -1, -1, -1, -1, -1, 63, -1, -1,
2643  66, 67, -1, -1, 70, -1, -1, -1, -1, -1,
2644  -1, 77, -1, -1, -1, -1, 82, 83, -1, -1,
2645  -1, -1, -1, -1, -1, -1, -1, -1, 94, 95,
2646  -1, -1, -1, 99, -1, -1, -1, -1, 104, -1,
2647  106, -1, -1, -1, -1, 111, -1, -1, -1, 115,
2648  116, 117, -1, -1, 120, -1, 122, 123, -1, -1,
2649  126, -1, -1, -1, -1, -1, -1, -1, 134, 135,
2650  -1, 137, -1, 139, 140, 141, -1, -1, 144, -1,
2651  -1, -1, -1, -1, -1, 151, -1, 153, -1, -1,
2652  -1, -1, 158, -1, 160, 161, -1, -1, -1, -1,
2653  -1, 167, 168, 3, -1, 5, 6, 7, 8, 9,
2654  10, 11, 12, 13, 14, -1, -1, 17, -1, -1,
2655  -1, -1, 22, 23, 24, -1, 26, -1, -1, -1,
2656  30, -1, -1, -1, 34, -1, -1, -1, 38, 39,
2657  -1, -1, -1, -1, 44, -1, 46, 47, -1, -1,
2658  50, 51, 52, 53, 54, 55, -1, -1, -1, -1,
2659  -1, -1, -1, 63, -1, -1, 66, 67, -1, -1,
2660  70, -1, -1, -1, -1, -1, -1, 77, -1, -1,
2661  -1, -1, 82, -1, -1, -1, -1, -1, -1, -1,
2662  -1, -1, -1, -1, 94, 95, -1, -1, -1, 99,
2663  -1, -1, -1, -1, 104, -1, 106, -1, -1, -1,
2664  -1, 111, -1, -1, -1, 115, 116, 117, -1, -1,
2665  120, -1, 122, 123, -1, -1, 126, -1, -1, -1,
2666  -1, -1, 132, -1, 134, 135, -1, 137, -1, 139,
2667  140, 141, -1, -1, 144, -1, -1, -1, -1, -1,
2668  -1, 151, -1, 153, -1, -1, -1, -1, 158, -1,
2669  160, 161, -1, -1, -1, -1, -1, 167, 168, 3,
2670  -1, 5, 6, 7, 8, 9, 10, 11, 12, 13,
2671  14, -1, -1, 17, -1, -1, -1, -1, 22, 23,
2672  24, -1, 26, -1, -1, -1, 30, -1, -1, -1,
2673  34, -1, -1, -1, 38, 39, -1, -1, -1, 43,
2674  44, -1, 46, 47, -1, -1, 50, 51, 52, 53,
2675  54, 55, -1, -1, -1, -1, -1, -1, -1, 63,
2676  -1, -1, 66, 67, -1, -1, 70, -1, -1, -1,
2677  -1, -1, -1, 77, -1, -1, -1, -1, 82, -1,
2678  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2679  94, 95, -1, -1, -1, 99, -1, -1, -1, -1,
2680  104, -1, 106, -1, -1, -1, -1, 111, -1, -1,
2681  -1, 115, 116, 117, -1, -1, 120, -1, 122, 123,
2682  -1, -1, 126, -1, -1, -1, -1, -1, -1, -1,
2683  134, 135, -1, 137, -1, 139, 140, 141, -1, -1,
2684  144, -1, -1, -1, -1, -1, -1, 151, -1, 153,
2685  -1, -1, -1, -1, 158, -1, 160, 161, -1, -1,
2686  -1, -1, -1, 167, 168, 3, -1, 5, 6, 7,
2687  8, 9, 10, 11, 12, 13, 14, -1, -1, 17,
2688  -1, -1, -1, -1, 22, 23, 24, -1, 26, -1,
2689  -1, -1, 30, -1, -1, -1, 34, -1, -1, -1,
2690  38, 39, -1, -1, -1, -1, 44, -1, 46, 47,
2691  -1, -1, 50, 51, 52, 53, 54, 55, -1, -1,
2692  -1, -1, -1, -1, -1, 63, -1, -1, 66, 67,
2693  -1, -1, 70, -1, -1, -1, -1, -1, -1, 77,
2694  -1, -1, -1, -1, 82, -1, -1, -1, -1, -1,
2695  -1, -1, -1, -1, -1, -1, 94, 95, -1, -1,
2696  -1, 99, -1, -1, -1, -1, 104, -1, 106, -1,
2697  -1, -1, -1, 111, -1, -1, -1, 115, 116, 117,
2698  -1, -1, 120, -1, 122, 123, -1, -1, 126, -1,
2699  -1, -1, -1, -1, -1, -1, 134, 135, -1, 137,
2700  -1, 139, 140, 141, -1, -1, 144, -1, -1, -1,
2701  -1, -1, -1, 151, -1, 153, -1, -1, -1, -1,
2702  158, -1, 160, 161, -1, -1, -1, -1, -1, 167,
2703  168, 3, -1, 5, 6, 7, 8, 9, 10, 11,
2704  12, 13, 14, -1, -1, 17, -1, -1, -1, -1,
2705  22, 23, -1, -1, 26, -1, -1, -1, 30, -1,
2706  -1, -1, 34, -1, -1, -1, 38, 39, -1, -1,
2707  -1, -1, 44, -1, 46, 47, -1, -1, 50, 51,
2708  52, 53, 54, 55, -1, -1, -1, -1, -1, -1,
2709  -1, -1, -1, -1, 66, 67, -1, -1, -1, -1,
2710  -1, -1, -1, -1, -1, 77, -1, -1, -1, -1,
2711  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2712  -1, -1, -1, 95, -1, -1, -1, 99, -1, -1,
2713  -1, -1, 104, -1, 106, -1, -1, -1, -1, 111,
2714  -1, -1, -1, 115, 116, 117, -1, -1, 120, -1,
2715  122, 123, -1, -1, 126, -1, -1, -1, -1, -1,
2716  -1, -1, 134, 135, -1, 137, -1, 139, 140, -1,
2717  -1, -1, 144, -1, -1, -1, -1, -1, -1, 151,
2718  -1, 153, -1, -1, -1, -1, -1, -1, 160, 161,
2719  -1, -1, -1, -1, -1, 167, 168, 3, -1, 5,
2720  6, 7, 8, 9, 10, 11, 12, 13, 14, -1,
2721  -1, 17, -1, -1, -1, -1, 22, 23, -1, -1,
2722  26, -1, -1, -1, 30, -1, -1, -1, 34, -1,
2723  -1, -1, 38, 39, -1, -1, -1, -1, 44, -1,
2724  46, 47, -1, -1, 50, 51, 52, 53, 54, 55,
2725  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2726  66, 67, -1, -1, -1, -1, -1, -1, -1, -1,
2727  -1, 77, -1, -1, -1, -1, -1, -1, -1, -1,
2728  -1, -1, -1, -1, -1, -1, -1, -1, -1, 95,
2729  -1, -1, -1, -1, -1, -1, -1, -1, 104, -1,
2730  106, -1, -1, -1, -1, 111, -1, -1, -1, 115,
2731  116, -1, -1, -1, -1, -1, 122, 123, -1, -1,
2732  126, -1, -1, -1, -1, -1, -1, -1, 134, 135,
2733  -1, 137, -1, -1, -1, -1, 142, -1, 144, -1,
2734  -1, -1, -1, -1, -1, 151, -1, 153, -1, -1,
2735  -1, -1, -1, -1, 160, -1, -1, -1, -1, -1,
2736  -1, 167, 168, 3, -1, 5, 6, 7, 8, 9,
2737  10, 11, 12, 13, 14, -1, -1, 17, -1, -1,
2738  -1, -1, 22, 23, -1, -1, 26, -1, -1, -1,
2739  30, -1, -1, -1, 34, -1, -1, -1, 38, 39,
2740  -1, -1, -1, -1, 44, -1, 46, 47, -1, -1,
2741  50, 51, 52, 53, 54, 55, -1, -1, -1, -1,
2742  -1, -1, -1, -1, -1, -1, 66, 67, -1, -1,
2743  -1, -1, -1, -1, -1, -1, -1, 77, -1, -1,
2744  6, 7, 8, 9, 10, -1, -1, 13, 14, -1,
2745  -1, -1, -1, -1, -1, 95, 22, 23, -1, -1,
2746  -1, -1, -1, -1, 104, -1, 106, -1, 34, -1,
2747  -1, 111, 38, -1, -1, 115, 116, -1, -1, -1,
2748  46, 47, 122, 123, -1, 51, 126, -1, 54, 55,
2749  -1, -1, -1, -1, 134, 135, -1, 137, -1, -1,
2750  66, 67, -1, -1, 144, -1, -1, -1, -1, -1,
2751  -1, 151, -1, 153, -1, -1, -1, -1, -1, -1,
2752  160, 6, 7, 8, 9, 10, -1, 167, 168, -1,
2753  -1, -1, -1, -1, -1, 6, 7, 8, 9, 10,
2754  106, -1, 13, 14, -1, -1, -1, -1, -1, 115,
2755  -1, 22, 23, 38, -1, -1, 122, 123, -1, -1,
2756  126, -1, -1, 34, -1, -1, 51, 38, 134, 135,
2757  55, 137, -1, 139, 140, 46, 47, -1, 144, -1,
2758  51, -1, -1, 54, 55, -1, -1, 153, -1, -1,
2759  -1, -1, -1, -1, -1, 66, 67, -1, -1, -1,
2760  -1, 167, -1, -1, -1, -1, -1, -1, -1, -1,
2761  -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2762  -1, 106, -1, -1, -1, -1, -1, -1, -1, -1,
2763  -1, -1, -1, -1, -1, 106, -1, -1, -1, -1,
2764  -1, 126, -1, -1, 115, -1, -1, -1, -1, -1,
2765  135, 122, 123, -1, -1, 126, -1, -1, -1, 144,
2766  -1, -1, -1, 134, 135, -1, 137, -1, 153, -1,
2767  -1, -1, -1, 144, -1, -1, -1, -1, -1, -1,
2768  -1, -1, 153
2769 };
2770 
2771 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
2772  symbol of state STATE-NUM. */
2773 static const yytype_uint16 yystos[] =
2774 {
2775  0, 165, 170, 171, 163, 0, 102, 173, 174, 175,
2776  176, 3, 5, 404, 104, 176, 6, 7, 8, 9,
2777  10, 11, 12, 13, 14, 17, 22, 23, 24, 26,
2778  30, 34, 38, 39, 44, 46, 47, 50, 51, 52,
2779  53, 54, 55, 63, 66, 67, 70, 77, 82, 83,
2780  94, 95, 99, 104, 106, 111, 115, 116, 117, 120,
2781  122, 123, 126, 134, 135, 137, 139, 140, 141, 144,
2782  151, 153, 158, 160, 161, 167, 168, 177, 183, 184,
2783  186, 187, 189, 190, 191, 192, 193, 194, 195, 197,
2784  200, 201, 202, 204, 208, 211, 213, 219, 225, 226,
2785  227, 232, 233, 240, 253, 254, 260, 267, 276, 277,
2786  278, 279, 280, 281, 283, 285, 286, 289, 290, 291,
2787  292, 293, 294, 295, 296, 298, 300, 302, 303, 304,
2788  306, 307, 309, 310, 311, 322, 323, 324, 327, 328,
2789  329, 331, 332, 333, 334, 335, 336, 337, 338, 339,
2790  340, 342, 343, 344, 345, 347, 348, 349, 358, 359,
2791  360, 361, 362, 365, 366, 367, 368, 375, 382, 383,
2792  384, 386, 387, 388, 389, 390, 391, 392, 394, 397,
2793  399, 400, 404, 405, 59, 172, 7, 44, 100, 229,
2794  330, 95, 166, 364, 395, 95, 404, 7, 397, 405,
2795  95, 364, 395, 148, 26, 28, 40, 41, 45, 71,
2796  104, 110, 112, 152, 162, 364, 95, 395, 7, 341,
2797  405, 95, 364, 395, 52, 52, 6, 7, 401, 95,
2798  102, 136, 364, 44, 132, 225, 42, 218, 395, 150,
2799  7, 402, 405, 7, 95, 218, 374, 395, 95, 95,
2800  310, 310, 52, 312, 364, 395, 95, 90, 145, 7,
2801  218, 218, 37, 37, 114, 15, 61, 68, 72, 73,
2802  74, 75, 76, 77, 78, 80, 88, 93, 96, 105,
2803  121, 297, 299, 301, 99, 117, 155, 282, 49, 81,
2804  101, 144, 284, 25, 159, 287, 64, 87, 288, 86,
2805  156, 32, 33, 293, 218, 42, 305, 307, 69, 97,
2806  139, 140, 321, 91, 325, 36, 91, 95, 404, 138,
2807  185, 73, 104, 7, 231, 405, 95, 38, 55, 126,
2808  153, 333, 7, 132, 144, 396, 405, 218, 369, 370,
2809  373, 218, 356, 404, 42, 95, 218, 364, 124, 146,
2810  188, 124, 146, 212, 108, 124, 198, 35, 55, 71,
2811  113, 364, 7, 397, 194, 103, 181, 182, 364, 218,
2812  385, 392, 394, 144, 397, 372, 373, 397, 341, 341,
2813  350, 225, 104, 205, 45, 104, 203, 52, 104, 132,
2814  225, 218, 149, 308, 404, 7, 404, 305, 397, 397,
2815  341, 218, 218, 225, 227, 227, 278, 279, 280, 280,
2816  280, 281, 283, 285, 286, 289, 109, 18, 18, 18,
2817  43, 225, 311, 142, 311, 225, 23, 326, 333, 389,
2818  225, 226, 227, 346, 403, 404, 7, 314, 315, 37,
2819  132, 37, 132, 305, 397, 356, 132, 356, 225, 314,
2820  403, 185, 185, 37, 404, 104, 104, 57, 196, 7,
2821  399, 405, 73, 404, 185, 397, 98, 95, 317, 52,
2822  132, 37, 132, 37, 132, 363, 18, 377, 377, 353,
2823  132, 7, 403, 55, 7, 403, 341, 7, 43, 119,
2824  132, 132, 132, 132, 377, 132, 58, 89, 378, 380,
2825  381, 382, 389, 397, 378, 376, 381, 376, 43, 113,
2826  143, 246, 252, 130, 130, 132, 185, 73, 132, 157,
2827  316, 318, 319, 397, 398, 398, 371, 43, 132, 185,
2828  84, 107, 199, 185, 403, 403, 79, 92, 185, 95,
2829  3, 403, 185, 95, 316, 377, 341, 398, 398, 305,
2830  378, 85, 21, 239, 351, 354, 401, 154, 73, 21,
2831  206, 104, 73, 206, 377, 73, 85, 268, 395, 395,
2832  117, 127, 144, 379, 127, 29, 113, 131, 227, 247,
2833  248, 37, 52, 132, 132, 185, 185, 185, 52, 215,
2834  216, 42, 364, 178, 132, 305, 377, 127, 393, 393,
2835  227, 52, 85, 118, 73, 227, 207, 403, 185, 185,
2836  20, 3, 227, 31, 269, 29, 311, 19, 48, 249,
2837  37, 318, 341, 341, 37, 132, 313, 185, 23, 139,
2838  140, 220, 221, 222, 223, 224, 322, 345, 185, 20,
2839  65, 209, 132, 132, 261, 341, 227, 353, 16, 129,
2840  355, 56, 37, 227, 255, 52, 273, 60, 196, 250,
2841  248, 377, 377, 216, 214, 225, 223, 223, 25, 179,
2842  139, 140, 139, 140, 227, 20, 210, 262, 234, 75,
2843  128, 352, 356, 356, 227, 403, 241, 256, 397, 378,
2844  35, 166, 251, 20, 320, 377, 43, 221, 132, 223,
2845  223, 224, 224, 227, 185, 37, 133, 263, 266, 235,
2846  357, 16, 129, 37, 164, 233, 240, 242, 244, 245,
2847  246, 37, 257, 266, 18, 270, 403, 35, 227, 65,
2848  217, 218, 100, 228, 52, 227, 37, 233, 236, 240,
2849  244, 4, 27, 218, 348, 404, 52, 227, 131, 52,
2850  131, 227, 185, 230, 231, 125, 180, 341, 52, 397,
2851  341, 245, 227, 341, 227, 37, 404, 317, 377, 341,
2852  75, 377, 131, 377, 271, 231, 377, 85, 377, 20,
2853  227, 85, 45, 269, 272, 274, 305, 227, 239, 227,
2854  227, 52, 131, 185, 264, 85, 243, 258, 397, 227,
2855  265, 227, 242, 259, 275, 263, 237, 257, 131, 238,
2856  227, 236
2857 };
2858 
2859 #define yyerrok (yyerrstatus = 0)
2860 #define yyclearin (yychar = YYEMPTY)
2861 #define YYEMPTY (-2)
2862 #define YYEOF 0
2863 
2864 #define YYACCEPT goto yyacceptlab
2865 #define YYABORT goto yyabortlab
2866 #define YYERROR goto yyerrorlab
2867 
2868 
2869 /* Like YYERROR except do call yyerror. This remains here temporarily
2870  to ease the transition to the new meaning of YYERROR, for GCC.
2871  Once GCC version 2 has supplanted version 1, this can go. */
2872 
2873 #define YYFAIL goto yyerrlab
2874 
2875 #define YYRECOVERING() (!!yyerrstatus)
2876 
2877 #define YYBACKUP(Token, Value) \
2878 do \
2879  if (yychar == YYEMPTY && yylen == 1) \
2880  { \
2881  yychar = (Token); \
2882  yylval = (Value); \
2883  yytoken = YYTRANSLATE (yychar); \
2884  YYPOPSTACK (1); \
2885  goto yybackup; \
2886  } \
2887  else \
2888  { \
2889  yyerror (&yylloc, parseInfo, YY_("syntax error: cannot back up")); \
2890  YYERROR; \
2891  } \
2892 while (YYID (0))
2893 
2894 
2895 #define YYTERROR 1
2896 #define YYERRCODE 256
2897 
2898 
2899 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
2900  If N is 0, then set CURRENT to the empty location which ends
2901  the previous symbol: RHS[0] (always defined). */
2902 
2903 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
2904 #ifndef YYLLOC_DEFAULT
2905 # define YYLLOC_DEFAULT(Current, Rhs, N) \
2906  do \
2907  if (YYID (N)) \
2908  { \
2909  (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
2910  (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
2911  (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
2912  (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
2913  } \
2914  else \
2915  { \
2916  (Current).first_line = (Current).last_line = \
2917  YYRHSLOC (Rhs, 0).last_line; \
2918  (Current).first_column = (Current).last_column = \
2919  YYRHSLOC (Rhs, 0).last_column; \
2920  } \
2921  while (YYID (0))
2922 #endif
2923 
2924 
2925 /* YY_LOCATION_PRINT -- Print the location on the stream.
2926  This macro was not mandated originally: define only if we know
2927  we won't break user code: when these are the locations we know. */
2928 
2929 #ifndef YY_LOCATION_PRINT
2930 # if YYLTYPE_IS_TRIVIAL
2931 # define YY_LOCATION_PRINT(File, Loc) \
2932  fprintf (File, "%d.%d-%d.%d", \
2933  (Loc).first_line, (Loc).first_column, \
2934  (Loc).last_line, (Loc).last_column)
2935 # else
2936 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
2937 # endif
2938 #endif
2939 
2940 
2941 /* YYLEX -- calling `yylex' with the right arguments. */
2942 
2943 #ifdef YYLEX_PARAM
2944 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
2945 #else
2946 # define YYLEX yylex (&yylval, &yylloc, parseInfo)
2947 #endif
2948 
2949 /* Enable debugging if requested. */
2950 #if YYDEBUG
2951 
2952 # ifndef YYFPRINTF
2953 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2954 # define YYFPRINTF fprintf
2955 # endif
2956 
2957 # define YYDPRINTF(Args) \
2958 do { \
2959  if (yydebug) \
2960  YYFPRINTF Args; \
2961 } while (YYID (0))
2962 
2963 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
2964 do { \
2965  if (yydebug) \
2966  { \
2967  YYFPRINTF (stderr, "%s ", Title); \
2968  yy_symbol_print (stderr, \
2969  Type, Value, Location, parseInfo); \
2970  YYFPRINTF (stderr, "\n"); \
2971  } \
2972 } while (YYID (0))
2973 
2974 
2975 /*--------------------------------.
2976 | Print this symbol on YYOUTPUT. |
2977 `--------------------------------*/
2978 
2979 /*ARGSUSED*/
2980 #if (defined __STDC__ || defined __C99__FUNC__ \
2981  || defined __cplusplus || defined _MSC_VER)
2982 static void
2983 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, ParserContext *const parseInfo)
2984 #else
2985 static void
2986 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, parseInfo)
2987  FILE *yyoutput;
2988  int yytype;
2989  YYSTYPE const * const yyvaluep;
2990  YYLTYPE const * const yylocationp;
2991  ParserContext *const parseInfo;
2992 #endif
2993 {
2994  if (!yyvaluep)
2995  return;
2996  YYUSE (yylocationp);
2997  YYUSE (parseInfo);
2998 # ifdef YYPRINT
2999  if (yytype < YYNTOKENS)
3000  YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
3001 # else
3002  YYUSE (yyoutput);
3003 # endif
3004  switch (yytype)
3005  {
3006  default:
3007  break;
3008  }
3009 }
3010 
3011 
3012 /*--------------------------------.
3013 | Print this symbol on YYOUTPUT. |
3014 `--------------------------------*/
3015 
3016 #if (defined __STDC__ || defined __C99__FUNC__ \
3017  || defined __cplusplus || defined _MSC_VER)
3018 static void
3019 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, ParserContext *const parseInfo)
3020 #else
3021 static void
3022 yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, parseInfo)
3023  FILE *yyoutput;
3024  int yytype;
3025  YYSTYPE const * const yyvaluep;
3026  YYLTYPE const * const yylocationp;
3027  ParserContext *const parseInfo;
3028 #endif
3029 {
3030  if (yytype < YYNTOKENS)
3031  YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
3032  else
3033  YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
3034 
3035  YY_LOCATION_PRINT (yyoutput, *yylocationp);
3036  YYFPRINTF (yyoutput, ": ");
3037  yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, parseInfo);
3038  YYFPRINTF (yyoutput, ")");
3039 }
3040 
3041 /*------------------------------------------------------------------.
3042 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
3043 | TOP (included). |
3044 `------------------------------------------------------------------*/
3045 
3046 #if (defined __STDC__ || defined __C99__FUNC__ \
3047  || defined __cplusplus || defined _MSC_VER)
3048 static void
3049 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
3050 #else
3051 static void
3052 yy_stack_print (yybottom, yytop)
3053  yytype_int16 *yybottom;
3054  yytype_int16 *yytop;
3055 #endif
3056 {
3057  YYFPRINTF (stderr, "Stack now");
3058  for (; yybottom <= yytop; yybottom++)
3059  {
3060  int yybot = *yybottom;
3061  YYFPRINTF (stderr, " %d", yybot);
3062  }
3063  YYFPRINTF (stderr, "\n");
3064 }
3065 
3066 # define YY_STACK_PRINT(Bottom, Top) \
3067 do { \
3068  if (yydebug) \
3069  yy_stack_print ((Bottom), (Top)); \
3070 } while (YYID (0))
3071 
3072 
3073 /*------------------------------------------------.
3074 | Report that the YYRULE is going to be reduced. |
3075 `------------------------------------------------*/
3076 
3077 #if (defined __STDC__ || defined __C99__FUNC__ \
3078  || defined __cplusplus || defined _MSC_VER)
3079 static void
3080 yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, ParserContext *const parseInfo)
3081 #else
3082 static void
3083 yy_reduce_print (yyvsp, yylsp, yyrule, parseInfo)
3084  YYSTYPE *yyvsp;
3085  YYLTYPE *yylsp;
3086  int yyrule;
3087  ParserContext *const parseInfo;
3088 #endif
3089 {
3090  int yynrhs = yyr2[yyrule];
3091  int yyi;
3092  unsigned long int yylno = yyrline[yyrule];
3093  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
3094  yyrule - 1, yylno);
3095  /* The symbols being reduced. */
3096  for (yyi = 0; yyi < yynrhs; yyi++)
3097  {
3098  fprintf (stderr, " $%d = ", yyi + 1);
3099  yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
3100  &(yyvsp[(yyi + 1) - (yynrhs)])
3101  , &(yylsp[(yyi + 1) - (yynrhs)]) , parseInfo);
3102  fprintf (stderr, "\n");
3103  }
3104 }
3105 
3106 # define YY_REDUCE_PRINT(Rule) \
3107 do { \
3108  if (yydebug) \
3109  yy_reduce_print (yyvsp, yylsp, Rule, parseInfo); \
3110 } while (YYID (0))
3111 
3112 /* Nonzero means print parse trace. It is left uninitialized so that
3113  multiple parsers can coexist. */
3114 int yydebug;
3115 #else /* !YYDEBUG */
3116 # define YYDPRINTF(Args)
3117 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
3118 # define YY_STACK_PRINT(Bottom, Top)
3119 # define YY_REDUCE_PRINT(Rule)
3120 #endif /* !YYDEBUG */
3121 
3122 
3123 /* YYINITDEPTH -- initial size of the parser's stacks. */
3124 #ifndef YYINITDEPTH
3125 # define YYINITDEPTH 200
3126 #endif
3127 
3128 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
3129  if the built-in stack extension method is used).
3130 
3131  Do not make this value too large; the results are undefined if
3132  YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
3133  evaluated with infinite-precision integer arithmetic. */
3134 
3135 #ifndef YYMAXDEPTH
3136 # define YYMAXDEPTH 10000
3137 #endif
3138 
3139 
3140 
3141 #if YYERROR_VERBOSE
3142 
3143 # ifndef yystrlen
3144 # if defined __GLIBC__ && defined _STRING_H
3145 # define yystrlen strlen
3146 # else
3147 /* Return the length of YYSTR. */
3148 #if (defined __STDC__ || defined __C99__FUNC__ \
3149  || defined __cplusplus || defined _MSC_VER)
3150 static YYSIZE_T
3151 yystrlen (const char *yystr)
3152 #else
3153 static YYSIZE_T
3154 yystrlen (yystr)
3155  const char *yystr;
3156 #endif
3157 {
3158  YYSIZE_T yylen;
3159  for (yylen = 0; yystr[yylen]; yylen++)
3160  continue;
3161  return yylen;
3162 }
3163 # endif
3164 # endif
3165 
3166 # ifndef yystpcpy
3167 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
3168 # define yystpcpy stpcpy
3169 # else
3170 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
3171  YYDEST. */
3172 #if (defined __STDC__ || defined __C99__FUNC__ \
3173  || defined __cplusplus || defined _MSC_VER)
3174 static char *
3175 yystpcpy (char *yydest, const char *yysrc)
3176 #else
3177 static char *
3178 yystpcpy (yydest, yysrc)
3179  char *yydest;
3180  const char *yysrc;
3181 #endif
3182 {
3183  char *yyd = yydest;
3184  const char *yys = yysrc;
3185 
3186  while ((*yyd++ = *yys++) != '\0')
3187  continue;
3188 
3189  return yyd - 1;
3190 }
3191 # endif
3192 # endif
3193 
3194 # ifndef yytnamerr
3195 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
3196  quotes and backslashes, so that it's suitable for yyerror. The
3197  heuristic is that double-quoting is unnecessary unless the string
3198  contains an apostrophe, a comma, or backslash (other than
3199  backslash-backslash). YYSTR is taken from yytname. If YYRES is
3200  null, do not copy; instead, return the length of what the result
3201  would have been. */
3202 static YYSIZE_T
3203 yytnamerr (char *yyres, const char *yystr)
3204 {
3205  if (*yystr == '"')
3206  {
3207  YYSIZE_T yyn = 0;
3208  char const *yyp = yystr;
3209 
3210  for (;;)
3211  switch (*++yyp)
3212  {
3213  case '\'':
3214  case ',':
3215  goto do_not_strip_quotes;
3216 
3217  case '\\':
3218  if (*++yyp != '\\')
3219  goto do_not_strip_quotes;
3220  /* Fall through. */
3221  default:
3222  if (yyres)
3223  yyres[yyn] = *yyp;
3224  yyn++;
3225  break;
3226 
3227  case '"':
3228  if (yyres)
3229  yyres[yyn] = '\0';
3230  return yyn;
3231  }
3232  do_not_strip_quotes: ;
3233  }
3234 
3235  if (! yyres)
3236  return yystrlen (yystr);
3237 
3238  return yystpcpy (yyres, yystr) - yyres;
3239 }
3240 # endif
3241 
3242 /* Copy into YYRESULT an error message about the unexpected token
3243  YYCHAR while in state YYSTATE. Return the number of bytes copied,
3244  including the terminating null byte. If YYRESULT is null, do not
3245  copy anything; just return the number of bytes that would be
3246  copied. As a special case, return 0 if an ordinary "syntax error"
3247  message will do. Return YYSIZE_MAXIMUM if overflow occurs during
3248  size calculation. */
3249 static YYSIZE_T
3250 yysyntax_error (char *yyresult, int yystate, int yychar)
3251 {
3252  int yyn = yypact[yystate];
3253 
3254  if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
3255  return 0;
3256  else
3257  {
3258  int yytype = YYTRANSLATE (yychar);
3259  YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
3260  YYSIZE_T yysize = yysize0;
3261  YYSIZE_T yysize1;
3262  int yysize_overflow = 0;
3263  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
3264  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
3265  int yyx;
3266 
3267 # if 0
3268  /* This is so xgettext sees the translatable formats that are
3269  constructed on the fly. */
3270  YY_("syntax error, unexpected %s");
3271  YY_("syntax error, unexpected %s, expecting %s");
3272  YY_("syntax error, unexpected %s, expecting %s or %s");
3273  YY_("syntax error, unexpected %s, expecting %s or %s or %s");
3274  YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
3275 # endif
3276  char *yyfmt;
3277  char const *yyf;
3278  static char const yyunexpected[] = "syntax error, unexpected %s";
3279  static char const yyexpecting[] = ", expecting %s";
3280  static char const yyor[] = " or %s";
3281  char yyformat[sizeof yyunexpected
3282  + sizeof yyexpecting - 1
3283  + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
3284  * (sizeof yyor - 1))];
3285  char const *yyprefix = yyexpecting;
3286 
3287  /* Start YYX at -YYN if negative to avoid negative indexes in
3288  YYCHECK. */
3289  int yyxbegin = yyn < 0 ? -yyn : 0;
3290 
3291  /* Stay within bounds of both yycheck and yytname. */
3292  int yychecklim = YYLAST - yyn + 1;
3293  int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
3294  int yycount = 1;
3295 
3296  yyarg[0] = yytname[yytype];
3297  yyfmt = yystpcpy (yyformat, yyunexpected);
3298 
3299  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
3300  if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3301  {
3302  if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
3303  {
3304  yycount = 1;
3305  yysize = yysize0;
3306  yyformat[sizeof yyunexpected - 1] = '\0';
3307  break;
3308  }
3309  yyarg[yycount++] = yytname[yyx];
3310  yysize1 = yysize + yytnamerr (0, yytname[yyx]);
3311  yysize_overflow |= (yysize1 < yysize);
3312  yysize = yysize1;
3313  yyfmt = yystpcpy (yyfmt, yyprefix);
3314  yyprefix = yyor;
3315  }
3316 
3317  yyf = YY_(yyformat);
3318  yysize1 = yysize + yystrlen (yyf);
3319  yysize_overflow |= (yysize1 < yysize);
3320  yysize = yysize1;
3321 
3322  if (yysize_overflow)
3323  return YYSIZE_MAXIMUM;
3324 
3325  if (yyresult)
3326  {
3327  /* Avoid sprintf, as that infringes on the user's name space.
3328  Don't have undefined behavior even if the translation
3329  produced a string with the wrong number of "%s"s. */
3330  char *yyp = yyresult;
3331  int yyi = 0;
3332  while ((*yyp = *yyf) != '\0')
3333  {
3334  if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
3335  {
3336  yyp += yytnamerr (yyp, yyarg[yyi++]);
3337  yyf += 2;
3338  }
3339  else
3340  {
3341  yyp++;
3342  yyf++;
3343  }
3344  }
3345  }
3346  return yysize;
3347  }
3348 }
3349 #endif /* YYERROR_VERBOSE */
3350 
3351 
3352 /*-----------------------------------------------.
3353 | Release the memory associated to this symbol. |
3354 `-----------------------------------------------*/
3355 
3356 /*ARGSUSED*/
3357 #if (defined __STDC__ || defined __C99__FUNC__ \
3358  || defined __cplusplus || defined _MSC_VER)
3359 static void
3360 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, ParserContext *const parseInfo)
3361 #else
3362 static void
3363 yydestruct (yymsg, yytype, yyvaluep, yylocationp, parseInfo)
3364  const char *yymsg;
3365  int yytype;
3366  YYSTYPE *yyvaluep;
3367  YYLTYPE *yylocationp;
3368  ParserContext *const parseInfo;
3369 #endif
3370 {
3371  YYUSE (yyvaluep);
3372  YYUSE (yylocationp);
3373  YYUSE (parseInfo);
3374 
3375  if (!yymsg)
3376  yymsg = "Deleting";
3377  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
3378 
3379  switch (yytype)
3380  {
3381 
3382  default:
3383  break;
3384  }
3385 }
3386 
3387 
3388 /* Prevent warnings from -Wmissing-prototypes. */
3389 
3390 #ifdef YYPARSE_PARAM
3391 #if defined __STDC__ || defined __cplusplus
3392 int yyparse (void *YYPARSE_PARAM);
3393 #else
3394 int yyparse ();
3395 #endif
3396 #else /* ! YYPARSE_PARAM */
3397 #if defined __STDC__ || defined __cplusplus
3398 int yyparse (ParserContext *const parseInfo);
3399 #else
3400 int yyparse ();
3401 #endif
3402 #endif /* ! YYPARSE_PARAM */
3403 
3404 
3405 
3406 
3407 
3408 
3409 /*----------.
3410 | yyparse. |
3411 `----------*/
3412 
3413 #ifdef YYPARSE_PARAM
3414 #if (defined __STDC__ || defined __C99__FUNC__ \
3415  || defined __cplusplus || defined _MSC_VER)
3416 int
3417 yyparse (void *YYPARSE_PARAM)
3418 #else
3419 int
3420 yyparse (YYPARSE_PARAM)
3421  void *YYPARSE_PARAM;
3422 #endif
3423 #else /* ! YYPARSE_PARAM */
3424 #if (defined __STDC__ || defined __C99__FUNC__ \
3425  || defined __cplusplus || defined _MSC_VER)
3426 int
3427 yyparse (ParserContext *const parseInfo)
3428 #else
3429 int
3430 yyparse (parseInfo)
3431  ParserContext *const parseInfo;
3432 #endif
3433 #endif
3434 {
3435  /* The lookahead symbol. */
3436 int yychar;
3437 
3438 /* The semantic value of the lookahead symbol. */
3439 YYSTYPE yylval;
3440 
3441 /* Number of syntax errors so far. */
3442 int yynerrs;
3443 /* Location data for the lookahead symbol. */
3444 YYLTYPE yylloc;
3445 
3446  int yystate;
3447  int yyn;
3448  int yyresult;
3449  /* Number of tokens to shift before error messages enabled. */
3450  int yyerrstatus;
3451  /* Lookahead token as an internal (translated) token number. */
3452  int yytoken = 0;
3453 #if YYERROR_VERBOSE
3454  /* Buffer for error messages, and its allocated size. */
3455  char yymsgbuf[128];
3456  char *yymsg = yymsgbuf;
3457  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
3458 #endif
3459 
3460  /* Three stacks and their tools:
3461  `yyss': related to states,
3462  `yyvs': related to semantic values,
3463  `yyls': related to locations.
3464 
3465  Refer to the stacks thru separate pointers, to allow yyoverflow
3466  to reallocate them elsewhere. */
3467 
3468  /* The state stack. */
3469  yytype_int16 yyssa[YYINITDEPTH];
3470  yytype_int16 *yyss = yyssa;
3471  yytype_int16 *yyssp;
3472 
3473  /* The semantic value stack. */
3474  YYSTYPE yyvsa[YYINITDEPTH];
3475  YYSTYPE *yyvs = yyvsa;
3476  YYSTYPE *yyvsp;
3477 
3478  /* The location stack. */
3479  YYLTYPE yylsa[YYINITDEPTH];
3480  YYLTYPE *yyls = yylsa;
3481  YYLTYPE *yylsp;
3482  /* The locations where the error started and ended. */
3483  YYLTYPE yyerror_range[2];
3484 
3485 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
3486 
3487  YYSIZE_T yystacksize = YYINITDEPTH;
3488 
3489  /* The variables used to return semantic value and location from the
3490  action routines. */
3491  YYSTYPE yyval;
3492  YYLTYPE yyloc;
3493 
3494  /* The number of symbols on the RHS of the reduced rule.
3495  Keep to zero when no symbol should be popped. */
3496  int yylen = 0;
3497 
3498  YYDPRINTF ((stderr, "Starting parse\n"));
3499 
3500  yystate = 0;
3501  yyerrstatus = 0;
3502  yynerrs = 0;
3503  yychar = YYEMPTY; /* Cause a token to be read. */
3504 
3505  /* Initialize stack pointers.
3506  Waste one element of value and location stack
3507  so that they stay on the same level as the state stack.
3508  The wasted elements are never initialized. */
3509 
3510  yyssp = yyss;
3511  yyvsp = yyvs;
3512  yylsp = yyls;
3513 #if YYLTYPE_IS_TRIVIAL
3514  /* Initialize the default location before parsing starts. */
3515  yylloc.first_line = yylloc.last_line = 1;
3516  yylloc.first_column = yylloc.last_column = 1;
3517 #endif
3518 
3519  goto yysetstate;
3520 
3521 /*------------------------------------------------------------.
3522 | yynewstate -- Push a new state, which is found in yystate. |
3523 `------------------------------------------------------------*/
3524  yynewstate:
3525  /* In all cases, when you get here, the value and location stacks
3526  have just been pushed. So pushing a state here evens the stacks. */
3527  yyssp++;
3528 
3529  yysetstate:
3530  *yyssp = yystate;
3531 
3532  if (yyss + yystacksize - 1 <= yyssp)
3533  {
3534  /* Get the current used size of the three stacks, in elements. */
3535  YYSIZE_T yysize = yyssp - yyss + 1;
3536 
3537 #ifdef yyoverflow
3538  {
3539  /* Give user a chance to reallocate the stack. Use copies of
3540  these so that the &'s don't force the real ones into
3541  memory. */
3542  YYSTYPE *yyvs1 = yyvs;
3543  yytype_int16 *yyss1 = yyss;
3544  YYLTYPE *yyls1 = yyls;
3545 
3546  /* Each stack pointer address is followed by the size of the
3547  data in use in that stack, in bytes. This used to be a
3548  conditional around just the two extra args, but that might
3549  be undefined if yyoverflow is a macro. */
3550  yyoverflow (YY_("memory exhausted"),
3551  &yyss1, yysize * sizeof (*yyssp),
3552  &yyvs1, yysize * sizeof (*yyvsp),
3553  &yyls1, yysize * sizeof (*yylsp),
3554  &yystacksize);
3555  yyls = yyls1;
3556  yyss = yyss1;
3557  yyvs = yyvs1;
3558  }
3559 #else /* no yyoverflow */
3560 # ifndef YYSTACK_RELOCATE
3561  goto yyexhaustedlab;
3562 # else
3563  /* Extend the stack our own way. */
3564  if (YYMAXDEPTH <= yystacksize)
3565  goto yyexhaustedlab;
3566  yystacksize *= 2;
3567  if (YYMAXDEPTH < yystacksize)
3568  yystacksize = YYMAXDEPTH;
3569 
3570  {
3571  yytype_int16 *yyss1 = yyss;
3572  union yyalloc *yyptr =
3573  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
3574  if (! yyptr)
3575  goto yyexhaustedlab;
3576  YYSTACK_RELOCATE (yyss);
3577  YYSTACK_RELOCATE (yyvs);
3578  YYSTACK_RELOCATE (yyls);
3579 # undef YYSTACK_RELOCATE
3580  if (yyss1 != yyssa)
3581  YYSTACK_FREE (yyss1);
3582  }
3583 # endif
3584 #endif /* no yyoverflow */
3585 
3586  yyssp = yyss + yysize - 1;
3587  yyvsp = yyvs + yysize - 1;
3588  yylsp = yyls + yysize - 1;
3589 
3590  YYDPRINTF ((stderr, "Stack size increased to %lu\n",
3591  (unsigned long int) yystacksize));
3592 
3593  if (yyss + yystacksize - 1 <= yyssp)
3594  YYABORT;
3595  }
3596 
3597  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
3598 
3599  if (yystate == YYFINAL)
3600  YYACCEPT;
3601 
3602  goto yybackup;
3603 
3604 /*-----------.
3605 | yybackup. |
3606 `-----------*/
3607 yybackup:
3608 
3609  /* Do appropriate processing given the current state. Read a
3610  lookahead token if we need one and don't already have one. */
3611 
3612  /* First try to decide what to do without reference to lookahead token. */
3613  yyn = yypact[yystate];
3614  if (yyn == YYPACT_NINF)
3615  goto yydefault;
3616 
3617  /* Not known => get a lookahead token if don't already have one. */
3618 
3619  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
3620  if (yychar == YYEMPTY)
3621  {
3622  YYDPRINTF ((stderr, "Reading a token: "));
3623  yychar = YYLEX;
3624  }
3625 
3626  if (yychar <= YYEOF)
3627  {
3628  yychar = yytoken = YYEOF;
3629  YYDPRINTF ((stderr, "Now at end of input.\n"));
3630  }
3631  else
3632  {
3633  yytoken = YYTRANSLATE (yychar);
3634  YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
3635  }
3636 
3637  /* If the proper action on seeing token YYTOKEN is to reduce or to
3638  detect an error, take that action. */
3639  yyn += yytoken;
3640  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
3641  goto yydefault;
3642  yyn = yytable[yyn];
3643  if (yyn <= 0)
3644  {
3645  if (yyn == 0 || yyn == YYTABLE_NINF)
3646  goto yyerrlab;
3647  yyn = -yyn;
3648  goto yyreduce;
3649  }
3650 
3651  /* Count tokens shifted since error; after three, turn off error
3652  status. */
3653  if (yyerrstatus)
3654  yyerrstatus--;
3655 
3656  /* Shift the lookahead token. */
3657  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
3658 
3659  /* Discard the shifted token. */
3660  yychar = YYEMPTY;
3661 
3662  yystate = yyn;
3663  *++yyvsp = yylval;
3664  *++yylsp = yylloc;
3665  goto yynewstate;
3666 
3667 
3668 /*-----------------------------------------------------------.
3669 | yydefault -- do the default action for the current state. |
3670 `-----------------------------------------------------------*/
3671 yydefault:
3672  yyn = yydefact[yystate];
3673  if (yyn == 0)
3674  goto yyerrlab;
3675  goto yyreduce;
3676 
3677 
3678 /*-----------------------------.
3679 | yyreduce -- Do a reduction. |
3680 `-----------------------------*/
3681 yyreduce:
3682  /* yyn is the number of a rule to reduce with. */
3683  yylen = yyr2[yyn];
3684 
3685  /* If YYLEN is nonzero, implement the default value of the action:
3686  `$$ = $1'.
3687 
3688  Otherwise, the following line sets YYVAL to garbage.
3689  This behavior is undocumented and Bison
3690  users should not rely upon it. Assigning to YYVAL
3691  unconditionally makes the parser a bit smaller, and it avoids a
3692  GCC warning that YYVAL may be used uninitialized. */
3693  yyval = yyvsp[1-yylen];
3694 
3695  /* Default location. */
3696  YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
3697  YY_REDUCE_PRINT (yyn);
3698  switch (yyn)
3699  {
3700  case 5:
3701 /* Line 1269 of yacc.c. */
3702 #line 1380 "querytransformparser.ypp"
3703  {
3704 
3705 /* Suppress more compiler warnings about unused defines. */
3706 #if defined(YYNNTS) \
3707  || defined(yyerrok) \
3708  || defined(YYNSTATES) \
3709  || defined(YYRHSLOC) \
3710  || defined(YYRECOVERING) \
3711  || defined(YYFAIL) \
3712  || defined(YYERROR) \
3713  || defined(YYNRULES) \
3714  || defined(YYBACKUP) \
3715  || defined(YYMAXDEPTH) \
3716  || defined(yyclearin) \
3717  || defined(YYERRCODE) \
3718  || defined(YY_LOCATION_PRINT) \
3719  || defined(YYLLOC_DEFAULT)
3720 #endif
3721 
3722  if((yyvsp[(3) - (5)].sval) != QLatin1String("1.0"))
3723  {
3724  const ReflectYYLTYPE ryy((yyloc), parseInfo);
3725 
3726  parseInfo->staticContext->error(QtXmlPatterns::tr("Version %1 is not supported. The supported "
3727  "XQuery version is 1.0.")
3728  .arg(formatData((yyvsp[(3) - (5)].sval))),
3729  ReportContext::XQST0031, &ryy);
3730  }
3731  }
3732  break;
3733 
3734  case 7:
3735 /* Line 1269 of yacc.c. */
3736 #line 1412 "querytransformparser.ypp"
3737  {
3738  const QRegExp encNameRegExp(QLatin1String("[A-Za-z][A-Za-z0-9._\\-]*"));
3739 
3740  if(!encNameRegExp.exactMatch((yyvsp[(2) - (2)].sval)))
3741  {
3742  parseInfo->staticContext->error(QtXmlPatterns::tr("The encoding %1 is invalid. "
3743  "It must contain Latin characters only, "
3744  "must not contain whitespace, and must match "
3745  "the regular expression %2.")
3746  .arg(formatKeyword((yyvsp[(2) - (2)].sval)),
3747  formatExpression(encNameRegExp.pattern())),
3748  ReportContext::XQST0087, fromYYLTYPE((yyloc), parseInfo));
3749  }
3750  }
3751  break;
3752 
3753  case 8:
3754 /* Line 1269 of yacc.c. */
3755 #line 1428 "querytransformparser.ypp"
3756  {
3757  /* In XSL-T, we can have dangling variable references, so resolve them
3758  * before we proceed with other steps, such as checking circularity. */
3759  if(parseInfo->isXSLT())
3760  {
3761  typedef QHash<QXmlName, Expression::Ptr> Hash;
3762  const Hash::const_iterator end(parseInfo->unresolvedVariableReferences.constEnd());
3763 
3764  for(Hash::const_iterator it(parseInfo->unresolvedVariableReferences.constBegin()); it != end; ++it)
3765  {
3766  const Expression::Ptr body(resolveVariable(it.key(), (yyloc), parseInfo, true)); // TODO source locations vaise
3767  Q_ASSERT(body);
3768  it.value()->as<UnresolvedVariableReference>()->bindTo(body);
3769  }
3770  }
3771 
3772  /* The UserFunction callsites aren't bound yet, so bind them(if possible!). */
3773  {
3774  const UserFunctionCallsite::List::const_iterator cend(parseInfo->userFunctionCallsites.constEnd());
3775  UserFunctionCallsite::List::const_iterator cit(parseInfo->userFunctionCallsites.constBegin());
3776  for(; cit != cend; ++cit) /* For each callsite. */
3777  {
3778  const UserFunctionCallsite::Ptr callsite(*cit);
3779  Q_ASSERT(callsite);
3780  const UserFunction::List::const_iterator end(parseInfo->userFunctions.constEnd());
3781  UserFunction::List::const_iterator it(parseInfo->userFunctions.constBegin());
3782 
3783  for(; it != end; ++it) /* For each UserFunction. */
3784  {
3785  const FunctionSignature::Ptr sign((*it)->signature());
3786  Q_ASSERT(sign);
3787 
3788  if(callsite->isSignatureValid(sign))
3789  {
3790  callsite->setSource((*it),
3791  parseInfo->allocateCacheSlots((*it)->argumentDeclarations().count()));
3792  break;
3793  }
3794  }
3795  if(it == end)
3796  {
3797  parseInfo->staticContext->error(QtXmlPatterns::tr("No function with signature %1 is available")
3798  .arg(formatFunction(callsite)),
3799  ReportContext::XPST0017, fromYYLTYPE((yyloc), parseInfo));
3800  }
3801  }
3802  }
3803 
3804  /* Mark callsites in UserFunction bodies as recursive, if they are. */
3805  {
3806  const UserFunction::List::const_iterator fend(parseInfo->userFunctions.constEnd());
3807  UserFunction::List::const_iterator fit(parseInfo->userFunctions.constBegin());
3808  for(; fit != fend; ++fit)
3809  {
3810  CallTargetDescription::List signList;
3811  signList.append((*fit)->signature());
3812  CallTargetDescription::checkCallsiteCircularity(signList, (*fit)->body());
3813  }
3814  }
3815 
3816  /* Now, check all global variables for circularity. This is done
3817  * backwards because global variables are only in scope below them,
3818  * in XQuery. */
3819  {
3820  const VariableDeclaration::List::const_iterator start(parseInfo->declaredVariables.constBegin());
3821  VariableDeclaration::List::const_iterator it(parseInfo->declaredVariables.constEnd());
3822 
3823  while(it != start)
3824  {
3825  --it;
3827  continue; /* We want to ignore 'external' variables. */
3828 
3829  FunctionSignature::List signList;
3830  checkVariableCircularity(*it, (*it)->expression(), (*it)->type, signList, parseInfo);
3831  ExpressionFactory::registerLastPath((*it)->expression());
3832  parseInfo->finalizePushedVariable(1, false); /* Warn if it's unused. */
3833  }
3834  }
3835 
3836  /* Generate code for doing initial template name calling. One problem
3837  * is that we compilation in the initial template name, since we throw away the
3838  * code if we don't have the requested template. */
3839  if(parseInfo->languageAccent == QXmlQuery::XSLT20
3840  && !parseInfo->initialTemplateName.isNull()
3841  && parseInfo->namedTemplates.contains(parseInfo->initialTemplateName))
3842  {
3843  parseInfo->queryBody = create(new CallTemplate(parseInfo->initialTemplateName,
3844  WithParam::Hash()),
3845  (yyloc), parseInfo);
3846  parseInfo->templateCalls.append(parseInfo->queryBody);
3847  /* We just discard the template body that XSLTTokenizer generated. */
3848  }
3849  else
3850  parseInfo->queryBody = (yyvsp[(2) - (2)].expr);
3851  }
3852  break;
3853 
3854  case 10:
3855 /* Line 1269 of yacc.c. */
3856 #line 1528 "querytransformparser.ypp"
3857  {
3858  // TODO add to namespace context
3859  parseInfo->moduleNamespace = parseInfo->staticContext->namePool()->allocateNamespace((yyvsp[(3) - (6)].sval));
3860  }
3861  break;
3862 
3863  case 12:
3864 /* Line 1269 of yacc.c. */
3865 #line 1536 "querytransformparser.ypp"
3866  {
3867  allowedIn(QXmlQuery::XQuery10, parseInfo, (yyloc));
3868  if(parseInfo->hasSecondPrologPart)
3869  parseInfo->staticContext->error(QtXmlPatterns::tr("A default namespace declaration must occur before function, "
3870  "variable, and option declarations."), ReportContext::XPST0003, fromYYLTYPE((yyloc), parseInfo));
3871  }
3872  break;
3873 
3874  case 13:
3875 /* Line 1269 of yacc.c. */
3876 #line 1543 "querytransformparser.ypp"
3877  {
3878  if(parseInfo->hasSecondPrologPart)
3879  parseInfo->staticContext->error(QtXmlPatterns::tr("A default namespace declaration must occur before function, "
3880  "variable, and option declarations."), ReportContext::XPST0003, fromYYLTYPE((yyloc), parseInfo));
3881  }
3882  break;
3883 
3884  case 14:
3885 /* Line 1269 of yacc.c. */
3886 #line 1549 "querytransformparser.ypp"
3887  {
3888  if(parseInfo->hasSecondPrologPart)
3889  parseInfo->staticContext->error(QtXmlPatterns::tr("Namespace declarations must occur before function, "
3890  "variable, and option declarations."), ReportContext::XPST0003, fromYYLTYPE((yyloc), parseInfo));
3891  }
3892  break;
3893 
3894  case 15:
3895 /* Line 1269 of yacc.c. */
3896 #line 1555 "querytransformparser.ypp"
3897  {
3898  allowedIn(QXmlQuery::XQuery10, parseInfo, (yyloc));
3899  if(parseInfo->hasSecondPrologPart)
3900  parseInfo->staticContext->error(QtXmlPatterns::tr("Module imports must occur before function, "
3901  "variable, and option declarations."), ReportContext::XPST0003, fromYYLTYPE((yyloc), parseInfo));
3902  }
3903  break;
3904 
3905  case 17:
3906 /* Line 1269 of yacc.c. */
3907 #line 1565 "querytransformparser.ypp"
3908  {
3909  parseInfo->hasSecondPrologPart = true;
3910  }
3911  break;
3912 
3913  case 18:
3914 /* Line 1269 of yacc.c. */
3915 #line 1569 "querytransformparser.ypp"
3916  {
3917  parseInfo->hasSecondPrologPart = true;
3918  }
3919  break;
3920 
3921  case 19:
3922 /* Line 1269 of yacc.c. */
3923 #line 1573 "querytransformparser.ypp"
3924  {
3925  allowedIn(QXmlQuery::XQuery10, parseInfo, (yyloc));
3926  parseInfo->hasSecondPrologPart = true;
3927  }
3928  break;
3929 
3930  case 20:
3931 /* Line 1269 of yacc.c. */
3932 #line 1596 "querytransformparser.ypp"
3933  {
3934  Template::Ptr temp(create(new Template(parseInfo->currentImportPrecedence, (yyvsp[(5) - (7)].sequenceType)), (yyloc), parseInfo));
3935 
3936  registerNamedTemplate((yyvsp[(3) - (7)].qName), typeCheckTemplateBody((yyvsp[(6) - (7)].expr), (yyvsp[(5) - (7)].sequenceType), parseInfo),
3937  parseInfo, (yylsp[(1) - (7)]), temp);
3938  temp->templateParameters = parseInfo->templateParameters;
3939  parseInfo->templateParametersHandled();
3940  }
3941  break;
3942 
3943  case 21:
3944 /* Line 1269 of yacc.c. */
3945 #line 1606 "querytransformparser.ypp"
3946  {
3947  parseInfo->isParsingPattern = true;
3948  }
3949  break;
3950 
3951  case 22:
3952 /* Line 1269 of yacc.c. */
3953 #line 1610 "querytransformparser.ypp"
3954  {
3955  parseInfo->isParsingPattern = false;
3956  }
3957  break;
3958 
3959  case 23:
3960 /* Line 1269 of yacc.c. */
3961 #line 1619 "querytransformparser.ypp"
3962  {
3963  /* In this grammar branch, we're guaranteed to be a template rule, but
3964  * may also be a named template. */
3965 
3966  const ImportPrecedence ip = parseInfo->isFirstTemplate() ? 0 : parseInfo->currentImportPrecedence;
3967  Expression::Ptr pattern((yyvsp[(7) - (15)].expr));
3968  const TemplatePattern::ID templateID = parseInfo->allocateTemplateID();
3969 
3970  Template::Ptr templ(create(new Template(ip, (yyvsp[(13) - (15)].sequenceType)), (yyloc), parseInfo));
3971  templ->body = typeCheckTemplateBody((yyvsp[(14) - (15)].expr), (yyvsp[(13) - (15)].sequenceType), parseInfo);
3972  templ->templateParameters = parseInfo->templateParameters;
3973  parseInfo->templateParametersHandled();
3974 
3975  TemplatePattern::Vector ourPatterns;
3976  /* We do it as per 6.4 Conflict Resolution for Template Rules:
3977  *
3978  * "If the pattern contains multiple alternatives separated by |, then
3979  * the template rule is treated equivalently to a set of template
3980  * rules, one for each alternative. However, it is not an error if a
3981  * node matches more than one of the alternatives." */
3982  while(pattern->is(Expression::IDCombineNodes))
3983  {
3984  const Expression::List operands(pattern->operands());
3985  pattern = operands.first();
3986 
3987  loadPattern(operands.at(1), ourPatterns, templateID, (yyvsp[(11) - (15)].enums.Double), templ);
3988  }
3989 
3990  loadPattern(pattern, ourPatterns, templateID, (yyvsp[(11) - (15)].enums.Double), templ);
3991 
3992  if(!(yyvsp[(3) - (15)].qName).isNull())
3993  registerNamedTemplate((yyvsp[(3) - (15)].qName), (yyvsp[(14) - (15)].expr), parseInfo, (yylsp[(1) - (15)]), templ);
3994 
3995  /* Now, let's add it to all the relevant templates. */
3996  for(int i = 0; i < (yyvsp[(10) - (15)].qNameVector).count(); ++i) /* For each mode. */
3997  {
3998  const QXmlName &modeName = (yyvsp[(10) - (15)].qNameVector).at(i);
3999 
4000  if(modeName == QXmlName(StandardNamespaces::InternalXSLT, StandardLocalNames::all) && (yyvsp[(10) - (15)].qNameVector).count() > 1)
4001  {
4002  parseInfo->staticContext->error(QtXmlPatterns::tr("The keyword %1 cannot occur with any other mode name.")
4003  .arg(formatKeyword(QLatin1String("#all"))),
4005  fromYYLTYPE((yyloc), parseInfo));
4006  }
4007 
4008  /* For each pattern the template use. */
4009  const TemplateMode::Ptr mode(parseInfo->modeFor(modeName));
4010  for(int t = 0; t < ourPatterns.count(); ++t)
4011  mode->templatePatterns.append(ourPatterns.at(t));
4012  }
4013  }
4014  break;
4015 
4016  case 24:
4017 /* Line 1269 of yacc.c. */
4018 #line 1673 "querytransformparser.ypp"
4019  {
4020  (yyval.enums.Double) = std::numeric_limits<xsDouble>::quiet_NaN();
4021  }
4022  break;
4023 
4024  case 25:
4025 /* Line 1269 of yacc.c. */
4026 #line 1678 "querytransformparser.ypp"
4027  {
4028  const AtomicValue::Ptr val(Decimal::fromLexical((yyvsp[(2) - (2)].sval)));
4029  if(val->hasError())
4030  {
4031  parseInfo->staticContext->error(QtXmlPatterns::tr("The value of attribute %1 must be of type %2, which %3 isn't.")
4032  .arg(formatKeyword(QLatin1String("priority")),
4033  formatType(parseInfo->staticContext->namePool(), BuiltinTypes::xsDecimal),
4034  formatData((yyvsp[(2) - (2)].sval))),
4036  fromYYLTYPE((yyloc), parseInfo));
4037  }
4038  else
4039  (yyval.enums.Double) = val->as<Numeric>()->toDouble();
4040  }
4041  break;
4042 
4043  case 26:
4044 /* Line 1269 of yacc.c. */
4045 #line 1694 "querytransformparser.ypp"
4046  {
4047  (yyval.qName) = QXmlName();
4048  }
4049  break;
4050 
4051  case 28:
4052 /* Line 1269 of yacc.c. */
4053 #line 1700 "querytransformparser.ypp"
4054  {
4055  (yyval.qName) = (yyvsp[(2) - (2)].qName);
4056  }
4057  break;
4058 
4059  case 30:
4060 /* Line 1269 of yacc.c. */
4061 #line 1706 "querytransformparser.ypp"
4062  {
4063  allowedIn(QXmlQuery::XQuery10, parseInfo, (yyloc));
4064  }
4065  break;
4066 
4067  case 32:
4068 /* Line 1269 of yacc.c. */
4069 #line 1711 "querytransformparser.ypp"
4070  {
4071  allowedIn(QXmlQuery::XQuery10, parseInfo, (yyloc));
4072  }
4073  break;
4074 
4075  case 33:
4076 /* Line 1269 of yacc.c. */
4077 #line 1715 "querytransformparser.ypp"
4078  {
4079  allowedIn(QXmlQuery::XQuery10, parseInfo, (yyloc));
4080  }
4081  break;
4082 
4083  case 34:
4084 /* Line 1269 of yacc.c. */
4085 #line 1719 "querytransformparser.ypp"
4086  {
4087  allowedIn(QXmlQuery::XQuery10, parseInfo, (yyloc));
4088  }
4089  break;
4090 
4091  case 39:
4092 /* Line 1269 of yacc.c. */
4093 #line 1730 "querytransformparser.ypp"
4094  {
4095  if(!(yyvsp[(6) - (7)].enums.Bool))
4096  allowedIn(QXmlQuery::XQuery10, parseInfo, (yyloc));
4097 
4098  if((yyvsp[(3) - (7)].sval) == QLatin1String("xmlns"))
4099  {
4100  parseInfo->staticContext->error(QtXmlPatterns::tr("It is not possible to redeclare prefix %1.")
4101  .arg(formatKeyword(QLatin1String("xmlns"))),
4102  ReportContext::XQST0070, fromYYLTYPE((yyloc), parseInfo));
4103  }
4104  else if ((yyvsp[(5) - (7)].sval) == CommonNamespaces::XML || (yyvsp[(3) - (7)].sval) == QLatin1String("xml"))
4105  {
4106  parseInfo->staticContext->error(QtXmlPatterns::tr(
4107  "The prefix %1 cannot be bound. By default, it is already bound "
4108  "to the namespace %2.")
4109  .arg(formatKeyword("xml"))
4112  fromYYLTYPE((yyloc), parseInfo));
4113  }
4114  else if(parseInfo->declaredPrefixes.contains((yyvsp[(3) - (7)].sval)))
4115  {
4116  /* This includes the case where the user has bound a default prefix(such
4117  * as 'local') and now tries to do it again. */
4118  parseInfo->staticContext->error(QtXmlPatterns::tr("Prefix %1 is already declared in the prolog.")
4119  .arg(formatKeyword((yyvsp[(3) - (7)].sval))),
4120  ReportContext::XQST0033, fromYYLTYPE((yyloc), parseInfo));
4121  }
4122  else
4123  {
4124  parseInfo->declaredPrefixes.append((yyvsp[(3) - (7)].sval));
4125 
4126  if((yyvsp[(5) - (7)].sval).isEmpty())
4127  {
4128  parseInfo->staticContext->namespaceBindings()->addBinding(QXmlName(StandardNamespaces::UndeclarePrefix,
4130  parseInfo->staticContext->namePool()->allocatePrefix((yyvsp[(3) - (7)].sval))));
4131  }
4132  else
4133  {
4134  parseInfo->staticContext->namespaceBindings()->addBinding(parseInfo->staticContext->namePool()->allocateBinding((yyvsp[(3) - (7)].sval), (yyvsp[(5) - (7)].sval)));
4135  }
4136  }
4137  }
4138  break;
4139 
4140  case 40:
4141 /* Line 1269 of yacc.c. */
4142 #line 1776 "querytransformparser.ypp"
4143  {
4144  if(parseInfo->hasDeclaration(ParserContext::BoundarySpaceDecl))
4145  {
4146  parseInfo->staticContext->error(prologMessage("declare boundary-space"),
4147  ReportContext::XQST0068, fromYYLTYPE((yyloc), parseInfo));
4148  }
4149  else
4150  {
4151  parseInfo->staticContext->setBoundarySpacePolicy((yyvsp[(3) - (4)].enums.boundarySpacePolicy));
4152  parseInfo->registerDeclaration(ParserContext::BoundarySpaceDecl);
4153  }
4154  }
4155  break;
4156 
4157  case 41:
4158 /* Line 1269 of yacc.c. */
4159 #line 1790 "querytransformparser.ypp"
4160  {
4161  (yyval.enums.boundarySpacePolicy) = StaticContext::BSPStrip;
4162  }
4163  break;
4164 
4165  case 42:
4166 /* Line 1269 of yacc.c. */
4167 #line 1795 "querytransformparser.ypp"
4168  {
4169  (yyval.enums.boundarySpacePolicy) = StaticContext::BSPPreserve;
4170  }
4171  break;
4172 
4173  case 45:
4174 /* Line 1269 of yacc.c. */
4175 #line 1804 "querytransformparser.ypp"
4176  {
4177  if(parseInfo->hasDeclaration(ParserContext::DeclareDefaultElementNamespace))
4178  {
4179  parseInfo->staticContext->error(prologMessage("declare default element namespace"),
4180  ReportContext::XQST0066, fromYYLTYPE((yyloc), parseInfo));
4181  }
4182  else
4183  {
4184  parseInfo->staticContext->namespaceBindings()->addBinding(QXmlName(parseInfo->staticContext->namePool()->allocateNamespace((yyvsp[(5) - (6)].sval)), StandardLocalNames::empty));
4185  parseInfo->registerDeclaration(ParserContext::DeclareDefaultElementNamespace);
4186  }
4187  }
4188  break;
4189 
4190  case 46:
4191 /* Line 1269 of yacc.c. */
4192 #line 1819 "querytransformparser.ypp"
4193  {
4194  if(parseInfo->hasDeclaration(ParserContext::DeclareDefaultFunctionNamespace))
4195  {
4196  parseInfo->staticContext->error(prologMessage("declare default function namespace"),
4197  ReportContext::XQST0066, fromYYLTYPE((yyloc), parseInfo));
4198  }
4199  else
4200  {
4201  parseInfo->staticContext->setDefaultFunctionNamespace((yyvsp[(5) - (6)].sval));
4202  parseInfo->registerDeclaration(ParserContext::DeclareDefaultFunctionNamespace);
4203  }
4204  }
4205  break;
4206 
4207  case 47:
4208 /* Line 1269 of yacc.c. */
4209 #line 1833 "querytransformparser.ypp"
4210  {
4211  if((yyvsp[(3) - (5)].qName).prefix() == StandardPrefixes::empty)
4212  {
4213  parseInfo->staticContext->error(QtXmlPatterns::tr("The name of an option must have a prefix. "
4214  "There is no default namespace for options."),
4215  ReportContext::XPST0081, fromYYLTYPE((yyloc), parseInfo));
4216  }
4217  }
4218  break;
4219 
4220  case 48:
4221 /* Line 1269 of yacc.c. */
4222 #line 1843 "querytransformparser.ypp"
4223  {
4224  allowedIn(QXmlQuery::XQuery10, parseInfo, (yyloc));
4225  if(parseInfo->hasDeclaration(ParserContext::OrderingModeDecl))
4226  {
4227  parseInfo->staticContext->error(prologMessage("declare ordering"),
4228  ReportContext::XQST0065, fromYYLTYPE((yyloc), parseInfo));
4229  }
4230  else
4231  {
4232  parseInfo->registerDeclaration(ParserContext::OrderingModeDecl);
4233  parseInfo->staticContext->setOrderingMode((yyvsp[(3) - (4)].enums.orderingMode));
4234  }
4235  }
4236  break;
4237 
4238  case 49:
4239 /* Line 1269 of yacc.c. */
4240 #line 1858 "querytransformparser.ypp"
4241  {
4242  (yyval.enums.orderingMode) = StaticContext::Ordered;
4243  }
4244  break;
4245 
4246  case 50:
4247 /* Line 1269 of yacc.c. */
4248 #line 1862 "querytransformparser.ypp"
4249  {
4250  (yyval.enums.orderingMode) = StaticContext::Unordered;
4251  }
4252  break;
4253 
4254  case 51:
4255 /* Line 1269 of yacc.c. */
4256 #line 1867 "querytransformparser.ypp"
4257  {
4258  if(parseInfo->hasDeclaration(ParserContext::EmptyOrderDecl))
4259  {
4260  parseInfo->staticContext->error(prologMessage("declare default order"),
4261  ReportContext::XQST0069, fromYYLTYPE((yyloc), parseInfo));
4262  }
4263  else
4264  {
4265  parseInfo->registerDeclaration(ParserContext::EmptyOrderDecl);
4266  parseInfo->staticContext->setOrderingEmptySequence((yyvsp[(4) - (5)].enums.orderingEmptySequence));
4267  }
4268  }
4269  break;
4270 
4271  case 52:
4272 /* Line 1269 of yacc.c. */
4273 #line 1881 "querytransformparser.ypp"
4274  {
4275  (yyval.enums.orderingEmptySequence) = StaticContext::Least;
4276  }
4277  break;
4278 
4279  case 53:
4280 /* Line 1269 of yacc.c. */
4281 #line 1885 "querytransformparser.ypp"
4282  {
4283  (yyval.enums.orderingEmptySequence) = StaticContext::Greatest;
4284  }
4285  break;
4286 
4287  case 54:
4288 /* Line 1269 of yacc.c. */
4289 #line 1891 "querytransformparser.ypp"
4290  {
4291  if(parseInfo->hasDeclaration(ParserContext::CopyNamespacesDecl))
4292  {
4293  parseInfo->staticContext->error(prologMessage("declare copy-namespaces"),
4294  ReportContext::XQST0055, fromYYLTYPE((yyloc), parseInfo));
4295  }
4296  else
4297  {
4298  parseInfo->registerDeclaration(ParserContext::CopyNamespacesDecl);
4299  }
4300  }
4301  break;
4302 
4303  case 55:
4304 /* Line 1269 of yacc.c. */
4305 #line 1904 "querytransformparser.ypp"
4306  {
4307  parseInfo->preserveNamespacesMode = true;
4308  }
4309  break;
4310 
4311  case 56:
4312 /* Line 1269 of yacc.c. */
4313 #line 1909 "querytransformparser.ypp"
4314  {
4315  parseInfo->preserveNamespacesMode = false;
4316  }
4317  break;
4318 
4319  case 57:
4320 /* Line 1269 of yacc.c. */
4321 #line 1914 "querytransformparser.ypp"
4322  {
4323  parseInfo->inheritNamespacesMode = true;
4324  }
4325  break;
4326 
4327  case 58:
4328 /* Line 1269 of yacc.c. */
4329 #line 1919 "querytransformparser.ypp"
4330  {
4331  parseInfo->inheritNamespacesMode = false;
4332  }
4333  break;
4334 
4335  case 59:
4336 /* Line 1269 of yacc.c. */
4337 #line 1924 "querytransformparser.ypp"
4338  {
4339  if(parseInfo->hasDeclaration(ParserContext::DefaultCollationDecl))
4340  {
4341  parseInfo->staticContext->error(prologMessage("declare default collation"),
4342  ReportContext::XQST0038, fromYYLTYPE((yyloc), parseInfo));
4343  }
4344  else
4345  {
4346  const QUrl coll(resolveAndCheckCollation<ReportContext::XQST0038>((yyvsp[(4) - (5)].sval), parseInfo, (yyloc)));
4347 
4348  parseInfo->registerDeclaration(ParserContext::DefaultCollationDecl);
4349  parseInfo->staticContext->setDefaultCollation(coll);
4350  }
4351  }
4352  break;
4353 
4354  case 60:
4355 /* Line 1269 of yacc.c. */
4356 #line 1940 "querytransformparser.ypp"
4357  {
4358  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XSLT20), parseInfo, (yyloc), (yyvsp[(3) - (5)].enums.Bool));
4359  if(parseInfo->hasDeclaration(ParserContext::BaseURIDecl))
4360  {
4361  parseInfo->staticContext->error(prologMessage("declare base-uri"),
4362  ReportContext::XQST0032, fromYYLTYPE((yyloc), parseInfo));
4363  }
4364  else
4365  {
4366  parseInfo->registerDeclaration(ParserContext::BaseURIDecl);
4367  const ReflectYYLTYPE ryy((yyloc), parseInfo);
4368 
4369  QUrl toBeBase(AnyURI::toQUrl<ReportContext::XQST0046>((yyvsp[(4) - (5)].sval), parseInfo->staticContext, &ryy));
4370  /* Now we're guaranteed that base is a valid lexical representation, but it can still be relative. */
4371 
4372  if(toBeBase.isRelative())
4373  toBeBase = parseInfo->staticContext->baseURI().resolved(toBeBase);
4374 
4375  parseInfo->staticContext->setBaseURI(toBeBase);
4376  }
4377  }
4378  break;
4379 
4380  case 61:
4381 /* Line 1269 of yacc.c. */
4382 #line 1963 "querytransformparser.ypp"
4383  {
4384  parseInfo->staticContext->error(QtXmlPatterns::tr("The Schema Import feature is not supported, "
4385  "and therefore %1 declarations cannot occur.")
4386  .arg(formatKeyword("import schema")),
4387  ReportContext::XQST0009, fromYYLTYPE((yyloc), parseInfo));
4388  }
4389  break;
4390 
4391  case 65:
4392 /* Line 1269 of yacc.c. */
4393 #line 1975 "querytransformparser.ypp"
4394  {
4395  if((yyvsp[(4) - (6)].sval).isEmpty())
4396  {
4397  parseInfo->staticContext->error(QtXmlPatterns::tr("The target namespace of a %1 cannot be empty.")
4398  .arg(formatKeyword("module import")),
4399  ReportContext::XQST0088, fromYYLTYPE((yyloc), parseInfo));
4400 
4401  }
4402  else
4403  {
4404  /* This is temporary until we have implemented it. */
4405  parseInfo->staticContext->error(QtXmlPatterns::tr("The module import feature is not supported"),
4406  ReportContext::XQST0016, fromYYLTYPE((yyloc), parseInfo));
4407  }
4408  }
4409  break;
4410 
4411  case 72:
4412 /* Line 1269 of yacc.c. */
4413 #line 2002 "querytransformparser.ypp"
4414  {
4415  allowedIn(QXmlQuery::XQuery10, parseInfo, (yyloc), (yyvsp[(3) - (9)].enums.Bool));
4416  if(variableByName((yyvsp[(5) - (9)].qName), parseInfo))
4417  {
4418  parseInfo->staticContext->error(QtXmlPatterns::tr("A variable with name %1 has already "
4419  "been declared.")
4420  .arg(formatKeyword(parseInfo->staticContext->namePool()->toLexical((yyvsp[(5) - (9)].qName)))),
4421  parseInfo->isXSLT() ? ReportContext::XTSE0630 : ReportContext::XQST0049,
4422  fromYYLTYPE((yyloc), parseInfo));
4423  }
4424  else
4425  {
4426  if((yyvsp[(7) - (9)].expr)) /* We got a value assigned. */
4427  {
4428  const Expression::Ptr checked
4429  (TypeChecker::applyFunctionConversion((yyvsp[(7) - (9)].expr), (yyvsp[(6) - (9)].sequenceType), parseInfo->staticContext,
4430  (yyvsp[(3) - (9)].enums.Bool) ? ReportContext::XTTE0570 : ReportContext::XPTY0004,
4432 
4433  pushVariable((yyvsp[(5) - (9)].qName), (yyvsp[(6) - (9)].sequenceType), checked, VariableDeclaration::GlobalVariable, (yyloc), parseInfo);
4434  parseInfo->declaredVariables.append(parseInfo->variables.last());
4435  }
4436  else /* We got an 'external' declaration. */
4437  {
4438  const SequenceType::Ptr varType(parseInfo->staticContext->
4439  externalVariableLoader()->announceExternalVariable((yyvsp[(5) - (9)].qName), (yyvsp[(6) - (9)].sequenceType)));
4440 
4441  if(varType)
4442  {
4443  /* We push the declaration such that we can see name clashes and so on, but we don't use it for tying
4444  * any references to it. */
4445  pushVariable((yyvsp[(5) - (9)].qName), varType, Expression::Ptr(), VariableDeclaration::ExternalVariable, (yyloc), parseInfo);
4446  }
4447  else if((yyvsp[(8) - (9)].expr))
4448  {
4449  /* Ok, the xsl:param got a default value, we make it
4450  * available as a regular variable declaration. */
4451  // TODO turn into checked
4452  pushVariable((yyvsp[(5) - (9)].qName), (yyvsp[(6) - (9)].sequenceType), (yyvsp[(8) - (9)].expr), VariableDeclaration::GlobalVariable, (yyloc), parseInfo);
4453  // TODO ensure that duplicates are trapped.
4454  }
4455  else
4456  {
4457  parseInfo->staticContext->error(QtXmlPatterns::tr("No value is available for the external "
4458  "variable with name %1.")
4459  .arg(formatKeyword(parseInfo->staticContext->namePool(), (yyvsp[(5) - (9)].qName))),
4460  parseInfo->isXSLT() ? ReportContext::XTDE0050 : ReportContext::XPDY0002,
4461  fromYYLTYPE((yyloc), parseInfo));
4462  }
4463  }
4464  }
4465  }
4466  break;
4467 
4468  case 73:
4469 /* Line 1269 of yacc.c. */
4470 #line 2056 "querytransformparser.ypp"
4471  {
4472  (yyval.expr).reset();
4473  }
4474  break;
4475 
4476  case 74:
4477 /* Line 1269 of yacc.c. */
4478 #line 2060 "querytransformparser.ypp"
4479  {
4480  (yyval.expr) = (yyvsp[(2) - (2)].expr);
4481  }
4482  break;
4483 
4484  case 75:
4485 /* Line 1269 of yacc.c. */
4486 #line 2065 "querytransformparser.ypp"
4487  {
4488  (yyval.expr).reset();
4489  }
4490  break;
4491 
4492  case 76:
4493 /* Line 1269 of yacc.c. */
4494 #line 2069 "querytransformparser.ypp"
4495  {
4496  (yyval.expr) = (yyvsp[(2) - (2)].expr);
4497  }
4498  break;
4499 
4500  case 77:
4501 /* Line 1269 of yacc.c. */
4502 #line 2074 "querytransformparser.ypp"
4503  {
4504  if(parseInfo->hasDeclaration(ParserContext::ConstructionDecl))
4505  {
4506  parseInfo->staticContext->error(prologMessage("declare ordering"),
4507  ReportContext::XQST0067, fromYYLTYPE((yyloc), parseInfo));
4508  }
4509  else
4510  {
4511  parseInfo->registerDeclaration(ParserContext::ConstructionDecl);
4512  parseInfo->staticContext->setConstructionMode((yyvsp[(3) - (4)].enums.constructionMode));
4513  }
4514  }
4515  break;
4516 
4517  case 78:
4518 /* Line 1269 of yacc.c. */
4519 #line 2088 "querytransformparser.ypp"
4520  {
4521  (yyval.enums.constructionMode) = StaticContext::CMStrip;
4522  }
4523  break;
4524 
4525  case 79:
4526 /* Line 1269 of yacc.c. */
4527 #line 2092 "querytransformparser.ypp"
4528  {
4529  (yyval.enums.constructionMode) = StaticContext::CMPreserve;
4530  }
4531  break;
4532 
4533  case 80:
4534 /* Line 1269 of yacc.c. */
4535 #line 2097 "querytransformparser.ypp"
4536  {
4537  (yyval.enums.slot) = parseInfo->currentExpressionSlot() - (yyvsp[(6) - (7)].functionArguments).count();
4538  }
4539  break;
4540 
4541  case 81:
4542 /* Line 1269 of yacc.c. */
4543 #line 2101 "querytransformparser.ypp"
4544  {
4545  if(!(yyvsp[(3) - (11)].enums.Bool))
4546  allowedIn(QXmlQuery::XQuery10, parseInfo, (yyloc), (yyvsp[(3) - (11)].enums.Bool));
4547 
4548  /* If FunctionBody is null, it is 'external', otherwise the value is the body. */
4549  const QXmlName::NamespaceCode ns((yyvsp[(4) - (11)].qName).namespaceURI());
4550 
4551  if(parseInfo->isXSLT() && !(yyvsp[(4) - (11)].qName).hasPrefix())
4552  {
4553  parseInfo->staticContext->error(QtXmlPatterns::tr("A stylesheet function must have a prefixed name."),
4555  fromYYLTYPE((yyloc), parseInfo));
4556  }
4557 
4558  if((yyvsp[(10) - (11)].expr)) /* We got a function body. */
4559  {
4560  if(ns == StandardNamespaces::empty)
4561  {
4562  parseInfo->staticContext->error(QtXmlPatterns::tr("The namespace for a user defined function "
4563  "cannot be empty (try the predefined "
4564  "prefix %1, which exists for cases "
4565  "like this)")
4566  .arg(formatKeyword("local")),
4567  ReportContext::XQST0060, fromYYLTYPE((yyloc), parseInfo));
4568  }
4570  {
4571  parseInfo->staticContext->error(QtXmlPatterns::tr(
4572  "The namespace %1 is reserved; therefore "
4573  "user defined functions may not use it. "
4574  "Try the predefined prefix %2, which "
4575  "exists for these cases.")
4576  .arg(formatURI(parseInfo->staticContext->namePool(), ns), formatKeyword("local")),
4577  parseInfo->isXSLT() ? ReportContext::XTSE0080 : ReportContext::XQST0045,
4578  fromYYLTYPE((yyloc), parseInfo));
4579  }
4580  else if(parseInfo->moduleNamespace != StandardNamespaces::empty &&
4581  ns != parseInfo->moduleNamespace)
4582  {
4583  parseInfo->staticContext->error(QtXmlPatterns::tr(
4584  "The namespace of a user defined "
4585  "function in a library module must be "
4586  "equivalent to the module namespace. "
4587  "In other words, it should be %1 instead "
4588  "of %2")
4589  .arg(formatURI(parseInfo->staticContext->namePool(), parseInfo->moduleNamespace),
4590  formatURI(parseInfo->staticContext->namePool(), ns)),
4591  ReportContext::XQST0048, fromYYLTYPE((yyloc), parseInfo));
4592  }
4593  else
4594  {
4595  /* Apply function conversion such that the body matches the declared
4596  * return type. */
4597  const Expression::Ptr checked(TypeChecker::applyFunctionConversion((yyvsp[(10) - (11)].expr), (yyvsp[(9) - (11)].sequenceType),
4598  parseInfo->staticContext,
4603 
4604  const int argCount = (yyvsp[(6) - (11)].functionArguments).count();
4605  const FunctionSignature::Ptr sign(new FunctionSignature((yyvsp[(4) - (11)].qName) /* name */,
4606  argCount /* minArgs */,
4607  argCount /* maxArgs */,
4608  (yyvsp[(9) - (11)].sequenceType) /* returnType */));
4609  sign->setArguments((yyvsp[(6) - (11)].functionArguments));
4610  const UserFunction::List::const_iterator end(parseInfo->userFunctions.constEnd());
4611  UserFunction::List::const_iterator it(parseInfo->userFunctions.constBegin());
4612 
4613  for(; it != end; ++it)
4614  {
4615  if(*(*it)->signature() == *sign)
4616  {
4617  parseInfo->staticContext->error(QtXmlPatterns::tr("A function already exists with "
4618  "the signature %1.")
4619  .arg(formatFunction(parseInfo->staticContext->namePool(), sign)),
4620  parseInfo->isXSLT() ? ReportContext::XTSE0770 : ReportContext::XQST0034, fromYYLTYPE((yyloc), parseInfo));
4621  }
4622  }
4623 
4624  VariableDeclaration::List argDecls;
4625 
4626  for(int i = 0; i < argCount; ++i)
4627  argDecls.append(parseInfo->variables.at(i));
4628 
4629  if((yyvsp[(8) - (11)].enums.slot) > -1)
4630  {
4631  /* We have allocated slots, so now push them out of scope. */
4632  parseInfo->finalizePushedVariable(argCount);
4633  }
4634 
4635  parseInfo->userFunctions.append(UserFunction::Ptr(new UserFunction(sign, checked, (yyvsp[(8) - (11)].enums.slot), argDecls)));
4636  }
4637  }
4638  else /* We got an 'external' declaration. */
4639  {
4640  parseInfo->staticContext->error(QtXmlPatterns::tr("No external functions are supported. "
4641  "All supported functions can be used directly, "
4642  "without first declaring them as external"),
4643  ReportContext::XPST0017, fromYYLTYPE((yyloc), parseInfo));
4644  }
4645  }
4646  break;
4647 
4648  case 82:
4649 /* Line 1269 of yacc.c. */
4650 #line 2205 "querytransformparser.ypp"
4651  {
4652  (yyval.functionArguments) = FunctionArgument::List();
4653  }
4654  break;
4655 
4656  case 83:
4657 /* Line 1269 of yacc.c. */
4658 #line 2209 "querytransformparser.ypp"
4659  {
4661  l.append((yyvsp[(1) - (1)].functionArgument));
4662  (yyval.functionArguments) = l;
4663  }
4664  break;
4665 
4666  case 84:
4667 /* Line 1269 of yacc.c. */
4668 #line 2215 "querytransformparser.ypp"
4669  {
4670  FunctionArgument::List::const_iterator it((yyvsp[(1) - (3)].functionArguments).constBegin());
4671  const FunctionArgument::List::const_iterator end((yyvsp[(1) - (3)].functionArguments).constEnd());
4672 
4673  for(; it != end; ++it)
4674  {
4675  if((*it)->name() == (yyvsp[(3) - (3)].functionArgument)->name())
4676  {
4677  parseInfo->staticContext->error(QtXmlPatterns::tr("An argument with name %1 has already "
4678  "been declared. Every argument name "
4679  "must be unique.")
4680  .arg(formatKeyword(parseInfo->staticContext->namePool(), (yyvsp[(3) - (3)].functionArgument)->name())),
4681  ReportContext::XQST0039, fromYYLTYPE((yyloc), parseInfo));
4682  }
4683  }
4684 
4685  (yyvsp[(1) - (3)].functionArguments).append((yyvsp[(3) - (3)].functionArgument));
4686  (yyval.functionArguments) = (yyvsp[(1) - (3)].functionArguments);
4687  }
4688  break;
4689 
4690  case 85:
4691 /* Line 1269 of yacc.c. */
4692 #line 2236 "querytransformparser.ypp"
4693  {
4694  pushVariable((yyvsp[(2) - (3)].qName), (yyvsp[(3) - (3)].sequenceType), Expression::Ptr(), VariableDeclaration::FunctionArgument, (yyloc), parseInfo);
4695  (yyval.functionArgument) = FunctionArgument::Ptr(new FunctionArgument((yyvsp[(2) - (3)].qName), (yyvsp[(3) - (3)].sequenceType)));
4696  }
4697  break;
4698 
4699  case 86:
4700 /* Line 1269 of yacc.c. */
4701 #line 2242 "querytransformparser.ypp"
4702  {
4703  (yyval.expr).reset();
4704  }
4705  break;
4706 
4707  case 88:
4708 /* Line 1269 of yacc.c. */
4709 #line 2248 "querytransformparser.ypp"
4710  {
4711  (yyval.expr) = (yyvsp[(2) - (3)].expr);
4712  }
4713  break;
4714 
4715  case 91:
4716 /* Line 1269 of yacc.c. */
4717 #line 2264 "querytransformparser.ypp"
4718  {
4719  (yyval.expr) = create(new CombineNodes((yyvsp[(1) - (3)].expr), CombineNodes::Union, (yyvsp[(3) - (3)].expr)), (yyloc), parseInfo);
4720  }
4721  break;
4722 
4723  case 93:
4724 /* Line 1269 of yacc.c. */
4725 #line 2270 "querytransformparser.ypp"
4726  {
4727  /* We write this into a node test. The spec says, 5.5.3 The Meaning of a Pattern:
4728  * "Similarly, / matches a document node, and only a document node,
4729  * because the result of the expression root(.)//(/) returns the root
4730  * node of the tree containing the context node if and only if it is a
4731  * document node." */
4732  (yyval.expr) = create(new AxisStep(QXmlNodeModelIndex::AxisSelf, BuiltinTypes::document), (yyloc), parseInfo);
4733  }
4734  break;
4735 
4736  case 94:
4737 /* Line 1269 of yacc.c. */
4738 #line 2279 "querytransformparser.ypp"
4739  {
4740  /* /axis::node-test
4741  * =>
4742  * axis::node-test[parent::document-node()]
4743  *
4744  * In practice it looks like this. $2 is:
4745  *
4746  * TruthPredicate
4747  * AxisStep self::element(c)
4748  * TruthPredicate
4749  * AxisStep parent::element(b)
4750  * AxisStep parent::element(a)
4751  *
4752  * and we want this:
4753  *
4754  * TruthPredicate
4755  * AxisStep self::element(c)
4756  * TruthPredicate
4757  * AxisStep self::element(b)
4758  * TruthPredicate
4759  * AxisStep parent::element(a)
4760  * AxisStep parent::document()
4761  *
4762  * So we want to rewrite the predicate deepest down into a
4763  * another TruthPredicate containing the AxisStep.
4764  *
4765  * The simplest case where $2 is only an axis step is special. When $2 is:
4766  *
4767  * AxisStep self::element(a)
4768  *
4769  * we want:
4770  *
4771  * TruthPredicate
4772  * AxisStep self::element(a)
4773  * AxisStep parent::document()
4774  */
4775 
4776  /* First, find the target. */
4777  Expression::Ptr target((yyvsp[(2) - (2)].expr));
4778 
4779  while(isPredicate(target->id()))
4780  {
4781  const Expression::Ptr candidate(target->operands().at(1));
4782 
4783  if(isPredicate(candidate->id()))
4784  target = candidate;
4785  else
4786  break; /* target is now the last predicate. */
4787  }
4788 
4789  if(target->is(Expression::IDAxisStep))
4790  {
4791  (yyval.expr) = create(GenericPredicate::create((yyvsp[(2) - (2)].expr), create(new AxisStep(QXmlNodeModelIndex::AxisParent, BuiltinTypes::document), (yyloc), parseInfo),
4792  parseInfo->staticContext, fromYYLTYPE((yylsp[(1) - (2)]), parseInfo)), (yylsp[(1) - (2)]), parseInfo);
4793  }
4794  else
4795  {
4796  const Expression::List targetOperands(target->operands());
4797  Expression::List newOps;
4798  newOps.append(targetOperands.at(0));
4799 
4800  newOps.append(create(GenericPredicate::create(targetOperands.at(1),
4802  parseInfo->staticContext, fromYYLTYPE((yylsp[(1) - (2)]), parseInfo)), (yylsp[(1) - (2)]), parseInfo));
4803 
4804  target->setOperands(newOps);
4805  (yyval.expr) = (yyvsp[(2) - (2)].expr);
4806  }
4807  }
4808  break;
4809 
4810  case 95:
4811 /* Line 1269 of yacc.c. */
4812 #line 2349 "querytransformparser.ypp"
4813  {
4814  /* //axis::node-test
4815  * =>
4816  * axis::node-test[parent::node()]
4817  *
4818  * Spec says: "//para matches any para element that has a parent node."
4819  */
4820  (yyval.expr) = create(GenericPredicate::create((yyvsp[(2) - (2)].expr), create(new AxisStep(QXmlNodeModelIndex::AxisParent, BuiltinTypes::node), (yyloc), parseInfo),
4821  parseInfo->staticContext, fromYYLTYPE((yylsp[(1) - (2)]), parseInfo)), (yylsp[(1) - (2)]), parseInfo);
4822  }
4823  break;
4824 
4825  case 97:
4826 /* Line 1269 of yacc.c. */
4827 #line 2361 "querytransformparser.ypp"
4828  {
4829  createIdPatternPath((yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr), QXmlNodeModelIndex::AxisParent, (yylsp[(2) - (3)]), parseInfo);
4830  }
4831  break;
4832 
4833  case 98:
4834 /* Line 1269 of yacc.c. */
4835 #line 2365 "querytransformparser.ypp"
4836  {
4837  createIdPatternPath((yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr), QXmlNodeModelIndex::AxisAncestor, (yylsp[(2) - (3)]), parseInfo);
4838  }
4839  break;
4840 
4841  case 99:
4842 /* Line 1269 of yacc.c. */
4843 #line 2370 "querytransformparser.ypp"
4844  {
4845  const Expression::List ands((yyvsp[(1) - (1)].expr)->operands());
4846  const FunctionSignature::Ptr signature((yyvsp[(1) - (1)].expr)->as<FunctionCall>()->signature());
4847  const QXmlName name(signature->name());
4850 
4851  if(name == id)
4852  {
4853  const Expression::ID id = ands.first()->id();
4855  {
4856  parseInfo->staticContext->error(QtXmlPatterns::tr("When function %1 is used for matching inside a pattern, "
4857  "the argument must be a variable reference or a string literal.")
4858  .arg(formatFunction(parseInfo->staticContext->namePool(), signature)),
4860  fromYYLTYPE((yyloc), parseInfo));
4861  }
4862  }
4863  else if(name == key)
4864  {
4865  if(ands.first()->id() != Expression::IDStringValue)
4866  {
4867  parseInfo->staticContext->error(QtXmlPatterns::tr("In an XSL-T pattern, the first argument to function %1 "
4868  "must be a string literal, when used for matching.")
4869  .arg(formatFunction(parseInfo->staticContext->namePool(), signature)),
4871  fromYYLTYPE((yyloc), parseInfo));
4872  }
4873 
4874  const Expression::ID id2 = ands.at(1)->id();
4875  if(!isVariableReference(id2) &&
4876  id2 != Expression::IDStringValue &&
4877  id2 != Expression::IDIntegerValue &&
4878  id2 != Expression::IDBooleanValue &&
4879  id2 != Expression::IDFloat)
4880  {
4881  parseInfo->staticContext->error(QtXmlPatterns::tr("In an XSL-T pattern, the first argument to function %1 "
4882  "must be a literal or a variable reference, when used for matching.")
4883  .arg(formatFunction(parseInfo->staticContext->namePool(), signature)),
4885  fromYYLTYPE((yyloc), parseInfo));
4886  }
4887 
4888  if(ands.count() == 3)
4889  {
4890  parseInfo->staticContext->error(QtXmlPatterns::tr("In an XSL-T pattern, function %1 cannot have a third argument.")
4891  .arg(formatFunction(parseInfo->staticContext->namePool(), signature)),
4893  fromYYLTYPE((yyloc), parseInfo));
4894  }
4895 
4896  }
4897  else
4898  {
4899  const FunctionSignature::Hash signs(parseInfo->staticContext->functionSignatures()->functionSignatures());
4900  parseInfo->staticContext->error(QtXmlPatterns::tr("In an XSL-T pattern, only function %1 "
4901  "and %2, not %3, can be used for matching.")
4902  .arg(formatFunction(parseInfo->staticContext->namePool(), signs.value(id)),
4903  formatFunction(parseInfo->staticContext->namePool(), signs.value(key)),
4904  formatFunction(parseInfo->staticContext->namePool(), signature)),
4906  fromYYLTYPE((yyloc), parseInfo));
4907  }
4908 
4909  (yyval.expr) = (yyvsp[(1) - (1)].expr);
4910  }
4911  break;
4912 
4913  case 101:
4914 /* Line 1269 of yacc.c. */
4915 #line 2440 "querytransformparser.ypp"
4916  {
4917  (yyval.expr) = createPatternPath((yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr), QXmlNodeModelIndex::AxisParent, (yylsp[(2) - (3)]), parseInfo);
4918  }
4919  break;
4920 
4921  case 102:
4922 /* Line 1269 of yacc.c. */
4923 #line 2444 "querytransformparser.ypp"
4924  {
4925  (yyval.expr) = createPatternPath((yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr), QXmlNodeModelIndex::AxisAncestor, (yylsp[(2) - (3)]), parseInfo);
4926  }
4927  break;
4928 
4929  case 103:
4930 /* Line 1269 of yacc.c. */
4931 #line 2449 "querytransformparser.ypp"
4932  {
4933  const Expression::Ptr expr(findAxisStep((yyvsp[(1) - (1)].expr)));
4934 
4935  const QXmlNodeModelIndex::Axis axis = expr->as<AxisStep>()->axis();
4936  AxisStep *const axisStep = expr->as<AxisStep>();
4937 
4938  /* Here we constrain the possible axes, and we rewrite the axes as according
4939  * to 5.5.3 The Meaning of a Pattern.
4940  *
4941  * However, we also rewrite axis child and attribute to axis self. The
4942  * reason for this is that if we don't, we will match the children of
4943  * the context node, instead of the context node itself. The formal
4944  * definition of a pattern, root(.)//EE is insensitive to context,
4945  * while the way we implement pattern, "the other way of seeing it",
4946  * e.g from right to left, are very much. */
4947 
4948  if(axisStep->nodeTest() == BuiltinTypes::document
4949  || axis == QXmlNodeModelIndex::AxisChild)
4951  else if(axis == QXmlNodeModelIndex::AxisAttribute)
4952  {
4954  /* Consider that the user write attribute::node(). This is
4955  * semantically equivalent to attribute::attribute(), but since we have changed
4956  * the axis to axis self, we also need to change the node test, such that we
4957  * have self::attribute(). */
4958  if(*axisStep->nodeTest() == *BuiltinTypes::node)
4960  }
4961  else
4962  {
4963  parseInfo->staticContext->error(QtXmlPatterns::tr("In an XSL-T pattern, axis %1 cannot be used, "
4964  "only axis %2 or %3 can.")
4965  .arg(formatKeyword(AxisStep::axisName(axis)),
4969  fromYYLTYPE((yyloc), parseInfo));
4970  }
4971 
4972  (yyval.expr) = (yyvsp[(1) - (1)].expr);
4973  }
4974  break;
4975 
4976  case 105:
4977 /* Line 1269 of yacc.c. */
4978 #line 2494 "querytransformparser.ypp"
4979  {
4980  (yyval.expr) = create(new ExpressionSequence((yyvsp[(1) - (1)].expressionList)), (yyloc), parseInfo);
4981  }
4982  break;
4983 
4984  case 106:
4985 /* Line 1269 of yacc.c. */
4986 #line 2499 "querytransformparser.ypp"
4987  {
4989  l.append((yyvsp[(1) - (3)].expr));
4990  l.append((yyvsp[(3) - (3)].expr));
4991  (yyval.expressionList) = l;
4992  }
4993  break;
4994 
4995  case 107:
4996 /* Line 1269 of yacc.c. */
4997 #line 2506 "querytransformparser.ypp"
4998  {
4999  (yyvsp[(1) - (3)].expressionList).append((yyvsp[(3) - (3)].expr));
5000  (yyval.expressionList) = (yyvsp[(1) - (3)].expressionList);
5001  }
5002  break;
5003 
5004  case 113:
5005 /* Line 1269 of yacc.c. */
5006 #line 2517 "querytransformparser.ypp"
5007  {
5008  (yyval.expr) = createDirAttributeValue((yyvsp[(3) - (4)].expressionList), parseInfo, (yyloc));
5009  }
5010  break;
5011 
5012  case 114:
5013 /* Line 1269 of yacc.c. */
5014 #line 2522 "querytransformparser.ypp"
5015  {
5016  QVector<QXmlName> result;
5018  (yyval.qNameVector) = result;
5019  }
5020  break;
5021 
5022  case 115:
5023 /* Line 1269 of yacc.c. */
5024 #line 2528 "querytransformparser.ypp"
5025  {
5026  (yyval.qNameVector) = (yyvsp[(2) - (2)].qNameVector);
5027  }
5028  break;
5029 
5030  case 116:
5031 /* Line 1269 of yacc.c. */
5032 #line 2533 "querytransformparser.ypp"
5033  {
5035  }
5036  break;
5037 
5038  case 117:
5039 /* Line 1269 of yacc.c. */
5040 #line 2537 "querytransformparser.ypp"
5041  {
5042  (yyval.qName) = (yyvsp[(2) - (2)].qName);
5043  }
5044  break;
5045 
5046  case 118:
5047 /* Line 1269 of yacc.c. */
5048 #line 2542 "querytransformparser.ypp"
5049  {
5050  QVector<QXmlName> result;
5051  result.append((yyvsp[(1) - (1)].qName));
5052  (yyval.qNameVector) = result;
5053  }
5054  break;
5055 
5056  case 119:
5057 /* Line 1269 of yacc.c. */
5058 #line 2548 "querytransformparser.ypp"
5059  {
5060  (yyvsp[(1) - (3)].qNameVector).append((yyvsp[(3) - (3)].qName));
5061  (yyval.qNameVector) = (yyvsp[(1) - (3)].qNameVector);
5062  }
5063  break;
5064 
5065  case 120:
5066 /* Line 1269 of yacc.c. */
5067 #line 2554 "querytransformparser.ypp"
5068  {
5069  (yyval.qName) = (yyvsp[(1) - (1)].qName);
5070  }
5071  break;
5072 
5073  case 121:
5074 /* Line 1269 of yacc.c. */
5075 #line 2558 "querytransformparser.ypp"
5076  {
5077  if((yyvsp[(1) - (1)].sval) == QLatin1String("#current"))
5079  else if((yyvsp[(1) - (1)].sval) == QLatin1String("#default"))
5081  else if((yyvsp[(1) - (1)].sval) == QLatin1String("#all"))
5083  else
5084  {
5085  const ReflectYYLTYPE ryy((yyloc), parseInfo);
5086 
5087  if(!QXmlUtils::isNCName((yyvsp[(1) - (1)].sval)))
5088  {
5089  parseInfo->staticContext->error(QtXmlPatterns::tr("%1 is an invalid template mode name.")
5090  .arg(formatKeyword((yyvsp[(1) - (1)].sval))),
5092  fromYYLTYPE((yyloc), parseInfo));
5093  }
5094 
5095  (yyval.qName) = parseInfo->staticContext->namePool()->allocateQName(StandardNamespaces::empty, (yyvsp[(1) - (1)].sval));
5096  }
5097  }
5098  break;
5099 
5100  case 124:
5101 /* Line 1269 of yacc.c. */
5102 #line 2587 "querytransformparser.ypp"
5103  {
5104  /* We're pushing the range variable here, not the positional. */
5105  (yyval.expr) = pushVariable((yyvsp[(3) - (7)].qName), quantificationType((yyvsp[(4) - (7)].sequenceType)), (yyvsp[(7) - (7)].expr), VariableDeclaration::RangeVariable, (yyloc), parseInfo);
5106  }
5107  break;
5108 
5109  case 125:
5110 /* Line 1269 of yacc.c. */
5111 #line 2591 "querytransformparser.ypp"
5112  {
5113  /* It is ok this appears after PositionalVar, because currentRangeSlot()
5114  * uses a different "channel" than currentPositionSlot(), so they can't trash
5115  * each other. */
5116  (yyval.enums.slot) = parseInfo->staticContext->currentRangeSlot();
5117  }
5118  break;
5119 
5120  case 126:
5121 /* Line 1269 of yacc.c. */
5122 #line 2598 "querytransformparser.ypp"
5123  {
5124  Q_ASSERT((yyvsp[(7) - (10)].expr));
5125  Q_ASSERT((yyvsp[(10) - (10)].expr));
5126 
5127  /* We want the next last pushed variable, since we push the range variable after the
5128  * positional variable. */
5129  if((yyvsp[(5) - (10)].enums.slot) != -1 && parseInfo->variables.at(parseInfo->variables.count() -2)->name == (yyvsp[(3) - (10)].qName))
5130  {
5131  /* Ok, a positional variable is used since its slot is not -1, and its name is equal
5132  * to our range variable. This is an error. */
5133  parseInfo->staticContext->error(QtXmlPatterns::tr("The name of a variable bound in a for-expression must be different "
5134  "from the positional variable. Hence, the two variables named %1 collide.")
5135  .arg(formatKeyword(parseInfo->staticContext->namePool(), (yyvsp[(3) - (10)].qName))),
5137  fromYYLTYPE((yyloc), parseInfo));
5138 
5139  }
5140 
5141  const Expression::Ptr retBody(create(new ForClause((yyvsp[(9) - (10)].enums.slot), (yyvsp[(8) - (10)].expr), (yyvsp[(10) - (10)].expr), (yyvsp[(5) - (10)].enums.slot)), (yyloc), parseInfo));
5142  ReturnOrderBy *const rob = locateReturnClause((yyvsp[(10) - (10)].expr));
5143 
5144  if(rob)
5145  (yyval.expr) = create(new OrderBy(rob->stability(), rob->orderSpecs(), retBody, rob), (yyloc), parseInfo);
5146  else
5147  (yyval.expr) = retBody;
5148 
5149  parseInfo->finalizePushedVariable();
5150 
5151  if((yyvsp[(5) - (10)].enums.slot) != -1) /* We also have a positional variable to remove from the scope. */
5152  parseInfo->finalizePushedVariable();
5153  }
5154  break;
5155 
5156  case 127:
5157 /* Line 1269 of yacc.c. */
5158 #line 2632 "querytransformparser.ypp"
5159  {
5160  pushVariable((yyvsp[(3) - (7)].qName), quantificationType((yyvsp[(4) - (7)].sequenceType)), (yyvsp[(7) - (7)].expr), VariableDeclaration::RangeVariable, (yyloc), parseInfo);
5161  }
5162  break;
5163 
5164  case 128:
5165 /* Line 1269 of yacc.c. */
5166 #line 2635 "querytransformparser.ypp"
5167  {
5168  /* It is ok this appears after PositionalVar, because currentRangeSlot()
5169  * uses a different "channel" than currentPositionSlot(), so they can't trash
5170  * each other. */
5171  (yyval.enums.slot) = parseInfo->staticContext->currentRangeSlot();
5172  }
5173  break;
5174 
5175  case 129:
5176 /* Line 1269 of yacc.c. */
5177 #line 2642 "querytransformparser.ypp"
5178  {
5179  (yyval.expr) = create(new ForClause((yyvsp[(9) - (10)].enums.slot), (yyvsp[(7) - (10)].expr), (yyvsp[(10) - (10)].expr), (yyvsp[(5) - (10)].enums.slot)), (yyloc), parseInfo);
5180 
5181  parseInfo->finalizePushedVariable();
5182 
5183  if((yyvsp[(5) - (10)].enums.slot) != -1) /* We also have a positional variable to remove from the scope. */
5184  parseInfo->finalizePushedVariable();
5185  }
5186  break;
5187 
5188  case 133:
5189 /* Line 1269 of yacc.c. */
5190 #line 2656 "querytransformparser.ypp"
5191  {
5192  (yyval.enums.slot) = -1;
5193  }
5194  break;
5195 
5196  case 134:
5197 /* Line 1269 of yacc.c. */
5198 #line 2661 "querytransformparser.ypp"
5199  {
5201  VariableDeclaration::PositionalVariable, (yyloc), parseInfo);
5202  (yyval.enums.slot) = parseInfo->currentPositionSlot();
5203  }
5204  break;
5205 
5206  case 135:
5207 /* Line 1269 of yacc.c. */
5208 #line 2668 "querytransformparser.ypp"
5209  {
5210  (yyval.expr) = pushVariable((yyvsp[(4) - (7)].qName), quantificationType((yyvsp[(5) - (7)].sequenceType)), (yyvsp[(7) - (7)].expr), VariableDeclaration::ExpressionVariable, (yyloc), parseInfo);
5211  }
5212  break;
5213 
5214  case 136:
5215 /* Line 1269 of yacc.c. */
5216 #line 2672 "querytransformparser.ypp"
5217  {
5218  allowedIn(QXmlQuery::XQuery10, parseInfo, (yyloc), (yyvsp[(2) - (9)].enums.Bool));
5219 
5220  Q_ASSERT(parseInfo->variables.top()->name == (yyvsp[(4) - (9)].qName));
5221  (yyval.expr) = create(new LetClause((yyvsp[(8) - (9)].expr), (yyvsp[(9) - (9)].expr), parseInfo->variables.top()), (yyloc), parseInfo);
5222  parseInfo->finalizePushedVariable();
5223  }
5224  break;
5225 
5226  case 137:
5227 /* Line 1269 of yacc.c. */
5228 #line 2681 "querytransformparser.ypp"
5229  { (yyval.expr) = pushVariable((yyvsp[(3) - (6)].qName), quantificationType((yyvsp[(4) - (6)].sequenceType)), (yyvsp[(6) - (6)].expr), VariableDeclaration::ExpressionVariable, (yyloc), parseInfo);}
5230  break;
5231 
5232  case 138:
5233 /* Line 1269 of yacc.c. */
5234 #line 2683 "querytransformparser.ypp"
5235  {
5236  Q_ASSERT(parseInfo->variables.top()->name == (yyvsp[(3) - (8)].qName));
5237  (yyval.expr) = create(new LetClause((yyvsp[(7) - (8)].expr), (yyvsp[(8) - (8)].expr), parseInfo->variables.top()), (yyloc), parseInfo);
5238  parseInfo->finalizePushedVariable();
5239  }
5240  break;
5241 
5242  case 142:
5243 /* Line 1269 of yacc.c. */
5244 #line 2694 "querytransformparser.ypp"
5245  {
5246  if((yyvsp[(1) - (3)].orderSpecs).isEmpty())
5247  (yyval.expr) = (yyvsp[(3) - (3)].expr);
5248  else
5249  (yyval.expr) = createReturnOrderBy((yyvsp[(1) - (3)].orderSpecs), (yyvsp[(3) - (3)].expr), parseInfo->orderStability.pop(), (yyloc), parseInfo);
5250  }
5251  break;
5252 
5253  case 143:
5254 /* Line 1269 of yacc.c. */
5255 #line 2702 "querytransformparser.ypp"
5256  {
5257  if((yyvsp[(3) - (5)].orderSpecs).isEmpty())
5258  (yyval.expr) = create(new IfThenClause((yyvsp[(2) - (5)].expr), (yyvsp[(5) - (5)].expr), create(new EmptySequence, (yyloc), parseInfo)), (yyloc), parseInfo);
5259  else
5260  (yyval.expr) = create(new IfThenClause((yyvsp[(2) - (5)].expr), createReturnOrderBy((yyvsp[(3) - (5)].orderSpecs), (yyvsp[(5) - (5)].expr), parseInfo->orderStability.pop(), (yyloc), parseInfo),
5261  create(new EmptySequence, (yyloc), parseInfo)),
5262  (yyloc), parseInfo);
5263  }
5264  break;
5265 
5266  case 144:
5267 /* Line 1269 of yacc.c. */
5268 #line 2712 "querytransformparser.ypp"
5269  {
5270  (yyval.orderSpecs) = OrderSpecTransfer::List();
5271  }
5272  break;
5273 
5274  case 146:
5275 /* Line 1269 of yacc.c. */
5276 #line 2718 "querytransformparser.ypp"
5277  {
5278  (yyval.orderSpecs) = (yyvsp[(2) - (2)].orderSpecs);
5279  }
5280  break;
5281 
5282  case 147:
5283 /* Line 1269 of yacc.c. */
5284 #line 2723 "querytransformparser.ypp"
5285  {
5287  list += (yyvsp[(1) - (3)].orderSpecs);
5288  list.append((yyvsp[(3) - (3)].orderSpec));
5289  (yyval.orderSpecs) = list;
5290  }
5291  break;
5292 
5293  case 148:
5294 /* Line 1269 of yacc.c. */
5295 #line 2730 "querytransformparser.ypp"
5296  {
5298  list.append((yyvsp[(1) - (1)].orderSpec));
5299  (yyval.orderSpecs) = list;
5300  }
5301  break;
5302 
5303  case 149:
5304 /* Line 1269 of yacc.c. */
5305 #line 2737 "querytransformparser.ypp"
5306  {
5307  (yyval.orderSpec) = OrderSpecTransfer((yyvsp[(1) - (4)].expr), OrderBy::OrderSpec((yyvsp[(2) - (4)].enums.sortDirection), (yyvsp[(3) - (4)].enums.orderingEmptySequence)));
5308  }
5309  break;
5310 
5311  case 150:
5312 /* Line 1269 of yacc.c. */
5313 #line 2742 "querytransformparser.ypp"
5314  {
5315  /* Where does the specification state the default value is ascending?
5316  *
5317  * It is implicit, in the first enumerated list in 3.8.3 Order By and Return Clauses:
5318  *
5319  * "If T1 and T2 are two tuples in the tuple stream, and V1 and V2 are the first pair
5320  * of values encountered when evaluating their orderspecs from left to right for
5321  * which one value is greater-than the other (as defined above), then:
5322  *
5323  * 1. If V1 is greater-than V2: If the orderspec specifies descending,
5324  * then T1 precedes T2 in the tuple stream; otherwise, T2 precedes T1 in the tuple stream.
5325  * 2. If V2 is greater-than V1: If the orderspec specifies descending,
5326  * then T2 precedes T1 in the tuple stream; otherwise, T1 precedes T2 in the tuple stream."
5327  *
5328  * which means that if you don't specify anything, or you
5329  * specify ascending, you get the same result.
5330  */
5331  (yyval.enums.sortDirection) = OrderBy::OrderSpec::Ascending;
5332  }
5333  break;
5334 
5335  case 151:
5336 /* Line 1269 of yacc.c. */
5337 #line 2763 "querytransformparser.ypp"
5338  {
5339  (yyval.enums.sortDirection) = OrderBy::OrderSpec::Ascending;
5340  }
5341  break;
5342 
5343  case 152:
5344 /* Line 1269 of yacc.c. */
5345 #line 2768 "querytransformparser.ypp"
5346  {
5347  (yyval.enums.sortDirection) = OrderBy::OrderSpec::Descending;
5348  }
5349  break;
5350 
5351  case 153:
5352 /* Line 1269 of yacc.c. */
5353 #line 2773 "querytransformparser.ypp"
5354  {
5355  (yyval.enums.orderingEmptySequence) = parseInfo->staticContext->orderingEmptySequence();
5356  }
5357  break;
5358 
5359  case 156:
5360 /* Line 1269 of yacc.c. */
5361 #line 2780 "querytransformparser.ypp"
5362  {
5363  if(parseInfo->isXSLT())
5364  resolveAndCheckCollation<ReportContext::XTDE1035>((yyvsp[(2) - (2)].sval), parseInfo, (yyloc));
5365  else
5366  resolveAndCheckCollation<ReportContext::XQST0076>((yyvsp[(2) - (2)].sval), parseInfo, (yyloc));
5367  }
5368  break;
5369 
5370  case 157:
5371 /* Line 1269 of yacc.c. */
5372 #line 2787 "querytransformparser.ypp"
5373  {
5374  /* We do nothing. We don't use collations, and we have this non-terminal
5375  * in order to accept expressions. */
5376  }
5377  break;
5378 
5379  case 158:
5380 /* Line 1269 of yacc.c. */
5381 #line 2793 "querytransformparser.ypp"
5382  {
5383  parseInfo->orderStability.push(OrderBy::StableOrder);
5384  }
5385  break;
5386 
5387  case 159:
5388 /* Line 1269 of yacc.c. */
5389 #line 2797 "querytransformparser.ypp"
5390  {
5391  parseInfo->orderStability.push(OrderBy::UnstableOrder);
5392  }
5393  break;
5394 
5395  case 162:
5396 /* Line 1269 of yacc.c. */
5397 #line 2805 "querytransformparser.ypp"
5398  {
5399  pushVariable((yyvsp[(3) - (6)].qName), quantificationType((yyvsp[(4) - (6)].sequenceType)), (yyvsp[(6) - (6)].expr),
5400  VariableDeclaration::RangeVariable, (yyloc), parseInfo);
5401  }
5402  break;
5403 
5404  case 163:
5405 /* Line 1269 of yacc.c. */
5406 #line 2809 "querytransformparser.ypp"
5407  {(yyval.enums.slot) = parseInfo->staticContext->currentRangeSlot();}
5408  break;
5409 
5410  case 164:
5411 /* Line 1269 of yacc.c. */
5412 #line 2811 "querytransformparser.ypp"
5413  {
5414  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
5415  (yyval.expr) = create(new QuantifiedExpression((yyvsp[(8) - (9)].enums.slot),
5416  QuantifiedExpression::Some, (yyvsp[(6) - (9)].expr), (yyvsp[(9) - (9)].expr)), (yyloc), parseInfo);
5417  parseInfo->finalizePushedVariable();
5418  }
5419  break;
5420 
5421  case 165:
5422 /* Line 1269 of yacc.c. */
5423 #line 2819 "querytransformparser.ypp"
5424  {
5425  (yyval.expr) = pushVariable((yyvsp[(3) - (6)].qName), quantificationType((yyvsp[(4) - (6)].sequenceType)), (yyvsp[(6) - (6)].expr),
5426  VariableDeclaration::RangeVariable, (yyloc), parseInfo);
5427  }
5428  break;
5429 
5430  case 166:
5431 /* Line 1269 of yacc.c. */
5432 #line 2823 "querytransformparser.ypp"
5433  {(yyval.enums.slot) = parseInfo->staticContext->currentRangeSlot();}
5434  break;
5435 
5436  case 167:
5437 /* Line 1269 of yacc.c. */
5438 #line 2825 "querytransformparser.ypp"
5439  {
5440  (yyval.expr) = create(new QuantifiedExpression((yyvsp[(8) - (9)].enums.slot),
5441  QuantifiedExpression::Some, (yyvsp[(7) - (9)].expr), (yyvsp[(9) - (9)].expr)), (yyloc), parseInfo);
5442  parseInfo->finalizePushedVariable();
5443  }
5444  break;
5445 
5446  case 169:
5447 /* Line 1269 of yacc.c. */
5448 #line 2834 "querytransformparser.ypp"
5449  {
5450  pushVariable((yyvsp[(3) - (6)].qName), quantificationType((yyvsp[(4) - (6)].sequenceType)), (yyvsp[(6) - (6)].expr),
5451  VariableDeclaration::RangeVariable, (yyloc), parseInfo);
5452  }
5453  break;
5454 
5455  case 170:
5456 /* Line 1269 of yacc.c. */
5457 #line 2838 "querytransformparser.ypp"
5458  {(yyval.enums.slot) = parseInfo->staticContext->currentRangeSlot();}
5459  break;
5460 
5461  case 171:
5462 /* Line 1269 of yacc.c. */
5463 #line 2840 "querytransformparser.ypp"
5464  {
5465  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
5466  (yyval.expr) = create(new QuantifiedExpression((yyvsp[(8) - (9)].enums.slot),
5467  QuantifiedExpression::Every, (yyvsp[(6) - (9)].expr), (yyvsp[(9) - (9)].expr)), (yyloc), parseInfo);
5468  parseInfo->finalizePushedVariable();
5469  }
5470  break;
5471 
5472  case 172:
5473 /* Line 1269 of yacc.c. */
5474 #line 2848 "querytransformparser.ypp"
5475  {
5476  (yyval.expr) = pushVariable((yyvsp[(3) - (6)].qName), quantificationType((yyvsp[(4) - (6)].sequenceType)), (yyvsp[(6) - (6)].expr),
5477  VariableDeclaration::RangeVariable, (yyloc), parseInfo);
5478  }
5479  break;
5480 
5481  case 173:
5482 /* Line 1269 of yacc.c. */
5483 #line 2852 "querytransformparser.ypp"
5484  {(yyval.enums.slot) = parseInfo->staticContext->currentRangeSlot();}
5485  break;
5486 
5487  case 174:
5488 /* Line 1269 of yacc.c. */
5489 #line 2854 "querytransformparser.ypp"
5490  {
5491  (yyval.expr) = create(new QuantifiedExpression((yyvsp[(8) - (9)].enums.slot),
5492  QuantifiedExpression::Every, (yyvsp[(7) - (9)].expr), (yyvsp[(9) - (9)].expr)), (yyloc), parseInfo);
5493  parseInfo->finalizePushedVariable();
5494  }
5495  break;
5496 
5497  case 176:
5498 /* Line 1269 of yacc.c. */
5499 #line 2863 "querytransformparser.ypp"
5500  {
5501  (yyval.expr) = (yyvsp[(2) - (2)].expr);
5502  }
5503  break;
5504 
5505  case 177:
5506 /* Line 1269 of yacc.c. */
5507 #line 2890 "querytransformparser.ypp"
5508  {
5509  parseInfo->typeswitchSource.push((yyvsp[(3) - (4)].expr));
5510  }
5511  break;
5512 
5513  case 178:
5514 /* Line 1269 of yacc.c. */
5515 #line 2894 "querytransformparser.ypp"
5516  {
5517  allowedIn(QXmlQuery::XQuery10, parseInfo, (yyloc));
5518  parseInfo->typeswitchSource.pop();
5519  (yyval.expr) = (yyvsp[(6) - (6)].expr);
5520  }
5521  break;
5522 
5523  case 179:
5524 /* Line 1269 of yacc.c. */
5525 #line 2901 "querytransformparser.ypp"
5526  {
5527  if(!(yyvsp[(2) - (3)].qName).isNull())
5528  {
5529  pushVariable((yyvsp[(2) - (3)].qName), (yyvsp[(3) - (3)].sequenceType), parseInfo->typeswitchSource.top(),
5530  VariableDeclaration::ExpressionVariable, (yyloc), parseInfo, false);
5531  }
5532  }
5533  break;
5534 
5535  case 180:
5536 /* Line 1269 of yacc.c. */
5537 #line 2909 "querytransformparser.ypp"
5538  {
5539  /* The variable shouldn't be in-scope for other case branches. */
5540  if(!(yyvsp[(2) - (6)].qName).isNull())
5541  parseInfo->finalizePushedVariable();
5542  }
5543  break;
5544 
5545  case 181:
5546 /* Line 1269 of yacc.c. */
5547 #line 2915 "querytransformparser.ypp"
5548  {
5549  const Expression::Ptr instanceOf(create(new InstanceOf(parseInfo->typeswitchSource.top(), (yyvsp[(3) - (8)].sequenceType)), (yyloc), parseInfo));
5550  (yyval.expr) = create(new IfThenClause(instanceOf, (yyvsp[(6) - (8)].expr), (yyvsp[(8) - (8)].expr)), (yyloc), parseInfo);
5551  }
5552  break;
5553 
5554  case 184:
5555 /* Line 1269 of yacc.c. */
5556 #line 2924 "querytransformparser.ypp"
5557  {
5558  (yyval.qName) = QXmlName();
5559  }
5560  break;
5561 
5562  case 185:
5563 /* Line 1269 of yacc.c. */
5564 #line 2929 "querytransformparser.ypp"
5565  {
5566  (yyval.qName) = (yyvsp[(2) - (3)].qName);
5567  }
5568  break;
5569 
5570  case 186:
5571 /* Line 1269 of yacc.c. */
5572 #line 2934 "querytransformparser.ypp"
5573  {
5574  (yyval.expr) = (yyvsp[(3) - (3)].expr);
5575  }
5576  break;
5577 
5578  case 187:
5579 /* Line 1269 of yacc.c. */
5580 #line 2938 "querytransformparser.ypp"
5581  {
5582  if(!(yyvsp[(3) - (3)].qName).isNull())
5583  {
5584  pushVariable((yyvsp[(3) - (3)].qName), parseInfo->typeswitchSource.top()->staticType(),
5585  parseInfo->typeswitchSource.top(),
5586  VariableDeclaration::ExpressionVariable, (yyloc), parseInfo, false);
5587  }
5588  }
5589  break;
5590 
5591  case 188:
5592 /* Line 1269 of yacc.c. */
5593 #line 2947 "querytransformparser.ypp"
5594  {
5595  if(!(yyvsp[(3) - (6)].qName).isNull())
5596  parseInfo->finalizePushedVariable();
5597  (yyval.expr) = (yyvsp[(6) - (6)].expr);
5598  }
5599  break;
5600 
5601  case 189:
5602 /* Line 1269 of yacc.c. */
5603 #line 2954 "querytransformparser.ypp"
5604  {
5605  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
5606  (yyval.expr) = create(new IfThenClause((yyvsp[(3) - (8)].expr), (yyvsp[(6) - (8)].expr), (yyvsp[(8) - (8)].expr)), (yyloc), parseInfo);
5607  }
5608  break;
5609 
5610  case 191:
5611 /* Line 1269 of yacc.c. */
5612 #line 2961 "querytransformparser.ypp"
5613  {
5614  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
5615  (yyval.expr) = create(new OrExpression((yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)), (yyloc), parseInfo);
5616  }
5617  break;
5618 
5619  case 193:
5620 /* Line 1269 of yacc.c. */
5621 #line 2968 "querytransformparser.ypp"
5622  {
5623  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
5624  (yyval.expr) = create(new AndExpression((yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)), (yyloc), parseInfo);
5625  }
5626  break;
5627 
5628  case 199:
5629 /* Line 1269 of yacc.c. */
5630 #line 2980 "querytransformparser.ypp"
5631  {
5632  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
5633  (yyval.expr) = create(new RangeExpression((yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)), (yyloc), parseInfo);
5634  }
5635  break;
5636 
5637  case 201:
5638 /* Line 1269 of yacc.c. */
5639 #line 2987 "querytransformparser.ypp"
5640  {
5641  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
5642  (yyval.expr) = create(new ArithmeticExpression((yyvsp[(1) - (3)].expr), (yyvsp[(2) - (3)].enums.mathOperator), (yyvsp[(3) - (3)].expr)), (yyloc), parseInfo);
5643  }
5644  break;
5645 
5646  case 202:
5647 /* Line 1269 of yacc.c. */
5648 #line 2992 "querytransformparser.ypp"
5649  {(yyval.enums.mathOperator) = AtomicMathematician::Add;}
5650  break;
5651 
5652  case 203:
5653 /* Line 1269 of yacc.c. */
5654 #line 2993 "querytransformparser.ypp"
5655  {(yyval.enums.mathOperator) = AtomicMathematician::Substract;}
5656  break;
5657 
5658  case 205:
5659 /* Line 1269 of yacc.c. */
5660 #line 2997 "querytransformparser.ypp"
5661  {
5662  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
5663  (yyval.expr) = create(new ArithmeticExpression((yyvsp[(1) - (3)].expr), (yyvsp[(2) - (3)].enums.mathOperator), (yyvsp[(3) - (3)].expr)), (yyloc), parseInfo);
5664  }
5665  break;
5666 
5667  case 206:
5668 /* Line 1269 of yacc.c. */
5669 #line 3002 "querytransformparser.ypp"
5670  {(yyval.enums.mathOperator) = AtomicMathematician::Multiply;}
5671  break;
5672 
5673  case 207:
5674 /* Line 1269 of yacc.c. */
5675 #line 3003 "querytransformparser.ypp"
5676  {(yyval.enums.mathOperator) = AtomicMathematician::Div;}
5677  break;
5678 
5679  case 208:
5680 /* Line 1269 of yacc.c. */
5681 #line 3004 "querytransformparser.ypp"
5682  {(yyval.enums.mathOperator) = AtomicMathematician::IDiv;}
5683  break;
5684 
5685  case 209:
5686 /* Line 1269 of yacc.c. */
5687 #line 3005 "querytransformparser.ypp"
5688  {(yyval.enums.mathOperator) = AtomicMathematician::Mod;}
5689  break;
5690 
5691  case 211:
5692 /* Line 1269 of yacc.c. */
5693 #line 3009 "querytransformparser.ypp"
5694  {
5695  allowedIn(QueryLanguages(QXmlQuery::XQuery10
5699  parseInfo, (yyloc));
5700  (yyval.expr) = create(new CombineNodes((yyvsp[(1) - (3)].expr), CombineNodes::Union, (yyvsp[(3) - (3)].expr)), (yyloc), parseInfo);
5701  }
5702  break;
5703 
5704  case 213:
5705 /* Line 1269 of yacc.c. */
5706 #line 3020 "querytransformparser.ypp"
5707  {
5708  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
5709  (yyval.expr) = create(new CombineNodes((yyvsp[(1) - (3)].expr), (yyvsp[(2) - (3)].enums.combinedNodeOp), (yyvsp[(3) - (3)].expr)), (yyloc), parseInfo);
5710  }
5711  break;
5712 
5713  case 216:
5714 /* Line 1269 of yacc.c. */
5715 #line 3029 "querytransformparser.ypp"
5716  {
5717  (yyval.enums.combinedNodeOp) = CombineNodes::Intersect;
5718  }
5719  break;
5720 
5721  case 217:
5722 /* Line 1269 of yacc.c. */
5723 #line 3033 "querytransformparser.ypp"
5724  {
5725  (yyval.enums.combinedNodeOp) = CombineNodes::Except;
5726  }
5727  break;
5728 
5729  case 219:
5730 /* Line 1269 of yacc.c. */
5731 #line 3039 "querytransformparser.ypp"
5732  {
5733  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
5734  (yyval.expr) = create(new InstanceOf((yyvsp[(1) - (4)].expr),
5735  SequenceType::Ptr((yyvsp[(4) - (4)].sequenceType))), (yyloc), parseInfo);
5736  }
5737  break;
5738 
5739  case 221:
5740 /* Line 1269 of yacc.c. */
5741 #line 3047 "querytransformparser.ypp"
5742  {
5743  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
5744  (yyval.expr) = create(new TreatAs((yyvsp[(1) - (4)].expr), (yyvsp[(4) - (4)].sequenceType)), (yyloc), parseInfo);
5745  }
5746  break;
5747 
5748  case 223:
5749 /* Line 1269 of yacc.c. */
5750 #line 3054 "querytransformparser.ypp"
5751  {
5752  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
5753  (yyval.expr) = create(new CastableAs((yyvsp[(1) - (4)].expr), (yyvsp[(4) - (4)].sequenceType)), (yyloc), parseInfo);
5754  }
5755  break;
5756 
5757  case 225:
5758 /* Line 1269 of yacc.c. */
5759 #line 3061 "querytransformparser.ypp"
5760  {
5761  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
5762  (yyval.expr) = create(new CastAs((yyvsp[(1) - (4)].expr), (yyvsp[(4) - (4)].sequenceType)), (yyloc), parseInfo);
5763  }
5764  break;
5765 
5766  case 227:
5767 /* Line 1269 of yacc.c. */
5768 #line 3068 "querytransformparser.ypp"
5769  {
5770  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
5771  (yyval.expr) = create(new UnaryExpression((yyvsp[(1) - (2)].enums.mathOperator), (yyvsp[(2) - (2)].expr), parseInfo->staticContext), (yyloc), parseInfo);
5772  }
5773  break;
5774 
5775  case 228:
5776 /* Line 1269 of yacc.c. */
5777 #line 3074 "querytransformparser.ypp"
5778  {
5779  (yyval.enums.mathOperator) = AtomicMathematician::Add;
5780  }
5781  break;
5782 
5783  case 229:
5784 /* Line 1269 of yacc.c. */
5785 #line 3078 "querytransformparser.ypp"
5786  {
5787  (yyval.enums.mathOperator) = AtomicMathematician::Substract;
5788  }
5789  break;
5790 
5791  case 233:
5792 /* Line 1269 of yacc.c. */
5793 #line 3087 "querytransformparser.ypp"
5794  {
5795  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
5796  (yyval.expr) = create(new GeneralComparison((yyvsp[(1) - (3)].expr), (yyvsp[(2) - (3)].enums.valueOperator), (yyvsp[(3) - (3)].expr), parseInfo->isBackwardsCompat.top()), (yyloc), parseInfo);
5797  }
5798  break;
5799 
5800  case 234:
5801 /* Line 1269 of yacc.c. */
5802 #line 3092 "querytransformparser.ypp"
5803  {(yyval.enums.valueOperator) = AtomicComparator::OperatorEqual;}
5804  break;
5805 
5806  case 235:
5807 /* Line 1269 of yacc.c. */
5808 #line 3093 "querytransformparser.ypp"
5809  {(yyval.enums.valueOperator) = AtomicComparator::OperatorNotEqual;}
5810  break;
5811 
5812  case 236:
5813 /* Line 1269 of yacc.c. */
5814 #line 3094 "querytransformparser.ypp"
5815  {(yyval.enums.valueOperator) = AtomicComparator::OperatorGreaterOrEqual;}
5816  break;
5817 
5818  case 237:
5819 /* Line 1269 of yacc.c. */
5820 #line 3095 "querytransformparser.ypp"
5821  {(yyval.enums.valueOperator) = AtomicComparator::OperatorGreaterThan;}
5822  break;
5823 
5824  case 238:
5825 /* Line 1269 of yacc.c. */
5826 #line 3096 "querytransformparser.ypp"
5827  {(yyval.enums.valueOperator) = AtomicComparator::OperatorLessOrEqual;}
5828  break;
5829 
5830  case 239:
5831 /* Line 1269 of yacc.c. */
5832 #line 3097 "querytransformparser.ypp"
5833  {(yyval.enums.valueOperator) = AtomicComparator::OperatorLessThan;}
5834  break;
5835 
5836  case 240:
5837 /* Line 1269 of yacc.c. */
5838 #line 3100 "querytransformparser.ypp"
5839  {
5840  (yyval.expr) = create(new ValueComparison((yyvsp[(1) - (3)].expr), (yyvsp[(2) - (3)].enums.valueOperator), (yyvsp[(3) - (3)].expr)), (yyloc), parseInfo);
5841  }
5842  break;
5843 
5844  case 241:
5845 /* Line 1269 of yacc.c. */
5846 #line 3104 "querytransformparser.ypp"
5847  {(yyval.enums.valueOperator) = AtomicComparator::OperatorEqual;}
5848  break;
5849 
5850  case 242:
5851 /* Line 1269 of yacc.c. */
5852 #line 3105 "querytransformparser.ypp"
5853  {(yyval.enums.valueOperator) = AtomicComparator::OperatorNotEqual;}
5854  break;
5855 
5856  case 243:
5857 /* Line 1269 of yacc.c. */
5858 #line 3106 "querytransformparser.ypp"
5859  {(yyval.enums.valueOperator) = AtomicComparator::OperatorGreaterOrEqual;}
5860  break;
5861 
5862  case 244:
5863 /* Line 1269 of yacc.c. */
5864 #line 3107 "querytransformparser.ypp"
5865  {(yyval.enums.valueOperator) = AtomicComparator::OperatorGreaterThan;}
5866  break;
5867 
5868  case 245:
5869 /* Line 1269 of yacc.c. */
5870 #line 3108 "querytransformparser.ypp"
5871  {(yyval.enums.valueOperator) = AtomicComparator::OperatorLessOrEqual;}
5872  break;
5873 
5874  case 246:
5875 /* Line 1269 of yacc.c. */
5876 #line 3109 "querytransformparser.ypp"
5877  {(yyval.enums.valueOperator) = AtomicComparator::OperatorLessThan;}
5878  break;
5879 
5880  case 247:
5881 /* Line 1269 of yacc.c. */
5882 #line 3112 "querytransformparser.ypp"
5883  {
5884  (yyval.expr) = create(new NodeComparison((yyvsp[(1) - (3)].expr), (yyvsp[(2) - (3)].enums.nodeOperator), (yyvsp[(3) - (3)].expr)), (yyloc), parseInfo);
5885  }
5886  break;
5887 
5888  case 248:
5889 /* Line 1269 of yacc.c. */
5890 #line 3116 "querytransformparser.ypp"
5891  {(yyval.enums.nodeOperator) = QXmlNodeModelIndex::Is;}
5892  break;
5893 
5894  case 249:
5895 /* Line 1269 of yacc.c. */
5896 #line 3117 "querytransformparser.ypp"
5897  {(yyval.enums.nodeOperator) = QXmlNodeModelIndex::Precedes;}
5898  break;
5899 
5900  case 250:
5901 /* Line 1269 of yacc.c. */
5902 #line 3118 "querytransformparser.ypp"
5903  {(yyval.enums.nodeOperator) = QXmlNodeModelIndex::Follows;}
5904  break;
5905 
5906  case 251:
5907 /* Line 1269 of yacc.c. */
5908 #line 3121 "querytransformparser.ypp"
5909  {
5910  allowedIn(QXmlQuery::XQuery10, parseInfo, (yyloc));
5911  parseInfo->staticContext->error(QtXmlPatterns::tr("The Schema Validation Feature is not supported. "
5912  "Hence, %1-expressions may not be used.")
5913  .arg(formatKeyword("validate")),
5914  ReportContext::XQST0075, fromYYLTYPE((yyloc), parseInfo));
5915  /*
5916  $$ = Validate::create($2, $1, parseInfo->staticContext);
5917  */
5918  }
5919  break;
5920 
5921  case 252:
5922 /* Line 1269 of yacc.c. */
5923 #line 3134 "querytransformparser.ypp"
5924  {(yyval.enums.validationMode) = Validate::Strict;}
5925  break;
5926 
5927  case 253:
5928 /* Line 1269 of yacc.c. */
5929 #line 3135 "querytransformparser.ypp"
5930  {(yyval.enums.validationMode) = Validate::Strict;}
5931  break;
5932 
5933  case 254:
5934 /* Line 1269 of yacc.c. */
5935 #line 3136 "querytransformparser.ypp"
5936  {(yyval.enums.validationMode) = Validate::Lax;}
5937  break;
5938 
5939  case 255:
5940 /* Line 1269 of yacc.c. */
5941 #line 3139 "querytransformparser.ypp"
5942  {
5943  allowedIn(QXmlQuery::XQuery10, parseInfo, (yyloc));
5944  /* We don't support any pragmas, so we only do the
5945  * necessary validation and use the fallback expression. */
5946 
5947  if((yyvsp[(2) - (2)].expr))
5948  (yyval.expr) = (yyvsp[(2) - (2)].expr);
5949  else
5950  {
5951  parseInfo->staticContext->error(QtXmlPatterns::tr("None of the pragma expressions are supported. "
5952  "Therefore, a fallback expression "
5953  "must be present"),
5954  ReportContext::XQST0079, fromYYLTYPE((yyloc), parseInfo));
5955  }
5956  }
5957  break;
5958 
5959  case 256:
5960 /* Line 1269 of yacc.c. */
5961 #line 3156 "querytransformparser.ypp"
5962  {
5963  (yyval.expr).reset();
5964  }
5965  break;
5966 
5967  case 257:
5968 /* Line 1269 of yacc.c. */
5969 #line 3160 "querytransformparser.ypp"
5970  {
5971  (yyval.expr) = (yyvsp[(2) - (3)].expr);
5972  }
5973  break;
5974 
5975  case 260:
5976 /* Line 1269 of yacc.c. */
5977 #line 3168 "querytransformparser.ypp"
5978  {
5979  allowedIn(QXmlQuery::XQuery10, parseInfo, (yyloc));
5980  }
5981  break;
5982 
5983  case 263:
5984 /* Line 1269 of yacc.c. */
5985 #line 3176 "querytransformparser.ypp"
5986  {
5987  /* This is "/step". That is, fn:root(self::node()) treat as document-node()/RelativePathExpr. */
5988  (yyval.expr) = create(new Path(createRootExpression(parseInfo, (yyloc)), (yyvsp[(2) - (2)].expr)), (yyloc), parseInfo);
5989  }
5990  break;
5991 
5992  case 264:
5993 /* Line 1269 of yacc.c. */
5994 #line 3182 "querytransformparser.ypp"
5995  {
5996  (yyval.expr) = createSlashSlashPath(createRootExpression(parseInfo, (yyloc)), (yyvsp[(2) - (2)].expr), (yyloc), parseInfo);
5997  }
5998  break;
5999 
6000  case 265:
6001 /* Line 1269 of yacc.c. */
6002 #line 3186 "querytransformparser.ypp"
6003  {
6004  /* This is "/". That is, fn:root(self::node()) treat as document-node(). */
6005  (yyval.expr) = createRootExpression(parseInfo, (yyloc));
6006  }
6007  break;
6008 
6009  case 268:
6010 /* Line 1269 of yacc.c. */
6011 #line 3196 "querytransformparser.ypp"
6012  {
6013  (yyval.expr) = create(new Path((yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr), (yyvsp[(2) - (3)].enums.pathKind)), (yyloc), parseInfo);
6014  }
6015  break;
6016 
6017  case 269:
6018 /* Line 1269 of yacc.c. */
6019 #line 3200 "querytransformparser.ypp"
6020  {
6021  const Expression::Ptr orderBy(createReturnOrderBy((yyvsp[(4) - (7)].orderSpecs), (yyvsp[(6) - (7)].expr), parseInfo->orderStability.pop(), (yyloc), parseInfo));
6022 
6023  ReturnOrderBy *const rob = orderBy->as<ReturnOrderBy>();
6024  const Expression::Ptr path(create(new Path((yyvsp[(1) - (7)].expr), orderBy, (yyvsp[(2) - (7)].enums.pathKind)), (yyloc), parseInfo));
6025 
6026  (yyval.expr) = create(new OrderBy(rob->stability(), rob->orderSpecs(), path, rob), (yyloc), parseInfo);
6027  }
6028  break;
6029 
6030  case 270:
6031 /* Line 1269 of yacc.c. */
6032 #line 3209 "querytransformparser.ypp"
6033  {
6034  (yyval.expr) = createSlashSlashPath((yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr), (yyloc), parseInfo);
6035  }
6036  break;
6037 
6038  case 271:
6039 /* Line 1269 of yacc.c. */
6040 #line 3214 "querytransformparser.ypp"
6041  {
6042  (yyval.expr) = NodeSortExpression::wrapAround((yyvsp[(1) - (1)].expr), parseInfo->staticContext);
6043  }
6044  break;
6045 
6046  case 273:
6047 /* Line 1269 of yacc.c. */
6048 #line 3219 "querytransformparser.ypp"
6049  {
6050  (yyval.expr) = create(new CurrentItemStore((yyvsp[(2) - (2)].expr)), (yyloc), parseInfo);
6051  }
6052  break;
6053 
6054  case 274:
6055 /* Line 1269 of yacc.c. */
6056 #line 3223 "querytransformparser.ypp"
6057  {
6058  const xsDouble version = (yyvsp[(1) - (1)].sval).toDouble();
6059 
6060  parseInfo->isBackwardsCompat.push(version != 2);
6061 
6062  (yyval.enums.Double) = version;
6063  }
6064  break;
6065 
6066  case 275:
6067 /* Line 1269 of yacc.c. */
6068 #line 3231 "querytransformparser.ypp"
6069  {
6070  if((yyvsp[(2) - (3)].enums.Double) < 2)
6071  (yyval.expr) = createCompatStore((yyvsp[(3) - (3)].expr), (yyloc), parseInfo);
6072  else
6073  (yyval.expr) = (yyvsp[(3) - (3)].expr);
6074  }
6075  break;
6076 
6077  case 276:
6078 /* Line 1269 of yacc.c. */
6079 #line 3238 "querytransformparser.ypp"
6080  {
6081  allowedIn(QXmlQuery::XSLT20, parseInfo, (yyloc));
6082  Q_ASSERT(!(yyvsp[(2) - (5)].sval).isEmpty());
6083  (yyval.expr) = create(new StaticBaseURIStore((yyvsp[(2) - (5)].sval), (yyvsp[(4) - (5)].expr)), (yyloc), parseInfo);
6084 }
6085  break;
6086 
6087  case 277:
6088 /* Line 1269 of yacc.c. */
6089 #line 3245 "querytransformparser.ypp"
6090  {
6091  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XSLT20), parseInfo, (yyloc));
6092  parseInfo->resolvers.push(parseInfo->staticContext->namespaceBindings());
6093  const NamespaceResolver::Ptr resolver(new DelegatingNamespaceResolver(parseInfo->staticContext->namespaceBindings()));
6094  resolver->addBinding(QXmlName(parseInfo->staticContext->namePool()->allocateNamespace((yyvsp[(5) - (6)].sval)),
6096  parseInfo->staticContext->namePool()->allocatePrefix((yyvsp[(3) - (6)].sval))));
6097  parseInfo->staticContext->setNamespaceBindings(resolver);
6098  }
6099  break;
6100 
6101  case 278:
6102 /* Line 1269 of yacc.c. */
6103 #line 3256 "querytransformparser.ypp"
6104  {
6105  parseInfo->staticContext->setNamespaceBindings(parseInfo->resolvers.pop());
6106  (yyval.expr) = (yyvsp[(8) - (9)].expr);
6107  }
6108  break;
6109 
6110  case 279:
6111 /* Line 1269 of yacc.c. */
6112 #line 3261 "querytransformparser.ypp"
6113  {
6114  (yyval.expr) = create(new CallTemplate((yyvsp[(2) - (5)].qName), parseInfo->templateWithParams), (yyloc), parseInfo);
6115  parseInfo->templateWithParametersHandled();
6116  parseInfo->templateCalls.append((yyval.expr));
6117  }
6118  break;
6119 
6120  case 280:
6121 /* Line 1269 of yacc.c. */
6122 #line 3268 "querytransformparser.ypp"
6123  {
6124  parseInfo->startParsingWithParam();
6125  }
6126  break;
6127 
6128  case 281:
6129 /* Line 1269 of yacc.c. */
6130 #line 3272 "querytransformparser.ypp"
6131  {
6132  parseInfo->endParsingWithParam();
6133  }
6134  break;
6135 
6136  case 282:
6137 /* Line 1269 of yacc.c. */
6138 #line 3277 "querytransformparser.ypp"
6139  {
6140  }
6141  break;
6142 
6143  case 283:
6144 /* Line 1269 of yacc.c. */
6145 #line 3280 "querytransformparser.ypp"
6146  {
6147  }
6148  break;
6149 
6150  case 284:
6151 /* Line 1269 of yacc.c. */
6152 #line 3283 "querytransformparser.ypp"
6153  {
6154  }
6155  break;
6156 
6157  case 285:
6158 /* Line 1269 of yacc.c. */
6159 #line 3287 "querytransformparser.ypp"
6160  {
6161  }
6162  break;
6163 
6164  case 286:
6165 /* Line 1269 of yacc.c. */
6166 #line 3290 "querytransformparser.ypp"
6167  {
6168  }
6169  break;
6170 
6171  case 287:
6172 /* Line 1269 of yacc.c. */
6173 #line 3294 "querytransformparser.ypp"
6174  {
6175  /* Note, this grammar rule is invoked for @c xsl:param @em and @c
6176  * xsl:with-param. */
6177  const bool isParsingWithParam = parseInfo->isParsingWithParam();
6178 
6195 
6196  if(!(yyvsp[(4) - (5)].sequenceType)->is(CommonSequenceTypes::ZeroOrMoreItems))
6197  type = (yyvsp[(4) - (5)].sequenceType);
6198 
6199  Expression::Ptr expr;
6200 
6201  /* The default value is an empty sequence. */
6202  if(!(yyvsp[(5) - (5)].expr) && ((type && (yyvsp[(4) - (5)].sequenceType)->cardinality().allowsEmpty())
6203  || isParsingWithParam))
6204  expr = create(new EmptySequence, (yyloc), parseInfo);
6205  else
6206  expr = (yyvsp[(5) - (5)].expr);
6207 
6208  /* We ensure we have some type, so CallTemplate, Template and friends
6209  * are happy. */
6210  if(!isParsingWithParam && !type)
6212 
6213  if((yyvsp[(1) - (5)].enums.Bool))
6214  /* TODO, handle tunnel parameters. */;
6215  else
6216  {
6217  if((!isParsingWithParam && VariableDeclaration::contains(parseInfo->templateParameters, (yyvsp[(3) - (5)].qName))) ||
6218  (isParsingWithParam && parseInfo->templateWithParams.contains((yyvsp[(3) - (5)].qName))))
6219  {
6220  parseInfo->staticContext->error(QtXmlPatterns::tr("Each name of a template parameter must be unique; %1 is duplicated.")
6221  .arg(formatKeyword(parseInfo->staticContext->namePool(), (yyvsp[(3) - (5)].qName))),
6222  isParsingWithParam ? ReportContext::XTSE0670 : ReportContext::XTSE0580, fromYYLTYPE((yyloc), parseInfo));
6223  }
6224  else
6225  {
6226  if(isParsingWithParam)
6227  parseInfo->templateWithParams[(yyvsp[(3) - (5)].qName)] = WithParam::Ptr(new WithParam((yyvsp[(3) - (5)].qName), (yyvsp[(4) - (5)].sequenceType), expr));
6228  else
6229  {
6230  Q_ASSERT(type);
6231  pushVariable((yyvsp[(3) - (5)].qName), type, expr, VariableDeclaration::TemplateParameter, (yyloc), parseInfo);
6232  parseInfo->templateParameters.append(parseInfo->variables.top());
6233  }
6234  }
6235  }
6236  }
6237  break;
6238 
6239  case 288:
6240 /* Line 1269 of yacc.c. */
6241 #line 3359 "querytransformparser.ypp"
6242  {
6243  (yyval.enums.Bool) = false;
6244  }
6245  break;
6246 
6247  case 289:
6248 /* Line 1269 of yacc.c. */
6249 #line 3363 "querytransformparser.ypp"
6250  {
6251  (yyval.enums.Bool) = true;
6252  }
6253  break;
6254 
6255  case 290:
6256 /* Line 1269 of yacc.c. */
6257 #line 3368 "querytransformparser.ypp"
6258  {
6259  (yyval.expr) = Expression::Ptr();
6260  }
6261  break;
6262 
6263  case 291:
6264 /* Line 1269 of yacc.c. */
6265 #line 3372 "querytransformparser.ypp"
6266  {
6267  (yyval.expr) = (yyvsp[(2) - (2)].expr);
6268  }
6269  break;
6270 
6271  case 292:
6272 /* Line 1269 of yacc.c. */
6273 #line 3381 "querytransformparser.ypp"
6274  {
6275  (yyval.enums.pathKind) = Path::RegularPath;
6276  }
6277  break;
6278 
6279  case 293:
6280 /* Line 1269 of yacc.c. */
6281 #line 3385 "querytransformparser.ypp"
6282  {
6283  (yyval.enums.pathKind) = Path::XSLTForEach;
6284  }
6285  break;
6286 
6287  case 294:
6288 /* Line 1269 of yacc.c. */
6289 #line 3389 "querytransformparser.ypp"
6290  {
6291  (yyval.enums.pathKind) = Path::ForApplyTemplate;
6292  }
6293  break;
6294 
6295  case 296:
6296 /* Line 1269 of yacc.c. */
6297 #line 3395 "querytransformparser.ypp"
6298  {
6299  (yyval.expr) = create(GenericPredicate::create((yyvsp[(1) - (4)].expr), (yyvsp[(3) - (4)].expr), parseInfo->staticContext, fromYYLTYPE((yyloc), parseInfo)), (yyloc), parseInfo);
6300  }
6301  break;
6302 
6303  case 299:
6304 /* Line 1269 of yacc.c. */
6305 #line 3403 "querytransformparser.ypp"
6306  {
6307  if((yyvsp[(1) - (1)].enums.axis) == QXmlNodeModelIndex::AxisAttribute)
6308  parseInfo->nodeTestSource = BuiltinTypes::attribute;
6309  }
6310  break;
6311 
6312  case 300:
6313 /* Line 1269 of yacc.c. */
6314 #line 3408 "querytransformparser.ypp"
6315  {
6316  if((yyvsp[(3) - (3)].itemType))
6317  {
6318  /* A node test was explicitly specified. The un-abbreviated syntax was used. */
6319  (yyval.expr) = create(new AxisStep((yyvsp[(1) - (3)].enums.axis), (yyvsp[(3) - (3)].itemType)), (yyloc), parseInfo);
6320  }
6321  else
6322  {
6323  /* Quote from 3.2.1.1 Axes
6324  *
6325  * [Definition: Every axis has a principal node kind. If an axis
6326  * can contain elements, then the principal node kind is element;
6327  * otherwise, it is the kind of nodes that the axis can contain.] Thus:
6328  * - For the attribute axis, the principal node kind is attribute.
6329  * - For all other axes, the principal node kind is element. */
6330 
6331  if((yyvsp[(1) - (3)].enums.axis) == QXmlNodeModelIndex::AxisAttribute)
6332  (yyval.expr) = create(new AxisStep(QXmlNodeModelIndex::AxisAttribute, BuiltinTypes::attribute), (yyloc), parseInfo);
6333  else
6334  (yyval.expr) = create(new AxisStep((yyvsp[(1) - (3)].enums.axis), BuiltinTypes::element), (yyloc), parseInfo);
6335  }
6336 
6337  parseInfo->restoreNodeTestSource();
6338  }
6339  break;
6340 
6341  case 304:
6342 /* Line 1269 of yacc.c. */
6343 #line 3438 "querytransformparser.ypp"
6344  {
6345  if((yyvsp[(1) - (2)].enums.axis) == QXmlNodeModelIndex::AxisNamespace)
6346  {
6347  /* We don't raise XPST0010 here because the namespace axis isn't an optional
6348  * axis. It simply is not part of the XQuery grammar. */
6349  parseInfo->staticContext->error(QtXmlPatterns::tr("The %1-axis is unsupported in XQuery")
6350  .arg(formatKeyword("namespace")),
6351  ReportContext::XPST0003, fromYYLTYPE((yyloc), parseInfo));
6352  }
6353  else
6354  (yyval.enums.axis) = (yyvsp[(1) - (2)].enums.axis);
6355 
6356  switch((yyvsp[(1) - (2)].enums.axis))
6357  {
6359  {
6360  allowedIn(QueryLanguages( QXmlQuery::XPath20
6363  | QXmlQuery::XSLT20),
6364  parseInfo, (yyloc));
6365  break;
6366  }
6368  {
6369  allowedIn(QueryLanguages( QXmlQuery::XPath20
6373  | QXmlQuery::XSLT20),
6374  parseInfo, (yyloc));
6375  break;
6376  }
6377  default:
6378  {
6379  allowedIn(QueryLanguages( QXmlQuery::XPath20
6381  | QXmlQuery::XSLT20),
6382  parseInfo, (yyloc));
6383  }
6384  }
6385  }
6386  break;
6387 
6388  case 305:
6389 /* Line 1269 of yacc.c. */
6390 #line 3481 "querytransformparser.ypp"
6391  {(yyval.enums.axis) = QXmlNodeModelIndex::AxisAncestorOrSelf ;}
6392  break;
6393 
6394  case 306:
6395 /* Line 1269 of yacc.c. */
6396 #line 3482 "querytransformparser.ypp"
6397  {(yyval.enums.axis) = QXmlNodeModelIndex::AxisAncestor ;}
6398  break;
6399 
6400  case 307:
6401 /* Line 1269 of yacc.c. */
6402 #line 3483 "querytransformparser.ypp"
6403  {(yyval.enums.axis) = QXmlNodeModelIndex::AxisAttribute ;}
6404  break;
6405 
6406  case 308:
6407 /* Line 1269 of yacc.c. */
6408 #line 3484 "querytransformparser.ypp"
6409  {(yyval.enums.axis) = QXmlNodeModelIndex::AxisChild ;}
6410  break;
6411 
6412  case 309:
6413 /* Line 1269 of yacc.c. */
6414 #line 3485 "querytransformparser.ypp"
6415  {(yyval.enums.axis) = QXmlNodeModelIndex::AxisDescendantOrSelf;}
6416  break;
6417 
6418  case 310:
6419 /* Line 1269 of yacc.c. */
6420 #line 3486 "querytransformparser.ypp"
6421  {(yyval.enums.axis) = QXmlNodeModelIndex::AxisDescendant ;}
6422  break;
6423 
6424  case 311:
6425 /* Line 1269 of yacc.c. */
6426 #line 3487 "querytransformparser.ypp"
6427  {(yyval.enums.axis) = QXmlNodeModelIndex::AxisFollowing ;}
6428  break;
6429 
6430  case 312:
6431 /* Line 1269 of yacc.c. */
6432 #line 3488 "querytransformparser.ypp"
6433  {(yyval.enums.axis) = QXmlNodeModelIndex::AxisPreceding ;}
6434  break;
6435 
6436  case 313:
6437 /* Line 1269 of yacc.c. */
6438 #line 3489 "querytransformparser.ypp"
6439  {(yyval.enums.axis) = QXmlNodeModelIndex::AxisFollowingSibling;}
6440  break;
6441 
6442  case 314:
6443 /* Line 1269 of yacc.c. */
6444 #line 3490 "querytransformparser.ypp"
6445  {(yyval.enums.axis) = QXmlNodeModelIndex::AxisPrecedingSibling;}
6446  break;
6447 
6448  case 315:
6449 /* Line 1269 of yacc.c. */
6450 #line 3491 "querytransformparser.ypp"
6451  {(yyval.enums.axis) = QXmlNodeModelIndex::AxisParent ;}
6452  break;
6453 
6454  case 316:
6455 /* Line 1269 of yacc.c. */
6456 #line 3492 "querytransformparser.ypp"
6457  {(yyval.enums.axis) = QXmlNodeModelIndex::AxisSelf ;}
6458  break;
6459 
6460  case 317:
6461 /* Line 1269 of yacc.c. */
6462 #line 3495 "querytransformparser.ypp"
6463  {
6464  parseInfo->nodeTestSource = BuiltinTypes::attribute;
6465  }
6466  break;
6467 
6468  case 318:
6469 /* Line 1269 of yacc.c. */
6470 #line 3499 "querytransformparser.ypp"
6471  {
6473  (yyval.expr) = create(new AxisStep(QXmlNodeModelIndex::AxisAttribute, (yyvsp[(3) - (3)].itemType)), (yyloc), parseInfo);
6474 
6475  parseInfo->restoreNodeTestSource();
6476  }
6477  break;
6478 
6479  case 319:
6480 /* Line 1269 of yacc.c. */
6481 #line 3506 "querytransformparser.ypp"
6482  {
6483  ItemType::Ptr nodeTest;
6484 
6485  if(parseInfo->isParsingPattern && *(yyvsp[(1) - (1)].itemType) == *BuiltinTypes::node)
6486  nodeTest = BuiltinTypes::xsltNodeTest;
6487  else
6488  nodeTest = (yyvsp[(1) - (1)].itemType);
6489 
6490  (yyval.expr) = create(new AxisStep(QXmlNodeModelIndex::AxisChild, nodeTest), (yyloc), parseInfo);
6491  }
6492  break;
6493 
6494  case 320:
6495 /* Line 1269 of yacc.c. */
6496 #line 3517 "querytransformparser.ypp"
6497  {
6498  (yyval.expr) = create(new AxisStep(QXmlNodeModelIndex::AxisAttribute, (yyvsp[(1) - (1)].itemType)), (yyloc), parseInfo);
6499  }
6500  break;
6501 
6502  case 322:
6503 /* Line 1269 of yacc.c. */
6504 #line 3524 "querytransformparser.ypp"
6505  {
6506  (yyval.expr) = create(new AxisStep(QXmlNodeModelIndex::AxisParent, BuiltinTypes::node), (yyloc), parseInfo);
6507  }
6508  break;
6509 
6510  case 324:
6511 /* Line 1269 of yacc.c. */
6512 #line 3530 "querytransformparser.ypp"
6513  {
6514  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
6515  }
6516  break;
6517 
6518  case 325:
6519 /* Line 1269 of yacc.c. */
6520 #line 3535 "querytransformparser.ypp"
6521  {
6522  (yyval.itemType) = QNameTest::create(parseInfo->nodeTestSource, (yyvsp[(1) - (1)].qName));
6523  }
6524  break;
6525 
6526  case 327:
6527 /* Line 1269 of yacc.c. */
6528 #line 3541 "querytransformparser.ypp"
6529  {
6530  (yyval.itemType) = parseInfo->nodeTestSource;
6531  }
6532  break;
6533 
6534  case 328:
6535 /* Line 1269 of yacc.c. */
6536 #line 3545 "querytransformparser.ypp"
6537  {
6538  const NamePool::Ptr np(parseInfo->staticContext->namePool());
6539  const ReflectYYLTYPE ryy((yyloc), parseInfo);
6540 
6541  const QXmlName::NamespaceCode ns(QNameConstructor::namespaceForPrefix(np->allocatePrefix((yyvsp[(1) - (1)].sval)), parseInfo->staticContext, &ryy));
6542 
6543  (yyval.itemType) = NamespaceNameTest::create(parseInfo->nodeTestSource, ns);
6544  }
6545  break;
6546 
6547  case 329:
6548 /* Line 1269 of yacc.c. */
6549 #line 3554 "querytransformparser.ypp"
6550  {
6551  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
6552  const QXmlName::LocalNameCode c = parseInfo->staticContext->namePool()->allocateLocalName((yyvsp[(1) - (1)].sval));
6553  (yyval.itemType) = LocalNameTest::create(parseInfo->nodeTestSource, c);
6554  }
6555  break;
6556 
6557  case 331:
6558 /* Line 1269 of yacc.c. */
6559 #line 3562 "querytransformparser.ypp"
6560  {
6561  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
6562  (yyval.expr) = create(GenericPredicate::create((yyvsp[(1) - (4)].expr), (yyvsp[(3) - (4)].expr), parseInfo->staticContext, fromYYLTYPE((yylsp[(4) - (4)]), parseInfo)), (yyloc), parseInfo);
6563  }
6564  break;
6565 
6566  case 339:
6567 /* Line 1269 of yacc.c. */
6568 #line 3575 "querytransformparser.ypp"
6569  {
6570  (yyval.expr) = create(new ApplyTemplate(parseInfo->modeFor((yyvsp[(2) - (5)].qName)),
6571  parseInfo->templateWithParams,
6572  parseInfo->modeFor(QXmlName(StandardNamespaces::InternalXSLT,
6574  (yylsp[(1) - (5)]), parseInfo);
6575  parseInfo->templateWithParametersHandled();
6576  }
6577  break;
6578 
6579  case 341:
6580 /* Line 1269 of yacc.c. */
6581 #line 3586 "querytransformparser.ypp"
6582  {
6583  (yyval.expr) = create(new Literal(AtomicString::fromValue((yyvsp[(1) - (1)].sval))), (yyloc), parseInfo);
6584  }
6585  break;
6586 
6587  case 342:
6588 /* Line 1269 of yacc.c. */
6589 #line 3591 "querytransformparser.ypp"
6590  {
6591  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
6592  (yyval.expr) = createNumericLiteral<Double>((yyvsp[(1) - (1)].sval), (yyloc), parseInfo);
6593  }
6594  break;
6595 
6596  case 343:
6597 /* Line 1269 of yacc.c. */
6598 #line 3596 "querytransformparser.ypp"
6599  {
6600  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
6601  (yyval.expr) = createNumericLiteral<Numeric>((yyvsp[(1) - (1)].sval), (yyloc), parseInfo);
6602  }
6603  break;
6604 
6605  case 344:
6606 /* Line 1269 of yacc.c. */
6607 #line 3602 "querytransformparser.ypp"
6608  {
6609  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
6610  (yyval.expr) = resolveVariable((yyvsp[(2) - (2)].qName), (yyloc), parseInfo, false);
6611  }
6612  break;
6613 
6614  case 345:
6615 /* Line 1269 of yacc.c. */
6616 #line 3608 "querytransformparser.ypp"
6617  {
6618  /* See: http://www.w3.org/TR/xpath20/#id-variables */
6619  (yyval.qName) = parseInfo->staticContext->namePool()->allocateQName(QString(), (yyvsp[(1) - (1)].sval));
6620  }
6621  break;
6622 
6623  case 346:
6624 /* Line 1269 of yacc.c. */
6625 #line 3613 "querytransformparser.ypp"
6626  {
6627  (yyval.qName) = (yyvsp[(1) - (1)].qName);
6628  }
6629  break;
6630 
6631  case 347:
6632 /* Line 1269 of yacc.c. */
6633 #line 3618 "querytransformparser.ypp"
6634  {
6635  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
6636  (yyval.expr) = (yyvsp[(2) - (3)].expr);
6637  }
6638  break;
6639 
6640  case 348:
6641 /* Line 1269 of yacc.c. */
6642 #line 3623 "querytransformparser.ypp"
6643  {
6644  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
6645  (yyval.expr) = create(new EmptySequence, (yyloc), parseInfo);
6646  }
6647  break;
6648 
6649  case 349:
6650 /* Line 1269 of yacc.c. */
6651 #line 3629 "querytransformparser.ypp"
6652  {
6653  (yyval.expr) = create(new ContextItem(), (yyloc), parseInfo);
6654  }
6655  break;
6656 
6657  case 350:
6658 /* Line 1269 of yacc.c. */
6659 #line 3634 "querytransformparser.ypp"
6660  {
6661  (yyval.expr) = (yyvsp[(2) - (2)].expr);
6662  }
6663  break;
6664 
6665  case 351:
6666 /* Line 1269 of yacc.c. */
6667 #line 3639 "querytransformparser.ypp"
6668  {
6669  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
6670  if(XPathHelper::isReservedNamespace((yyvsp[(1) - (4)].qName).namespaceURI()) || (yyvsp[(1) - (4)].qName).namespaceURI() == StandardNamespaces::InternalXSLT)
6671  { /* We got a call to a builtin function. */
6672  const ReflectYYLTYPE ryy((yyloc), parseInfo);
6673 
6674  const Expression::Ptr
6675  func(parseInfo->staticContext->
6676  functionSignatures()->createFunctionCall((yyvsp[(1) - (4)].qName), (yyvsp[(3) - (4)].expressionList), parseInfo->staticContext, &ryy));
6677 
6678  if(func)
6679  (yyval.expr) = create(func, (yyloc), parseInfo);
6680  else
6681  {
6682  parseInfo->staticContext->error(QtXmlPatterns::tr("No function with name %1 is available.")
6683  .arg(formatKeyword(parseInfo->staticContext->namePool(), (yyvsp[(1) - (4)].qName))),
6684  ReportContext::XPST0017, fromYYLTYPE((yyloc), parseInfo));
6685  }
6686  }
6687  else /* It's a call to a function created with 'declare function'.*/
6688  {
6689  (yyval.expr) = create(new UserFunctionCallsite((yyvsp[(1) - (4)].qName), (yyvsp[(3) - (4)].expressionList).count()), (yyloc), parseInfo);
6690 
6691  (yyval.expr)->setOperands((yyvsp[(3) - (4)].expressionList));
6692  parseInfo->userFunctionCallsites.append((yyval.expr));
6693  }
6694  }
6695  break;
6696 
6697  case 352:
6698 /* Line 1269 of yacc.c. */
6699 #line 3668 "querytransformparser.ypp"
6700  {
6701  (yyval.expressionList) = Expression::List();
6702  }
6703  break;
6704 
6705  case 353:
6706 /* Line 1269 of yacc.c. */
6707 #line 3673 "querytransformparser.ypp"
6708  {
6709  Expression::List list;
6710  list.append((yyvsp[(1) - (1)].expr));
6711  (yyval.expressionList) = list;
6712  }
6713  break;
6714 
6715  case 355:
6716 /* Line 1269 of yacc.c. */
6717 #line 3682 "querytransformparser.ypp"
6718  {
6719  allowedIn(QXmlQuery::XQuery10, parseInfo, (yyloc));
6720  }
6721  break;
6722 
6723  case 360:
6724 /* Line 1269 of yacc.c. */
6725 #line 3726 "querytransformparser.ypp"
6726  {
6727  (yyval.enums.tokenizerPosition) = parseInfo->tokenizer->commenceScanOnly();
6728  parseInfo->scanOnlyStack.push(true);
6729  }
6730  break;
6731 
6732  case 361:
6733 /* Line 1269 of yacc.c. */
6734 #line 3735 "querytransformparser.ypp"
6735  {
6736  ++parseInfo->elementConstructorDepth;
6737  Expression::List constructors;
6738 
6739  parseInfo->resolvers.push(parseInfo->staticContext->namespaceBindings());
6740 
6741  /* Fix up attributes and namespace declarations. */
6742  const NamespaceResolver::Ptr resolver(new DelegatingNamespaceResolver(parseInfo->staticContext->namespaceBindings()));
6743  const NamePool::Ptr namePool(parseInfo->staticContext->namePool());
6744  const int len = (yyvsp[(4) - (4)].attributeHolders).size();
6745  QSet<QXmlName::PrefixCode> usedDeclarations;
6746 
6747  /* Whether xmlns="" has been encountered. */
6748  bool hasDefaultDeclaration = false;
6749 
6750  /* For each attribute & namespace declaration, do: */
6751  for(int i = 0; i < len; ++i)
6752  {
6753  QString strLocalName;
6754  QString strPrefix;
6755 
6756  XPathHelper::splitQName((yyvsp[(4) - (4)].attributeHolders).at(i).first, strPrefix, strLocalName);
6757  const QXmlName::PrefixCode prefix = namePool->allocatePrefix(strPrefix);
6758 
6759  /* This can seem a bit weird. However, this name is ending up in a QXmlName
6760  * which consider its prefix a... prefix. So, a namespace binding name can in some cases
6761  * be a local name, but that's just as the initial syntactical construct. */
6762  const QXmlName::LocalNameCode localName = namePool->allocatePrefix(strLocalName);
6763 
6764  /* Not that localName is "foo" in "xmlns:foo" and that prefix is "xmlns". */
6765 
6766  if(prefix == StandardPrefixes::xmlns ||
6767  (prefix == StandardPrefixes::empty && localName == StandardPrefixes::xmlns))
6768  {
6769  if(localName == StandardPrefixes::xmlns)
6770  hasDefaultDeclaration = true;
6771 
6772  /* We have a namespace declaration. */
6773 
6774  const Expression::Ptr nsExpr((yyvsp[(4) - (4)].attributeHolders).at(i).second);
6775 
6776  const QString strNamespace(nsExpr->is(Expression::IDEmptySequence) ? QString() : nsExpr->as<Literal>()->item().stringValue());
6777 
6778  const QXmlName::NamespaceCode ns = namePool->allocateNamespace(strNamespace);
6779 
6780  if(ns == StandardNamespaces::empty)
6781  {
6782  if(localName != StandardPrefixes::xmlns)
6783  {
6784  parseInfo->staticContext->error(QtXmlPatterns::tr("The namespace URI cannot be the empty string when binding to a prefix, %1.")
6785  .arg(formatURI(strPrefix)),
6786  ReportContext::XQST0085, fromYYLTYPE((yyloc), parseInfo));
6787  }
6788  }
6789  else if(!AnyURI::isValid(strNamespace))
6790  {
6791  parseInfo->staticContext->error(QtXmlPatterns::tr("%1 is an invalid namespace URI.").arg(formatURI(strNamespace)),
6792  ReportContext::XQST0022, fromYYLTYPE((yyloc), parseInfo));
6793  }
6794 
6795  if(prefix == StandardPrefixes::xmlns && localName == StandardPrefixes::xmlns)
6796  {
6797  parseInfo->staticContext->error(QtXmlPatterns::tr("It is not possible to bind to the prefix %1")
6798  .arg(formatKeyword("xmlns")),
6799  ReportContext::XQST0070, fromYYLTYPE((yyloc), parseInfo));
6800  }
6801 
6802  if(ns == StandardNamespaces::xml && localName != StandardPrefixes::xml)
6803  {
6804  parseInfo->staticContext->error(QtXmlPatterns::tr("Namespace %1 can only be bound to %2 (and it is, in either case, pre-declared).")
6805  .arg(formatURI(namePool->stringForNamespace(StandardNamespaces::xml)))
6806  .arg(formatKeyword("xml")),
6807  ReportContext::XQST0070, fromYYLTYPE((yyloc), parseInfo));
6808  }
6809 
6810  if(localName == StandardPrefixes::xml && ns != StandardNamespaces::xml)
6811  {
6812  parseInfo->staticContext->error(QtXmlPatterns::tr("Prefix %1 can only be bound to %2 (and it is, in either case, pre-declared).")
6813  .arg(formatKeyword("xml"))
6814  .arg(formatURI(namePool->stringForNamespace(StandardNamespaces::xml))),
6815  ReportContext::XQST0070, fromYYLTYPE((yyloc), parseInfo));
6816  }
6817 
6818  QXmlName nb;
6819 
6820  if(localName == StandardPrefixes::xmlns)
6822  else
6823  nb = QXmlName(ns, StandardLocalNames::empty, localName);
6824 
6825  if(usedDeclarations.contains(nb.prefix()))
6826  {
6827  parseInfo->staticContext->error(QtXmlPatterns::tr("Two namespace declaration attributes have the same name: %1.")
6828  .arg(formatKeyword(namePool->stringForPrefix(nb.prefix()))),
6829  ReportContext::XQST0071, fromYYLTYPE((yyloc), parseInfo));
6830 
6831  }
6832  else
6833  usedDeclarations.insert(nb.prefix());
6834 
6835  /* If the user has bound the XML namespace correctly, we in either
6836  * case don't want to output it.
6837  *
6838  * We only have to check the namespace parts since the above checks has ensured
6839  * consistency in the prefix parts. */
6840  if(ns != StandardNamespaces::xml)
6841  {
6842  /* We don't want default namespace declarations when the
6843  * default namespace already is empty. */
6844  if(!(ns == StandardNamespaces::empty &&
6845  localName == StandardNamespaces::xmlns &&
6846  resolver->lookupNamespaceURI(StandardPrefixes::empty) == StandardNamespaces::empty))
6847  {
6848  constructors.append(create(new NamespaceConstructor(nb), (yyloc), parseInfo));
6849  resolver->addBinding(nb);
6850  }
6851  }
6852  }
6853  }
6854 
6855  if(parseInfo->elementConstructorDepth == 1 && !hasDefaultDeclaration)
6856  {
6857  /* TODO But mostly this isn't needed, since the default element
6858  * namespace is empty? How does this at all work? */
6859  const QXmlName def(resolver->lookupNamespaceURI(StandardPrefixes::empty), StandardLocalNames::empty);
6860  constructors.append(create(new NamespaceConstructor(def), (yyloc), parseInfo));
6861  }
6862 
6863  parseInfo->staticContext->setNamespaceBindings(resolver);
6864  (yyval.expressionList) = constructors;
6865 
6866  /* Resolve the name of the element, now that the namespace attributes are read. */
6867  {
6868  const ReflectYYLTYPE ryy((yyloc), parseInfo);
6869 
6872  ReportContext::XPST0081>((yyvsp[(2) - (4)].sval), parseInfo->staticContext, resolver, &ryy);
6873  parseInfo->tagStack.push(ele);
6874  }
6875 
6876  parseInfo->tokenizer->resumeTokenizationFrom((yyvsp[(3) - (4)].enums.tokenizerPosition));
6877  }
6878  break;
6879 
6880  case 362:
6881 /* Line 1269 of yacc.c. */
6882 #line 3881 "querytransformparser.ypp"
6883  {
6884  /* We add the content constructor after the attribute constructors. This might result
6885  * in nested ExpressionSequences, but it will be optimized away later on. */
6886 
6887  Expression::List attributes((yyvsp[(5) - (8)].expressionList));
6888  const NamePool::Ptr namePool(parseInfo->staticContext->namePool());
6889  const int len = (yyvsp[(7) - (8)].attributeHolders).size();
6890  QSet<QXmlName> declaredAttributes;
6891  declaredAttributes.reserve(len);
6892 
6893  /* For each namespace, resolve its name(now that we have resolved the namespace declarations) and
6894  * turn it into an attribute constructor. */
6895  for(int i = 0; i < len; ++i)
6896  {
6897  QString strLocalName;
6898  QString strPrefix;
6899 
6900  XPathHelper::splitQName((yyvsp[(7) - (8)].attributeHolders).at(i).first, strPrefix, strLocalName);
6901  const QXmlName::PrefixCode prefix = namePool->allocatePrefix(strPrefix);
6902  const QXmlName::LocalNameCode localName = namePool->allocateLocalName(strLocalName);
6903 
6904  if(prefix == StandardPrefixes::xmlns ||
6905  (prefix == StandardPrefixes::empty && localName == StandardLocalNames::xmlns))
6906  {
6907  const Expression::ID id = (yyvsp[(7) - (8)].attributeHolders).at(i).second->id();
6908 
6910  {
6911  /* It's a namespace declaration, and we've already handled those above. */
6912  continue;
6913  }
6914  else
6915  {
6916  parseInfo->staticContext->error(QtXmlPatterns::tr("The namespace URI must be a constant and cannot "
6917  "use enclosed expressions."),
6918  ReportContext::XQST0022, fromYYLTYPE((yyloc), parseInfo));
6919  }
6920 
6921  }
6922  else
6923  {
6924  const ReflectYYLTYPE ryy((yyloc), parseInfo);
6927  ReportContext::XPST0081>((yyvsp[(7) - (8)].attributeHolders).at(i).first, parseInfo->staticContext,
6928  parseInfo->staticContext->namespaceBindings(),
6929  &ryy, true);
6930  if(declaredAttributes.contains(att))
6931  {
6932  parseInfo->staticContext->error(QtXmlPatterns::tr("An attribute with name %1 has already appeared on this element.")
6933  .arg(formatKeyword(parseInfo->staticContext->namePool(), att)),
6934  ReportContext::XQST0040, fromYYLTYPE((yyloc), parseInfo));
6935 
6936  }
6937  else
6938  declaredAttributes.insert(att);
6939 
6940  /* wrapLiteral() needs the SourceLocationReflection of the AttributeConstructor, but
6941  * it's unknown inside the arguments to its constructor. Hence we have to do this workaround of setting
6942  * it twice.
6943  *
6944  * The AttributeConstructor's arguments are just dummies. */
6945  const Expression::Ptr ctor(create(new AttributeConstructor((yyvsp[(7) - (8)].attributeHolders).at(i).second, (yyvsp[(7) - (8)].attributeHolders).at(i).second), (yyloc), parseInfo));
6946 
6947  Expression::List ops;
6948  ops.append(wrapLiteral(toItem(QNameValue::fromValue(namePool, att)), parseInfo->staticContext, ctor.data()));
6949  ops.append((yyvsp[(7) - (8)].attributeHolders).at(i).second);
6950  ctor->setOperands(ops);
6951 
6952  attributes.append(ctor);
6953  }
6954  }
6955 
6956  Expression::Ptr contentOp;
6957 
6958  if(attributes.isEmpty())
6959  contentOp = (yyvsp[(8) - (8)].expr);
6960  else
6961  {
6962  attributes.append((yyvsp[(8) - (8)].expr));
6963  contentOp = create(new ExpressionSequence(attributes), (yyloc), parseInfo);
6964  }
6965 
6966  const Expression::Ptr name(create(new Literal(toItem(QNameValue::fromValue(parseInfo->staticContext->namePool(), parseInfo->tagStack.top()))), (yyloc), parseInfo));
6967  (yyval.expr) = create(new ElementConstructor(name, contentOp, parseInfo->isXSLT()), (yyloc), parseInfo);
6968 
6969  /* Restore the old context. We don't want the namespaces
6970  * to be in-scope for expressions appearing after the
6971  * element they appeared on. */
6972  parseInfo->staticContext->setNamespaceBindings(parseInfo->resolvers.pop());
6973  parseInfo->tagStack.pop();
6974 
6975  --parseInfo->elementConstructorDepth;
6976  }
6977  break;
6978 
6979  case 363:
6980 /* Line 1269 of yacc.c. */
6981 #line 3977 "querytransformparser.ypp"
6982  {
6983  (yyval.expr) = create(new EmptySequence(), (yyloc), parseInfo);
6984  }
6985  break;
6986 
6987  case 364:
6988 /* Line 1269 of yacc.c. */
6989 #line 3981 "querytransformparser.ypp"
6990  {
6991  if(!(yyvsp[(4) - (5)].qName).isLexicallyEqual(parseInfo->tagStack.top()))
6992  {
6993  parseInfo->staticContext->error(QtXmlPatterns::tr("A direct element constructor is not "
6994  "well-formed. %1 is ended with %2.")
6995  .arg(formatKeyword(parseInfo->staticContext->namePool()->toLexical(parseInfo->tagStack.top())),
6996  formatKeyword(parseInfo->staticContext->namePool()->toLexical((yyvsp[(4) - (5)].qName)))),
6997  ReportContext::XPST0003, fromYYLTYPE((yyloc), parseInfo));
6998  }
6999 
7000  if((yyvsp[(2) - (5)].expressionList).isEmpty())
7001  (yyval.expr) = create(new EmptySequence(), (yyloc), parseInfo);
7002  else if((yyvsp[(2) - (5)].expressionList).size() == 1)
7003  (yyval.expr) = (yyvsp[(2) - (5)].expressionList).first();
7004  else
7005  (yyval.expr) = create(new ExpressionSequence((yyvsp[(2) - (5)].expressionList)), (yyloc), parseInfo);
7006  }
7007  break;
7008 
7009  case 365:
7010 /* Line 1269 of yacc.c. */
7011 #line 4000 "querytransformparser.ypp"
7012  {
7013  (yyval.attributeHolders) = AttributeHolderVector();
7014  }
7015  break;
7016 
7017  case 366:
7018 /* Line 1269 of yacc.c. */
7019 #line 4004 "querytransformparser.ypp"
7020  {
7021  (yyvsp[(1) - (2)].attributeHolders).append((yyvsp[(2) - (2)].attributeHolder));
7022  (yyval.attributeHolders) = (yyvsp[(1) - (2)].attributeHolders);
7023  }
7024  break;
7025 
7026  case 367:
7027 /* Line 1269 of yacc.c. */
7028 #line 4010 "querytransformparser.ypp"
7029  {
7030  (yyval.attributeHolder) = qMakePair((yyvsp[(1) - (3)].sval), (yyvsp[(3) - (3)].expr));
7031  }
7032  break;
7033 
7034  case 368:
7035 /* Line 1269 of yacc.c. */
7036 #line 4015 "querytransformparser.ypp"
7037  {
7038  (yyval.expr) = createDirAttributeValue((yyvsp[(2) - (3)].expressionList), parseInfo, (yyloc));
7039  }
7040  break;
7041 
7042  case 369:
7043 /* Line 1269 of yacc.c. */
7044 #line 4020 "querytransformparser.ypp"
7045  {
7046  (yyval.expr) = createDirAttributeValue((yyvsp[(2) - (3)].expressionList), parseInfo, (yyloc));
7047  }
7048  break;
7049 
7050  case 370:
7051 /* Line 1269 of yacc.c. */
7052 #line 4025 "querytransformparser.ypp"
7053  {
7054  (yyval.expressionList) = Expression::List();
7055  }
7056  break;
7057 
7058  case 371:
7059 /* Line 1269 of yacc.c. */
7060 #line 4029 "querytransformparser.ypp"
7061  {
7062  Expression::Ptr content((yyvsp[(1) - (2)].expr));
7063 
7064  if(parseInfo->isBackwardsCompat.top())
7065  content = create(GenericPredicate::createFirstItem(content), (yyloc), parseInfo);
7066 
7067  (yyvsp[(2) - (2)].expressionList).prepend(createSimpleContent(content, (yyloc), parseInfo));
7068  (yyval.expressionList) = (yyvsp[(2) - (2)].expressionList);
7069  }
7070  break;
7071 
7072  case 372:
7073 /* Line 1269 of yacc.c. */
7074 #line 4039 "querytransformparser.ypp"
7075  {
7076  (yyvsp[(2) - (2)].expressionList).prepend(create(new Literal(AtomicString::fromValue((yyvsp[(1) - (2)].sval))), (yyloc), parseInfo));
7077  (yyval.expressionList) = (yyvsp[(2) - (2)].expressionList);
7078  }
7079  break;
7080 
7081  case 373:
7082 /* Line 1269 of yacc.c. */
7083 #line 4045 "querytransformparser.ypp"
7084  {
7085  (yyval.expressionList) = Expression::List();
7086  parseInfo->isPreviousEnclosedExpr = false;
7087  }
7088  break;
7089 
7090  case 374:
7091 /* Line 1269 of yacc.c. */
7092 #line 4050 "querytransformparser.ypp"
7093  {
7094  (yyvsp[(1) - (2)].expressionList).append((yyvsp[(2) - (2)].expr));
7095  (yyval.expressionList) = (yyvsp[(1) - (2)].expressionList);
7096  parseInfo->isPreviousEnclosedExpr = false;
7097  }
7098  break;
7099 
7100  case 375:
7101 /* Line 1269 of yacc.c. */
7102 #line 4056 "querytransformparser.ypp"
7103  {
7104  if(parseInfo->staticContext->boundarySpacePolicy() == StaticContext::BSPStrip &&
7105  XPathHelper::isWhitespaceOnly((yyvsp[(2) - (2)].sval)))
7106  {
7107  (yyval.expressionList) = (yyvsp[(1) - (2)].expressionList);
7108  }
7109  else
7110  {
7111  (yyvsp[(1) - (2)].expressionList).append(create(new TextNodeConstructor(create(new Literal(AtomicString::fromValue((yyvsp[(2) - (2)].sval))), (yyloc), parseInfo)), (yyloc), parseInfo));
7112  (yyval.expressionList) = (yyvsp[(1) - (2)].expressionList);
7113  parseInfo->isPreviousEnclosedExpr = false;
7114  }
7115  }
7116  break;
7117 
7118  case 376:
7119 /* Line 1269 of yacc.c. */
7120 #line 4070 "querytransformparser.ypp"
7121  {
7122  (yyvsp[(1) - (2)].expressionList).append(create(new TextNodeConstructor(create(new Literal(AtomicString::fromValue((yyvsp[(2) - (2)].sval))), (yyloc), parseInfo)), (yyloc), parseInfo));
7123  (yyval.expressionList) = (yyvsp[(1) - (2)].expressionList);
7124  parseInfo->isPreviousEnclosedExpr = false;
7125  }
7126  break;
7127 
7128  case 377:
7129 /* Line 1269 of yacc.c. */
7130 #line 4076 "querytransformparser.ypp"
7131  {
7132  /* We insert a text node constructor that send an empty text node between
7133  * the two enclosed expressions, in order to ensure that no space is inserted.
7134  *
7135  * However, we only do it when we have no node constructors. */
7136  if(parseInfo->isPreviousEnclosedExpr &&
7137  BuiltinTypes::xsAnyAtomicType->xdtTypeMatches((yyvsp[(2) - (2)].expr)->staticType()->itemType()) &&
7138  BuiltinTypes::xsAnyAtomicType->xdtTypeMatches((yyvsp[(1) - (2)].expressionList).last()->staticType()->itemType()))
7139  (yyvsp[(1) - (2)].expressionList).append(create(new TextNodeConstructor(create(new Literal(AtomicString::fromValue(QString())), (yyloc), parseInfo)), (yyloc), parseInfo));
7140  else
7141  parseInfo->isPreviousEnclosedExpr = true;
7142 
7143  (yyvsp[(1) - (2)].expressionList).append(createCopyOf((yyvsp[(2) - (2)].expr), parseInfo, (yyloc)));
7144  (yyval.expressionList) = (yyvsp[(1) - (2)].expressionList);
7145  }
7146  break;
7147 
7148  case 378:
7149 /* Line 1269 of yacc.c. */
7150 #line 4093 "querytransformparser.ypp"
7151  {
7152  (yyval.expr) = create(new CommentConstructor(create(new Literal(AtomicString::fromValue((yyvsp[(2) - (2)].sval))), (yyloc), parseInfo)), (yyloc), parseInfo);
7153  }
7154  break;
7155 
7156  case 379:
7157 /* Line 1269 of yacc.c. */
7158 #line 4098 "querytransformparser.ypp"
7159  {
7160  const ReflectYYLTYPE ryy((yyloc), parseInfo);
7163  ReportContext::XPST0003>((yyvsp[(2) - (3)].sval),
7164  parseInfo->staticContext, &ryy);
7165 
7166  (yyval.expr) = create(new ProcessingInstructionConstructor(
7167  create(new Literal(AtomicString::fromValue((yyvsp[(2) - (3)].sval))), (yyloc), parseInfo),
7168  create(new Literal(AtomicString::fromValue((yyvsp[(3) - (3)].sval))), (yyloc), parseInfo)), (yyloc), parseInfo);
7169  }
7170  break;
7171 
7172  case 387:
7173 /* Line 1269 of yacc.c. */
7174 #line 4119 "querytransformparser.ypp"
7175  {
7176  allowedIn(QXmlQuery::XQuery10, parseInfo, (yyloc), (yyvsp[(2) - (3)].enums.Bool));
7177 
7178  (yyval.expr) = create(new DocumentConstructor((yyvsp[(3) - (3)].expr)), (yyloc), parseInfo);
7179  }
7180  break;
7181 
7182  case 388:
7183 /* Line 1269 of yacc.c. */
7184 #line 4126 "querytransformparser.ypp"
7185  {
7186  /* This value is incremented before the action below is executed. */
7187  ++parseInfo->elementConstructorDepth;
7188  }
7189  break;
7190 
7191  case 389:
7192 /* Line 1269 of yacc.c. */
7193 #line 4131 "querytransformparser.ypp"
7194  {
7195  Q_ASSERT(5);
7196  allowedIn(QXmlQuery::XQuery10, parseInfo, (yyloc), (yyvsp[(2) - (5)].enums.Bool));
7197 
7198  Expression::Ptr effExpr;
7199 
7200  if((yyvsp[(5) - (5)].expr))
7201  effExpr = createCopyOf((yyvsp[(5) - (5)].expr), parseInfo, (yyloc));
7202  else
7203  effExpr = create(new EmptySequence(), (yyloc), parseInfo);
7204 
7205  const QXmlName::NamespaceCode ns = parseInfo->resolvers.top()->lookupNamespaceURI(StandardPrefixes::empty);
7206 
7207  /* Ensure the default namespace gets counted as an in-scope binding, if such a one exists. If we're
7208  * a child of another constructor, it has already been done. */
7209  if(parseInfo->elementConstructorDepth == 1 && ns != StandardNamespaces::empty)
7210  {
7211  Expression::List exprList;
7212 
7213  /* We append the namespace constructor before the body, in order to
7214  * comply with QAbstractXmlPushHandler's contract. */
7215  const QXmlName def(parseInfo->resolvers.top()->lookupNamespaceURI(StandardPrefixes::empty), StandardLocalNames::empty);
7216  exprList.append(create(new NamespaceConstructor(def), (yyloc), parseInfo));
7217 
7218  exprList.append(effExpr);
7219 
7220  effExpr = create(new ExpressionSequence(exprList), (yyloc), parseInfo);
7221  }
7222 
7223  --parseInfo->elementConstructorDepth;
7224  (yyval.expr) = create(new ElementConstructor((yyvsp[(3) - (5)].expr), effExpr, parseInfo->isXSLT()), (yyloc), parseInfo);
7225  }
7226  break;
7227 
7228  case 390:
7229 /* Line 1269 of yacc.c. */
7230 #line 4165 "querytransformparser.ypp"
7231  {
7232  (yyval.enums.Bool) = false;
7233  }
7234  break;
7235 
7236  case 391:
7237 /* Line 1269 of yacc.c. */
7238 #line 4169 "querytransformparser.ypp"
7239  {
7240  (yyval.enums.Bool) = true;
7241  }
7242  break;
7243 
7244  case 392:
7245 /* Line 1269 of yacc.c. */
7246 #line 4177 "querytransformparser.ypp"
7247  {
7248  allowedIn(QXmlQuery::XQuery10, parseInfo, (yyloc), (yyvsp[(2) - (4)].enums.Bool));
7249 
7250  const Expression::Ptr name(create(new AttributeNameValidator((yyvsp[(3) - (4)].expr)), (yyloc), parseInfo));
7251 
7252  if((yyvsp[(4) - (4)].expr))
7253  (yyval.expr) = create(new AttributeConstructor(name, createSimpleContent((yyvsp[(4) - (4)].expr), (yyloc), parseInfo)), (yyloc), parseInfo);
7254  else
7255  (yyval.expr) = create(new AttributeConstructor(name, create(new EmptySequence(), (yyloc), parseInfo)), (yyloc), parseInfo);
7256  }
7257  break;
7258 
7259  case 393:
7260 /* Line 1269 of yacc.c. */
7261 #line 4189 "querytransformparser.ypp"
7262  {
7263  (yyval.expr) = create(new TextNodeConstructor(createSimpleContent((yyvsp[(3) - (3)].expr), (yyloc), parseInfo)), (yyloc), parseInfo);
7264  }
7265  break;
7266 
7267  case 394:
7268 /* Line 1269 of yacc.c. */
7269 #line 4194 "querytransformparser.ypp"
7270  {
7271  allowedIn(QXmlQuery::XQuery10, parseInfo, (yyloc), (yyvsp[(2) - (3)].enums.Bool));
7272 
7273  (yyval.expr) = create(new CommentConstructor(createSimpleContent((yyvsp[(3) - (3)].expr), (yyloc), parseInfo)), (yyloc), parseInfo);
7274  }
7275  break;
7276 
7277  case 395:
7278 /* Line 1269 of yacc.c. */
7279 #line 4201 "querytransformparser.ypp"
7280  {
7281  allowedIn(QXmlQuery::XQuery10, parseInfo, (yyloc), (yyvsp[(2) - (3)].expr));
7282 
7283  if((yyvsp[(3) - (3)].expr))
7284  {
7285  (yyval.expr) = create(new ProcessingInstructionConstructor((yyvsp[(2) - (3)].expr), createSimpleContent((yyvsp[(3) - (3)].expr), (yyloc), parseInfo)), (yyloc), parseInfo);
7286  }
7287  else
7288  (yyval.expr) = create(new ProcessingInstructionConstructor((yyvsp[(2) - (3)].expr), create(new EmptySequence(), (yyloc), parseInfo)), (yyloc), parseInfo);
7289  }
7290  break;
7291 
7292  case 396:
7293 /* Line 1269 of yacc.c. */
7294 #line 4212 "querytransformparser.ypp"
7295  {
7296  parseInfo->nodeTestSource = BuiltinTypes::attribute;
7297  }
7298  break;
7299 
7300  case 397:
7301 /* Line 1269 of yacc.c. */
7302 #line 4216 "querytransformparser.ypp"
7303  {
7304  parseInfo->restoreNodeTestSource();
7305  }
7306  break;
7307 
7308  case 398:
7309 /* Line 1269 of yacc.c. */
7310 #line 4219 "querytransformparser.ypp"
7311  {
7312  (yyval.expr) = create(new Literal(toItem(QNameValue::fromValue(parseInfo->staticContext->namePool(), (yyvsp[(2) - (3)].qName)))), (yyloc), parseInfo);
7313  }
7314  break;
7315 
7316  case 400:
7317 /* Line 1269 of yacc.c. */
7318 #line 4225 "querytransformparser.ypp"
7319  {
7320  (yyval.expr) = create(new Literal(toItem(QNameValue::fromValue(parseInfo->staticContext->namePool(), (yyvsp[(1) - (1)].qName)))), (yyloc), parseInfo);
7321  }
7322  break;
7323 
7324  case 402:
7325 /* Line 1269 of yacc.c. */
7326 #line 4231 "querytransformparser.ypp"
7327  {
7328  if(BuiltinTypes::xsQName->xdtTypeMatches((yyvsp[(1) - (1)].expr)->staticType()->itemType()))
7329  (yyval.expr) = (yyvsp[(1) - (1)].expr);
7330  else
7331  {
7332  (yyval.expr) = create(new QNameConstructor((yyvsp[(1) - (1)].expr),
7333  parseInfo->staticContext->namespaceBindings()),
7334  (yyloc), parseInfo);
7335  }
7336  }
7337  break;
7338 
7339  case 403:
7340 /* Line 1269 of yacc.c. */
7341 #line 4246 "querytransformparser.ypp"
7342  {
7343  (yyval.expr) = create(new NCNameConstructor(create(new Literal(AtomicString::fromValue((yyvsp[(1) - (1)].sval))), (yyloc), parseInfo)), (yyloc), parseInfo);
7344  }
7345  break;
7346 
7347  case 404:
7348 /* Line 1269 of yacc.c. */
7349 #line 4250 "querytransformparser.ypp"
7350  {
7351  (yyval.expr) = create(new NCNameConstructor((yyvsp[(1) - (1)].expr)), (yyloc), parseInfo);
7352  }
7353  break;
7354 
7355  case 405:
7356 /* Line 1269 of yacc.c. */
7357 #line 4259 "querytransformparser.ypp"
7358  {
7359  (yyval.expr) = create(new ComputedNamespaceConstructor((yyvsp[(2) - (3)].expr), (yyvsp[(3) - (3)].expr)), (yyloc), parseInfo);
7360 }
7361  break;
7362 
7363  case 406:
7364 /* Line 1269 of yacc.c. */
7365 #line 4264 "querytransformparser.ypp"
7366  {
7367  (yyval.sequenceType) = makeGenericSequenceType((yyvsp[(1) - (1)].itemType), Cardinality::exactlyOne());
7368  }
7369  break;
7370 
7371  case 407:
7372 /* Line 1269 of yacc.c. */
7373 #line 4268 "querytransformparser.ypp"
7374  {
7375  (yyval.sequenceType) = makeGenericSequenceType((yyvsp[(1) - (2)].itemType), Cardinality::zeroOrOne());
7376  }
7377  break;
7378 
7379  case 408:
7380 /* Line 1269 of yacc.c. */
7381 #line 4273 "querytransformparser.ypp"
7382  {
7383  (yyval.sequenceType) = CommonSequenceTypes::ZeroOrMoreItems;
7384  }
7385  break;
7386 
7387  case 409:
7388 /* Line 1269 of yacc.c. */
7389 #line 4277 "querytransformparser.ypp"
7390  {
7391  (yyval.sequenceType) = (yyvsp[(2) - (2)].sequenceType);
7392  }
7393  break;
7394 
7395  case 410:
7396 /* Line 1269 of yacc.c. */
7397 #line 4282 "querytransformparser.ypp"
7398  {
7399  (yyval.sequenceType) = makeGenericSequenceType((yyvsp[(1) - (2)].itemType), (yyvsp[(2) - (2)].cardinality));
7400  }
7401  break;
7402 
7403  case 411:
7404 /* Line 1269 of yacc.c. */
7405 #line 4287 "querytransformparser.ypp"
7406  {
7407  (yyval.sequenceType) = CommonSequenceTypes::Empty;
7408  }
7409  break;
7410 
7411  case 412:
7412 /* Line 1269 of yacc.c. */
7413 #line 4291 "querytransformparser.ypp"
7414  {(yyval.cardinality) = Cardinality::exactlyOne();}
7415  break;
7416 
7417  case 413:
7418 /* Line 1269 of yacc.c. */
7419 #line 4292 "querytransformparser.ypp"
7420  {(yyval.cardinality) = Cardinality::oneOrMore();}
7421  break;
7422 
7423  case 414:
7424 /* Line 1269 of yacc.c. */
7425 #line 4293 "querytransformparser.ypp"
7426  {(yyval.cardinality) = Cardinality::zeroOrMore();}
7427  break;
7428 
7429  case 415:
7430 /* Line 1269 of yacc.c. */
7431 #line 4294 "querytransformparser.ypp"
7432  {(yyval.cardinality) = Cardinality::zeroOrOne();}
7433  break;
7434 
7435  case 419:
7436 /* Line 1269 of yacc.c. */
7437 #line 4300 "querytransformparser.ypp"
7438  {
7439  (yyval.itemType) = BuiltinTypes::item;
7440  }
7441  break;
7442 
7443  case 420:
7444 /* Line 1269 of yacc.c. */
7445 #line 4305 "querytransformparser.ypp"
7446  {
7447  const SchemaType::Ptr t(parseInfo->staticContext->schemaDefinitions()->createSchemaType((yyvsp[(1) - (1)].qName)));
7448 
7449  if(!t)
7450  {
7451  parseInfo->staticContext->error(QtXmlPatterns::tr("The name %1 does not refer to any schema type.")
7452  .arg(formatKeyword(parseInfo->staticContext->namePool(), (yyvsp[(1) - (1)].qName))), ReportContext::XPST0051, fromYYLTYPE((yyloc), parseInfo));
7453  }
7455  (yyval.itemType) = AtomicType::Ptr(t);
7456  else
7457  {
7458  /* Try to give an intelligent message. */
7459  if(t->isComplexType())
7460  {
7461  parseInfo->staticContext->error(QtXmlPatterns::tr("%1 is an complex type. Casting to complex "
7462  "types is not possible. However, casting "
7463  "to atomic types such as %2 works.")
7464  .arg(formatType(parseInfo->staticContext->namePool(), t))
7465  .arg(formatType(parseInfo->staticContext->namePool(), BuiltinTypes::xsInteger)),
7466  ReportContext::XPST0051, fromYYLTYPE((yyloc), parseInfo));
7467  }
7468  else
7469  {
7470  parseInfo->staticContext->error(QtXmlPatterns::tr("%1 is not an atomic type. Casting "
7471  "is only possible to atomic types.")
7472  .arg(formatType(parseInfo->staticContext->namePool(), t)),
7473  ReportContext::XPST0051, fromYYLTYPE((yyloc), parseInfo));
7474  }
7475  }
7476  }
7477  break;
7478 
7479  case 428:
7480 /* Line 1269 of yacc.c. */
7481 #line 4349 "querytransformparser.ypp"
7482  {
7483  (yyval.itemType) = BuiltinTypes::node;
7484  }
7485  break;
7486 
7487  case 429:
7488 /* Line 1269 of yacc.c. */
7489 #line 4354 "querytransformparser.ypp"
7490  {
7491  (yyval.itemType) = BuiltinTypes::document;
7492  }
7493  break;
7494 
7495  case 430:
7496 /* Line 1269 of yacc.c. */
7497 #line 4359 "querytransformparser.ypp"
7498  {
7499  // TODO support for document element testing
7500  (yyval.itemType) = BuiltinTypes::document;
7501  }
7502  break;
7503 
7504  case 433:
7505 /* Line 1269 of yacc.c. */
7506 #line 4368 "querytransformparser.ypp"
7507  {
7508  (yyval.itemType) = BuiltinTypes::text;
7509  }
7510  break;
7511 
7512  case 434:
7513 /* Line 1269 of yacc.c. */
7514 #line 4373 "querytransformparser.ypp"
7515  {
7516  (yyval.itemType) = BuiltinTypes::comment;
7517  }
7518  break;
7519 
7520  case 435:
7521 /* Line 1269 of yacc.c. */
7522 #line 4378 "querytransformparser.ypp"
7523  {
7524  (yyval.itemType) = BuiltinTypes::pi;
7525  }
7526  break;
7527 
7528  case 436:
7529 /* Line 1269 of yacc.c. */
7530 #line 4383 "querytransformparser.ypp"
7531  {
7532  (yyval.itemType) = LocalNameTest::create(BuiltinTypes::pi, parseInfo->staticContext->namePool()->allocateLocalName((yyvsp[(3) - (4)].sval)));
7533  }
7534  break;
7535 
7536  case 437:
7537 /* Line 1269 of yacc.c. */
7538 #line 4388 "querytransformparser.ypp"
7539  {
7540  if(QXmlUtils::isNCName((yyvsp[(3) - (4)].sval)))
7541  {
7542  (yyval.itemType) = LocalNameTest::create(BuiltinTypes::pi, parseInfo->staticContext->namePool()->allocateLocalName((yyvsp[(3) - (4)].sval)));
7543  }
7544  else
7545  {
7546  parseInfo->staticContext->error(QtXmlPatterns::tr("%1 is not a valid name for a "
7547  "processing-instruction.")
7548  .arg(formatKeyword((yyvsp[(3) - (4)].sval))),
7550  fromYYLTYPE((yyloc), parseInfo));
7551  }
7552  }
7553  break;
7554 
7555  case 440:
7556 /* Line 1269 of yacc.c. */
7557 #line 4407 "querytransformparser.ypp"
7558  {
7559  (yyval.itemType) = BuiltinTypes::attribute;
7560  }
7561  break;
7562 
7563  case 441:
7564 /* Line 1269 of yacc.c. */
7565 #line 4412 "querytransformparser.ypp"
7566  {
7567  (yyval.itemType) = BuiltinTypes::attribute;
7568  }
7569  break;
7570 
7571  case 442:
7572 /* Line 1269 of yacc.c. */
7573 #line 4417 "querytransformparser.ypp"
7574  {
7575  (yyval.itemType) = QNameTest::create(BuiltinTypes::attribute, (yyvsp[(3) - (4)].qName));
7576  }
7577  break;
7578 
7579  case 443:
7580 /* Line 1269 of yacc.c. */
7581 #line 4421 "querytransformparser.ypp"
7582  {
7583  const SchemaType::Ptr t(parseInfo->staticContext->schemaDefinitions()->createSchemaType((yyvsp[(5) - (6)].qName)));
7584 
7585  if(t)
7586  (yyval.itemType) = BuiltinTypes::attribute;
7587  else
7588  {
7589  parseInfo->staticContext->error(unknownType().arg(formatKeyword(parseInfo->staticContext->namePool(), (yyvsp[(5) - (6)].qName))),
7590  ReportContext::XPST0008, fromYYLTYPE((yyloc), parseInfo));
7591  }
7592  }
7593  break;
7594 
7595  case 444:
7596 /* Line 1269 of yacc.c. */
7597 #line 4433 "querytransformparser.ypp"
7598  {
7599  const SchemaType::Ptr t(parseInfo->staticContext->schemaDefinitions()->createSchemaType((yyvsp[(5) - (6)].qName)));
7600 
7601  if(t)
7602  (yyval.itemType) = BuiltinTypes::attribute;
7603  else
7604  {
7605  parseInfo->staticContext->error(unknownType().arg(formatKeyword(parseInfo->staticContext->namePool(), (yyvsp[(5) - (6)].qName))),
7606  ReportContext::XPST0008, fromYYLTYPE((yyloc), parseInfo));
7607  }
7608  }
7609  break;
7610 
7611  case 445:
7612 /* Line 1269 of yacc.c. */
7613 #line 4446 "querytransformparser.ypp"
7614  {
7615  parseInfo->staticContext->error(QtXmlPatterns::tr("%1 is not in the in-scope attribute "
7616  "declarations. Note that the schema import "
7617  "feature is not supported.")
7618  .arg(formatKeyword(parseInfo->staticContext->namePool(), (yyvsp[(3) - (4)].qName))),
7619  ReportContext::XPST0008, fromYYLTYPE((yyloc), parseInfo));
7620  (yyval.itemType).reset();
7621  }
7622  break;
7623 
7624  case 446:
7625 /* Line 1269 of yacc.c. */
7626 #line 4456 "querytransformparser.ypp"
7627  {
7628  (yyval.itemType) = BuiltinTypes::element;
7629  }
7630  break;
7631 
7632  case 447:
7633 /* Line 1269 of yacc.c. */
7634 #line 4461 "querytransformparser.ypp"
7635  {
7636  (yyval.itemType) = BuiltinTypes::element;
7637  }
7638  break;
7639 
7640  case 448:
7641 /* Line 1269 of yacc.c. */
7642 #line 4466 "querytransformparser.ypp"
7643  {
7644  (yyval.itemType) = QNameTest::create(BuiltinTypes::element, (yyvsp[(3) - (4)].qName));
7645  }
7646  break;
7647 
7648  case 449:
7649 /* Line 1269 of yacc.c. */
7650 #line 4471 "querytransformparser.ypp"
7651  {
7652  const SchemaType::Ptr t(parseInfo->staticContext->schemaDefinitions()->createSchemaType((yyvsp[(5) - (7)].qName)));
7653 
7654  if(t)
7655  (yyval.itemType) = BuiltinTypes::element;
7656  else
7657  {
7658  parseInfo->staticContext->error(unknownType()
7659  .arg(formatKeyword(parseInfo->staticContext->namePool(), (yyvsp[(5) - (7)].qName))),
7660  ReportContext::XPST0008, fromYYLTYPE((yyloc), parseInfo));
7661  }
7662  }
7663  break;
7664 
7665  case 450:
7666 /* Line 1269 of yacc.c. */
7667 #line 4485 "querytransformparser.ypp"
7668  {
7669  const SchemaType::Ptr t(parseInfo->staticContext->schemaDefinitions()->createSchemaType((yyvsp[(5) - (7)].qName)));
7670 
7671  if(t)
7672  (yyval.itemType) = BuiltinTypes::element;
7673  else
7674  {
7675  parseInfo->staticContext->error(QtXmlPatterns::tr("%1 is an unknown schema type.")
7676  .arg(formatKeyword(parseInfo->staticContext->namePool(), (yyvsp[(5) - (7)].qName))),
7677  ReportContext::XPST0008, fromYYLTYPE((yyloc), parseInfo));
7678  }
7679  }
7680  break;
7681 
7682  case 453:
7683 /* Line 1269 of yacc.c. */
7684 #line 4502 "querytransformparser.ypp"
7685  {
7686  parseInfo->staticContext->error(QtXmlPatterns::tr("%1 is not in the in-scope attribute "
7687  "declarations. Note that the schema import "
7688  "feature is not supported.")
7689  .arg(formatKeyword(parseInfo->staticContext->namePool(), (yyvsp[(3) - (4)].qName))),
7690  ReportContext::XPST0008, fromYYLTYPE((yyloc), parseInfo));
7691  (yyval.itemType).reset();
7692  }
7693  break;
7694 
7695  case 455:
7696 /* Line 1269 of yacc.c. */
7697 #line 4514 "querytransformparser.ypp"
7698  {
7699  (yyval.qName) = parseInfo->staticContext->namePool()->allocateQName(StandardNamespaces::empty, (yyvsp[(1) - (1)].sval));
7700  }
7701  break;
7702 
7703  case 457:
7704 /* Line 1269 of yacc.c. */
7705 #line 4526 "querytransformparser.ypp"
7706  {
7707  if(parseInfo->nodeTestSource == BuiltinTypes::element)
7708  (yyval.qName) = parseInfo->staticContext->namePool()->allocateQName(parseInfo->staticContext->namespaceBindings()->lookupNamespaceURI(StandardPrefixes::empty), (yyvsp[(1) - (1)].sval));
7709  else
7710  (yyval.qName) = parseInfo->staticContext->namePool()->allocateQName(StandardNamespaces::empty, (yyvsp[(1) - (1)].sval));
7711  }
7712  break;
7713 
7714  case 462:
7715 /* Line 1269 of yacc.c. */
7716 #line 4540 "querytransformparser.ypp"
7717  {
7718  (yyval.qName) = parseInfo->staticContext->namePool()->allocateQName(parseInfo->staticContext->defaultFunctionNamespace(), (yyvsp[(1) - (1)].sval));
7719  }
7720  break;
7721 
7722  case 463:
7723 /* Line 1269 of yacc.c. */
7724 #line 4544 "querytransformparser.ypp"
7725  {
7726  (yyval.qName) = parseInfo->staticContext->namePool()->allocateQName(StandardNamespaces::InternalXSLT, (yyvsp[(2) - (2)].sval));
7727  }
7728  break;
7729 
7730  case 466:
7731 /* Line 1269 of yacc.c. */
7732 #line 4552 "querytransformparser.ypp"
7733  {
7734  parseInfo->staticContext->error(QtXmlPatterns::tr("The name of an extension expression must be in "
7735  "a namespace."),
7736  ReportContext::XPST0081, fromYYLTYPE((yyloc), parseInfo));
7737  }
7738  break;
7739 
7740  case 469:
7741 /* Line 1269 of yacc.c. */
7742 #line 4562 "querytransformparser.ypp"
7743  {
7744  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
7745  }
7746  break;
7747 
7748  case 470:
7749 /* Line 1269 of yacc.c. */
7750 #line 4566 "querytransformparser.ypp"
7751  {
7752  allowedIn(QueryLanguages(QXmlQuery::XQuery10 | QXmlQuery::XPath20), parseInfo, (yyloc));
7753  }
7754  break;
7755 
7756  case 471:
7757 /* Line 1269 of yacc.c. */
7758 #line 4571 "querytransformparser.ypp"
7759  {
7760 
7761  const ReflectYYLTYPE ryy((yyloc), parseInfo);
7762 
7763  (yyval.qName) = QNameConstructor::
7764  expandQName<StaticContext::Ptr,
7766  ReportContext::XPST0081>((yyvsp[(1) - (1)].sval), parseInfo->staticContext,
7767  parseInfo->staticContext->namespaceBindings(), &ryy);
7768 
7769  }
7770  break;
7771 
7772  case 472:
7773 /* Line 1269 of yacc.c. */
7774 #line 4583 "querytransformparser.ypp"
7775  {
7776  (yyval.qName) = parseInfo->staticContext->namePool()->fromClarkName((yyvsp[(1) - (1)].sval));
7777  }
7778  break;
7779 
7780 
7781 /* Line 1269 of yacc.c. */
7782 #line 7763 "qquerytransformparser.cpp"
7783  default: break;
7784  }
7785  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
7786 
7787  YYPOPSTACK (yylen);
7788  yylen = 0;
7789  YY_STACK_PRINT (yyss, yyssp);
7790 
7791  *++yyvsp = yyval;
7792  *++yylsp = yyloc;
7793 
7794  /* Now `shift' the result of the reduction. Determine what state
7795  that goes to, based on the state we popped back to and the rule
7796  number reduced by. */
7797 
7798  yyn = yyr1[yyn];
7799 
7800  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
7801  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
7802  yystate = yytable[yystate];
7803  else
7804  yystate = yydefgoto[yyn - YYNTOKENS];
7805 
7806  goto yynewstate;
7807 
7808 
7809 /*------------------------------------.
7810 | yyerrlab -- here on detecting error |
7811 `------------------------------------*/
7812 yyerrlab:
7813  /* If not already recovering from an error, report this error. */
7814  if (!yyerrstatus)
7815  {
7816  ++yynerrs;
7817 #if ! YYERROR_VERBOSE
7818  yyerror (&yylloc, parseInfo, YY_("syntax error"));
7819 #else
7820  {
7821  YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
7822  if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
7823  {
7824  YYSIZE_T yyalloc = 2 * yysize;
7825  if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
7826  yyalloc = YYSTACK_ALLOC_MAXIMUM;
7827  if (yymsg != yymsgbuf)
7828  YYSTACK_FREE (yymsg);
7829  yymsg = (char *) YYSTACK_ALLOC (yyalloc);
7830  if (yymsg)
7831  yymsg_alloc = yyalloc;
7832  else
7833  {
7834  yymsg = yymsgbuf;
7835  yymsg_alloc = sizeof yymsgbuf;
7836  }
7837  }
7838 
7839  if (0 < yysize && yysize <= yymsg_alloc)
7840  {
7841  (void) yysyntax_error (yymsg, yystate, yychar);
7842  yyerror (&yylloc, parseInfo, yymsg);
7843  }
7844  else
7845  {
7846  yyerror (&yylloc, parseInfo, YY_("syntax error"));
7847  if (yysize != 0)
7848  goto yyexhaustedlab;
7849  }
7850  }
7851 #endif
7852  }
7853 
7854  yyerror_range[0] = yylloc;
7855 
7856  if (yyerrstatus == 3)
7857  {
7858  /* If just tried and failed to reuse lookahead token after an
7859  error, discard it. */
7860 
7861  if (yychar <= YYEOF)
7862  {
7863  /* Return failure if at end of input. */
7864  if (yychar == YYEOF)
7865  YYABORT;
7866  }
7867  else
7868  {
7869  yydestruct ("Error: discarding",
7870  yytoken, &yylval, &yylloc, parseInfo);
7871  yychar = YYEMPTY;
7872  }
7873  }
7874 
7875  /* Else will try to reuse lookahead token after shifting the error
7876  token. */
7877  goto yyerrlab1;
7878 
7879 
7880 /*---------------------------------------------------.
7881 | yyerrorlab -- error raised explicitly by YYERROR. |
7882 `---------------------------------------------------*/
7883 yyerrorlab:
7884 
7885  /* Pacify compilers like GCC when the user code never invokes
7886  YYERROR and the label yyerrorlab therefore never appears in user
7887  code. */
7888  if (/*CONSTCOND*/ 0)
7889  goto yyerrorlab;
7890 
7891  yyerror_range[0] = yylsp[1-yylen];
7892  /* Do not reclaim the symbols of the rule which action triggered
7893  this YYERROR. */
7894  YYPOPSTACK (yylen);
7895  yylen = 0;
7896  YY_STACK_PRINT (yyss, yyssp);
7897  yystate = *yyssp;
7898  goto yyerrlab1;
7899 
7900 
7901 /*-------------------------------------------------------------.
7902 | yyerrlab1 -- common code for both syntax error and YYERROR. |
7903 `-------------------------------------------------------------*/
7904 yyerrlab1:
7905  yyerrstatus = 3; /* Each real token shifted decrements this. */
7906 
7907  for (;;)
7908  {
7909  yyn = yypact[yystate];
7910  if (yyn != YYPACT_NINF)
7911  {
7912  yyn += YYTERROR;
7913  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
7914  {
7915  yyn = yytable[yyn];
7916  if (0 < yyn)
7917  break;
7918  }
7919  }
7920 
7921  /* Pop the current state because it cannot handle the error token. */
7922  if (yyssp == yyss)
7923  YYABORT;
7924 
7925  yyerror_range[0] = *yylsp;
7926  yydestruct ("Error: popping",
7927  yystos[yystate], yyvsp, yylsp, parseInfo);
7928  YYPOPSTACK (1);
7929  yystate = *yyssp;
7930  YY_STACK_PRINT (yyss, yyssp);
7931  }
7932 
7933  *++yyvsp = yylval;
7934 
7935  yyerror_range[1] = yylloc;
7936  /* Using YYLLOC is tempting, but would change the location of
7937  the lookahead. YYLOC is available though. */
7938  YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
7939  *++yylsp = yyloc;
7940 
7941  /* Shift the error token. */
7942  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
7943 
7944  yystate = yyn;
7945  goto yynewstate;
7946 
7947 
7948 /*-------------------------------------.
7949 | yyacceptlab -- YYACCEPT comes here. |
7950 `-------------------------------------*/
7951 yyacceptlab:
7952  yyresult = 0;
7953  goto yyreturn;
7954 
7955 /*-----------------------------------.
7956 | yyabortlab -- YYABORT comes here. |
7957 `-----------------------------------*/
7958 yyabortlab:
7959  yyresult = 1;
7960  goto yyreturn;
7961 
7962 #ifndef yyoverflow
7963 /*-------------------------------------------------.
7964 | yyexhaustedlab -- memory exhaustion comes here. |
7965 `-------------------------------------------------*/
7966 yyexhaustedlab:
7967  yyerror (&yylloc, parseInfo, YY_("memory exhausted"));
7968  yyresult = 2;
7969  /* Fall through. */
7970 #endif
7971 
7972 yyreturn:
7973  if (yychar != YYEMPTY)
7974  yydestruct ("Cleanup: discarding lookahead",
7975  yytoken, &yylval, &yylloc, parseInfo);
7976  /* Do not reclaim the symbols of the rule which action triggered
7977  this YYABORT or YYACCEPT. */
7978  YYPOPSTACK (yylen);
7979  YY_STACK_PRINT (yyss, yyssp);
7980  while (yyssp != yyss)
7981  {
7982  yydestruct ("Cleanup: popping",
7983  yystos[*yyssp], yyvsp, yylsp, parseInfo);
7984  YYPOPSTACK (1);
7985  }
7986 #ifndef yyoverflow
7987  if (yyss != yyssa)
7988  YYSTACK_FREE (yyss);
7989 #endif
7990 #if YYERROR_VERBOSE
7991  if (yymsg != yymsgbuf)
7992  YYSTACK_FREE (yymsg);
7993 #endif
7994  /* Make sure YYID is used. */
7995  return YYID (yyresult);
7996 }
7997 
7998 
7999 /* Line 1486 of yacc.c. */
8000 #line 4587 "querytransformparser.ypp"
8001 
8002 
8004 {
8005  switch(token.type)
8006  {
8007  case NCNAME:
8008  /* Fallthrough. */
8009  case QNAME:
8010  /* Fallthrough. */
8011  case NUMBER:
8012  /* Fallthrough. */
8013  case XPATH2_NUMBER:
8014  return token.value;
8015  case STRING_LITERAL:
8016  return QLatin1Char('"') + token.value + QLatin1Char('"');
8017  default:
8018  {
8019  const QString raw(QString::fromLatin1(yytname[YYTRANSLATE(token.type)]));
8020 
8021  /* Remove the quotes. */
8022  if(raw.at(0) == QLatin1Char('"') && raw.length() > 1)
8023  return raw.mid(1, raw.length() - 2);
8024  else
8025  return raw;
8026  }
8027  }
8028 }
8029 
8030 } /* namespace Patternist */
8031 
8033 
8034 // vim: et:ts=4:sw=4:sts=4:syntax=yacc
8035 
qint32 VariableSlotID
#define YYLAST
Constructs a text node. This covers both computed and directly constructed text nodes.
VariableSlotID allocateGlobalVariableSlot()
void setAxis(const QXmlNodeModelIndex::Axis newAxis)
Definition: qaxisstep_p.h:157
Implements XPath 2.0&#39;s quantification expressions some and every.
unsigned char yytype_uint8
static Expression::Ptr createDirAttributeValue(const Expression::List &content, const ParserContext *const parseInfo, const YYLTYPE &sourceLocator)
#define YYMAXDEPTH
QExplicitlySharedDataPointer< VariableDeclaration > Ptr
static Cardinality zeroOrMore()
#define YYINITDEPTH
static const yytype_int16 yycheck[]
int type
Definition: qmetatype.cpp:239
static Expression::Ptr createConcatFN(const ParserContext *const parseInfo, const Expression::List &args, const YYLTYPE &sourceLocator)
Creates a call to fn:concat() with args as the arguments.
VariableSlotID allocateCacheSlot()
unsigned char c[8]
Definition: qnumeric_p.h:62
ItemType::Ptr nodeTest() const
Definition: qaxisstep_p.h:112
QString Q_AUTOTEST_EXPORT escape(const QString &input)
Similar to Qt::escape(), but also escapes apostrophes and quotes, such that the result is suitable as...
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
virtual QString description() const
NamespaceCode LocalNameCode
Definition: qxmlname.h:84
#define YYTERROR
Base class for all AST nodes in an XPath/XQuery/XSL-T expression.
Constructs an element node. This covers both computed and directly constructed element nodes...
#define yylloc
Represents a declared variable. Only used at the compilation stage.
static Expression::Ptr typeCheckTemplateBody(const Expression::Ptr &body, const SequenceType::Ptr &reqType, const ParserContext *const parseInfo)
static AtomicValue::Ptr fromLexical(const QString &strNumeric)
Definition: qdecimal.cpp:64
A compile time only AST node that changes the static base URI, used when xml:base attributes appears...
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
QString toString(FormattingOptions options=None) const
Returns the human-displayable string representation of the URL.
Definition: qurl.cpp:5896
QString formatKeyword(const QString &keyword)
static const SequenceType::Ptr ZeroOrMoreItems
static YYSIZE_T yystrlen(const char *yystr)
#define it(className, varName)
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
QHash< QXmlName, Template::Ptr > namedTemplates
#define yyerror
Together with OrderBy, it implements XQuery 1.0&#39;s order by expression.
Creates a DynamicContext which provides the focus item for the function fn:current().
Implements XPath 2.0&#39;s castable as expression.
Definition: qcastableas_p.h:73
qint16 NamespaceCode
Definition: qxmlname.h:82
QString formatType(const NamePool::Ptr &np, const T &type)
Formats ItemType and SequenceType.
#define at(className, varName)
static Expression::Ptr findAxisStep(const Expression::Ptr &expr, const bool throughStructures=true)
A special value that when passed as the namespace part to NamespaceResolver::addBinding(), undeclares the prefix.
Definition: qnamepool_p.h:293
Implements XSL-T&#39;s construction of simple content, which is different from XQuery&#39;s approach...
static Expression::Ptr create(Expression *const expr, const YYLTYPE &sourceLocator, const ParserContext *const parseInfo)
static const yytype_uint16 yydefact[]
Q_CORE_EXPORT QTextStream & reset(QTextStream &s)
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
Implements the path expression, containing two steps, such as in html/body.
Definition: qpath_p.h:72
#define YY_LOCATION_PRINT(File, Loc)
QVector< AttributeHolder > AttributeHolderVector
Definition: qtokenizer_p.h:75
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the vector...
Definition: qvector.h:252
A step in a path expression that with an axis and a node test evaluates to a sequence of nodes from t...
Definition: qaxisstep_p.h:71
Constructs an element node. This covers both computed and directly constructed element nodes...
The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object...
Definition: qshareddata.h:136
#define YYSTACK_FREE
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
Implements XPath 2.0&#39;s cast as expression.
Definition: qcastas_p.h:79
#define YYID(n)
Constructs a namespace on an element, and naturally only appears as a child of ElementConstructor.
const ParserContext *const m_parseInfo
Implements XPath 2.0&#39;s for expression.
Definition: qforclause_p.h:72
QMultiHash< QXmlName, Expression::Ptr > unresolvedVariableReferences
static QXmlName::NamespaceCode namespaceForPrefix(const QXmlName::PrefixCode prefix, const StaticContext::Ptr &context, const SourceLocationReflection *const r)
static void loadPattern(const Expression::Ptr &matchPattern, TemplatePattern::Vector &ourPatterns, const TemplatePattern::ID id, const PatternPriority priority, const Template::Ptr &temp)
Item toItem(const QExplicitlySharedDataPointer< T > atomicValue)
Definition: qitem_p.h:431
static void changeToTopAxis(const Expression::Ptr &op)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int yyparse(ParserContext *const parseInfo)
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QExplicitlySharedDataPointer< AtomicType > Ptr
Definition: qatomictype_p.h:85
Contains macros for debugging.
static QXmlName expandQName(const QString &lexicalQName, const TReportContext &context, const NamespaceResolver::Ptr &nsResolver, const SourceLocationReflection *const r, const bool asForAttribute=false)
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
static bool isReservedNamespace(const QXmlName::NamespaceCode ns)
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
#define YYEMPTY
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static Expression::Ptr createSimpleContent(const Expression::Ptr &source, const YYLTYPE &sourceLocator, const ParserContext *const parseInfo)
Ensures the lexical space of the string value of the Item returned from its child Expression is an NC...
Constructs a namespace on an element, and naturally only appears as a child of ElementConstructor.
static bool isVariableReference(const Expression::ID id)
bool isRelative() const
Returns true if the URL is relative; otherwise returns false.
Definition: qurl.cpp:5880
Implements the node comparison operators >>, <<, and is.
Constructs an element node. This covers both computed and directly constructed element nodes...
static ReturnOrderBy * locateReturnClause(const Expression::Ptr &expr)
When set, the function conversion rules are applied.
static Expression::Ptr createPatternPath(const Expression::Ptr &operand1, const Expression::Ptr &operand2, const QXmlNodeModelIndex::Axis axis, const YYLTYPE &sl, const ParserContext *const parseInfo)
Writes operand1 and operand2, two operands in an XSL-T pattern, into an equivalent XPath expression...
static AtomicString::Ptr fromValue(const QString &value)
QString prefix(const QXmlNamePool &query) const
Returns the prefix.
Definition: qxmlname.cpp:370
static const yytype_int16 yypgoto[]
#define YYSTACK_ALLOC_MAXIMUM
Does node copying in a parameterized way, in order to deal with namespace preservation/inheritance.
Definition: qcopyof_p.h:75
Constructs simple content as specified for attributes in direct element constructors in XQuery...
static SequenceType::Ptr quantificationType(const SequenceType::Ptr &type)
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
static ItemType::Ptr create(const ItemType::Ptr &primaryType, const QXmlName::NamespaceCode namespaceURI)
#define YYABORT
static void checkVariableCircularity(const VariableDeclaration::Ptr &var, const Expression::Ptr &checkee, const VariableDeclaration::Type type, FunctionSignature::List &signList, const ParserContext *const parseInfo)
Checks for variable initialization circularity.
static int sign(int x)
Implements XPath 2.0&#39;s to expression.
static QString tokenToString(const Token &token)
Performs the sorting by being a parent to ForClause.
Definition: qorderby_p.h:76
static const SequenceType::Ptr ExactlyOneInteger
#define YY_REDUCE_PRINT(Rule)
Contains a set of bindings, plus a pointer to another resolver which is delegates requests to...
static const yytype_int16 yydefgoto[]
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the vector.
Definition: qvector.h:249
friend class const_iterator
Definition: qlist.h:264
Implements XPath 2.0&#39;s conditional expression if([expr]) then [expr] else [expr]. ...
Implements XPath 2.0&#39;s general comparions, such as the = operator.
virtual ID id() const
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
T * data() const
Returns a pointer to the shared data object.
Definition: qshareddata.h:145
Implements XPath 2.0 unary expression, (-|+)ValueExpr.
static const yytype_uint8 yyr2[]
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
const TCastTarget * as() const
void error(const QString &message, const ReportContext::ErrorCode errorCode, const QSourceLocation &sourceLocation)
static QString formatFunction(const NamePool::Ptr &np, const FunctionSignature::Ptr &func)
Formats FunctionSignature.
static void registerNamedTemplate(const QXmlName &name, const Expression::Ptr &body, ParserContext *const parseInfo, const YYLTYPE &sourceLocator, const Template::Ptr &temp)
static bool isEmpty(const char *str)
Implements XPath 2.0&#39;s operators for combining node sequences: union, intersect and except...
QExplicitlySharedDataPointer< Template > Ptr
Definition: qtemplate_p.h:89
VariableDeclaration::Stack variables
static QNameValue::Ptr fromValue(const NamePool::Ptr &np, const QXmlName name)
Definition: qqnamevalue.cpp:59
static const yytype_int16 yypact[]
static QString unknownType()
Centralizes a translation string for the purpose of increasing consistency.
static Cardinality oneOrMore()
Creates an xs:QName value from a lexical QName using statically known namespace bindings.
bool contains(const T &value) const
Definition: qset.h:91
static const ItemType::Ptr xsltNodeTest
static QString axisName(const QXmlNodeModelIndex::Axis axis)
Prints the EBNF name corresponding to axis.
Definition: qaxisstep.cpp:209
static const ItemType::Ptr item
Implements arithmetics, such as multiplication and subtraction.
const char * name
static const SequenceType::Ptr ExactlyOneDocumentNode
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
const QLatin1String XML("http://www.w3.org/XML/1998/namespace")
static const yytype_int16 yytable[]
static char * yystpcpy(char *yydest, const char *yysrc)
Represents the signature of an XPath function.
The namespace for the internal API of QtXmlPatterns.
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
Implements the context item, the dot: ..
void setNodeTest(const ItemType::Ptr &nev)
Definition: qaxisstep_p.h:117
const_iterator insert(const T &value)
Definition: qset.h:179
static Expression::Ptr createReturnOrderBy(const OrderSpecTransfer::List &orderSpecTransfer, const Expression::Ptr &returnExpr, const OrderBy::Stability stability, const YYLTYPE &sourceLocator, const ParserContext *const parseInfo)
#define YYEOF
static const yytype_uint16 yyr1[]
The QSourceLocation class identifies a location in a resource by URI, line, and column.
static Expression::Ptr createCopyOf(const Expression::Ptr &operand, const ParserContext *const parseInfo, const YYLTYPE &sl)
struct YYLTYPE YYLTYPE
static void checkCallsiteCircularity(CallTargetDescription::List &signList, const Expression::Ptr expr)
#define yydebug
Implements the value instance of empty sequence: ().
virtual Expression::List operands() const =0
static bool contains(const VariableDeclaration::List &list, const QXmlName &lookup)
Returns true if list contains lookup.
#define YYDPRINTF(Args)
Carries meta data for a function argument as found in XPath&#39;s builtin functions and user declared fun...
static const yytype_uint8 yytranslate[]
virtual Token nextToken(YYLTYPE *const sourceLocator)=0
static QString formatData(const QString &data)
Contains data used when parsing and tokenizing.
virtual QSourceLocation sourceLocation() const
QXmlNodeModelIndex::Axis axis() const
Definition: qaxisstep.cpp:204
static Expression::Ptr createIdPatternPath(const Expression::Ptr &operand1, const Expression::Ptr &operand2, const QXmlNodeModelIndex::Axis axis, const YYLTYPE &sl, const ParserContext *const parseInfo)
Performs the same role as createPatternPath(), but is tailored for fn:key() and fn:id().
void push(const T &t)
Adds element t to the top of the stack.
Definition: qstack.h:60
static void allowedIn(const QueryLanguages allowedLanguages, const ParserContext *const parseInfo, const YYLTYPE &sourceLocator, const bool isInternal=false)
Flags invalid expressions and declarations in the currently parsed language.
A reference to an argument declared in a UserFunction.
static const AnyNodeType::Ptr node
static Expression::Ptr create(const Expression::Ptr &sourceExpression, const Expression::Ptr &predicateExpression, const StaticContext::Ptr &context, const QSourceLocation &location)
A function created with XQuery&#39;s declare function declaration.
Q_CORE_EXPORT bool qIsNaN(double d)
Returns true if the double {d} is not a number (NaN).
Definition: qnumeric.cpp:55
unsigned short int yytype_uint16
#define YYSTYPE
Definition: qtokenizer_p.h:137
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
const QXmlQuery::QueryLanguage languageAccent
static const ItemType::Ptr document
#define YYACCEPT
A compile time only AST node that changes the backwareds compatibility mode. Used for XSL-T 2...
#define YYSIZE_MAXIMUM
Houses an AtomicValue, making it available as an Expression.
Definition: qliteral_p.h:74
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
QExplicitlySharedDataPointer< Expression > Ptr
A smart pointer wrapping mutable Expression instances.
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
static const char *const yytname[]
QString pattern() const
Returns the pattern string of the regular expression.
Definition: qregexp.cpp:3960
static const EmptySequenceType::Ptr Empty
static Expression::Ptr createRootExpression(const ParserContext *const parseInfo, const YYLTYPE &sl)
Creates an Expression that corresponds to /. This is literally fn:root(self::node()) treat as documen...
static void variableUnavailable(const QXmlName &variableName, const ParserContext *const parseInfo, const YYLTYPE &location)
static Cardinality zeroOrOne()
The QXmlName class represents the name of an XML node, in an efficient, namespace-aware way...
Definition: qxmlname.h:58
static ItemType::Ptr create(const ItemType::Ptr &primaryType, const QXmlName qName)
Definition: qqnametest.cpp:61
A reference to a variable declared with declare variable or let.
Represents a let-clause, but is only used at compile time.
Definition: qletclause_p.h:78
#define YYTABLE_NINF
#define yynerrs
Contains functions used for formatting arguments, such as keywords and paths, in translated strings...
Constructs a text node. This covers both computed and directly constructed text nodes.
static int XPathlex(YYSTYPE *lexVal, YYLTYPE *sourceLocator, const ParserContext *const parseInfo)
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182
static const AtomicType::Ptr xsQName
static const yytype_uint16 yystos[]
Contains data related to a template.
Definition: qtemplate_p.h:84
Base class for all numeric values.
A reference to a variable declared with for or a quantification expression, but not for instance a le...
static bool wxsTypeMatches(const SchemaType::Ptr &type, const SchemaType::Ptr &otherType, QSet< SchemaType::Ptr > &visitedTypes, SchemaType::Ptr &conflictingType)
Evaluates to the same result as its operand, but ensures the operand is evaluated once even if this E...
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)
static const ItemType::Ptr attribute
static bool isValid(const QString &candidate)
Return true if candidate is a valid xs:anyURI, otherwise false.
Definition: qanyuri.cpp:93
#define yylval
static Expression::Ptr applyFunctionConversion(const Expression::Ptr &operand, const SequenceType::Ptr &reqType, const StaticContext::Ptr &context, const ReportContext::ErrorCode code=ReportContext::XPTY0004, const Options=Options(AutomaticallyConvert|CheckFocus))
Builds a pipeline of artificial AST nodes that ensures operand conforms to the type reqType by applyi...
static Expression::Ptr createSlashSlashPath(const Expression::Ptr &begin, const Expression::Ptr &end, const YYLTYPE &sourceLocator, const ParserContext *const parseInfo)
Creates a path expression which contains the step // between begin and and end.
static void validateTargetName(const QString &lexicalNCName, const TReportContext &context, const SourceLocationReflection *const r)
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
Compile time only AST-node which is a marker for variable references whose declaration has not yet ap...
Constructs a comment node. This covers both computed and directly constructed text nodes...
#define YYLEX
Q_OUTOFLINE_TEMPLATE QPair< T1, T2 > qMakePair(const T1 &x, const T2 &y)
Definition: qpair.h:102
static QTestResult::TestLocation location
Definition: qtestresult.cpp:63
int key
Contains class Numeric. This file was originally called qnumeric_p.h, but various build systems canno...
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
static void splitQName(const QString &qName, QString &prefix, QString &localName)
Splits qName into localName and prefix.
OrderBy::OrderSpec::Vector orderSpecs() const
const StaticContext::Ptr staticContext
#define YYFINAL
#define YY_STACK_PRINT(Bottom, Top)
static QString formatExpression(const QString &expr)
static const AtomicType::Ptr xsInteger
static Cardinality exactlyOne()
QFactoryLoader * l
A reference to an at variable, declared with the for-part in XQuery&#39;s FLWOR expression.
#define YYPOPSTACK(N)
static QList< QByteArray > enums
Definition: qaxserver.cpp:443
static YYSIZE_T yysyntax_error(char *yyresult, int yystate, int yychar)
static QSourceLocation fromYYLTYPE(const YYLTYPE &sourceLocator, const ParserContext *const parseInfo)
bool exactMatch(const QString &str) const
Returns true if str is matched exactly by this regular expression; otherwise returns false...
Definition: qregexp.cpp:4094
When combined with other components, implements xsl:apply-templates.
Axis
Identify the axes emanating from a node.
static const AtomicType::Ptr xsDecimal
VariableSlotID allocatePositionalSlot()
Implements the comma(",") operator, the sequence constructor.
const VariableDeclaration * variableDeclaration() const
A reference to an external variable.
static QString prologMessage(const char *const msg)
Centralizes a translation message, for the purpose of consistency and modularization.
A reference to a template parameter declared with xsl:param.
const T * const_iterator
The QVector::const_iterator typedef provides an STL-style const iterator for QVector and QStack...
Definition: qvector.h:245
static bool isPredicate(const Expression::ID id)
static qreal toDouble(const QChar *&str)
static const ItemType::Ptr text
ReflectYYLTYPE(const YYLTYPE &sourceLocator, const ParserContext *const pi)
static const AtomicType::Ptr xsAnyAtomicType
static QUrl resolveAndCheckCollation(const QString &collation, const ParserContext *const parseInfo, const YYLTYPE &sl)
Resolves against the static base URI and checks that collation is a supported Unicode Collation...
#define YYNTOKENS
static ItemType::Ptr create(const ItemType::Ptr &primaryType, const QXmlName::LocalNameCode localName)
Carries meta data for xsl:with-param as encountered in template callsites such as xsl:call-template a...
Definition: qwithparam_p.h:75
Implements XPath 2.0&#39;s logical expression or.
#define YYPACT_NINF
The QFlags class provides a type-safe way of storing OR-combinations of enum values.
Definition: qglobal.h:2313
Implements XPath 2.0 value comparions, such as the eq operator.
QFlags< QXmlQuery::QueryLanguage > QueryLanguages
OrderBy::Stability stability() const
static QString formatURI(const NamePool::Ptr &np, const QXmlName::NamespaceCode &uri)
Formats uri, that&#39;s considered to be a URI, for display.
Definition: qanyuri_p.h:202
static const ItemType::Ptr pi
QExplicitlySharedDataPointer< StaticContext > Ptr
#define yychar
#define YYSIZE_T
virtual const SourceLocationReflection * actualReflection() const
#define YYUSE(e)
QUrl resolved(const QUrl &relative) const
Returns the result of the merge of this URL with relative.
Definition: qurl.cpp:5819
#define YY_(msgid)
static const KeyPair *const end
Ensures the lexical space of the string value of the Item returned from its child Expression is an NC...
xsDouble PatternPriority
#define YYTRANSLATE(YYX)
static bool isWhitespaceOnly(const QStringRef &string)
Determines whether consists only of whitespace. Characters considered whitespace are the ones for whi...
const QUrl & queryURI() const
Definition: qtokenizer_p.h:187
bool is(const ID id) const
static int XPatherror(YYLTYPE *sourceLocator, const ParserContext *const parseInfo, const char *const msg)
The generated Bison parser calls this function when there is a parse error.
static YYSIZE_T yytnamerr(char *yyres, const char *yystr)
VariableSlotID allocateExpressionSlot()
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
static const ItemType::Ptr element
static Expression::Ptr wrapAround(const Expression::Ptr &operand, const StaticContext::Ptr &context)
Definition: qnodesort.cpp:92
static bool isNCName(const QStringRef &ncName)
Determines whether c is a valid instance of production [4]NCName in the XML 1.0 Namespaces specificat...
Definition: qxmlutils.cpp:377
Expression::Ptr createNumericLiteral(const QString &in, const YYLTYPE &sl, const ParserContext *const parseInfo)
Centralizes code for creating numeric literals.
static VariableDeclaration::Ptr variableByName(const QXmlName name, const ParserContext *const parseInfo)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
static Expression::Ptr createFirstItem(const Expression::Ptr &sourceExpression)
Performs a call to a UserFunction.
#define YYSTACK_ALLOC
Contains functions and classes used by the parser and tokenizer.
static Expression::Ptr resolveVariable(const QXmlName &name, const YYLTYPE &sourceLocator, ParserContext *const parseInfo, const bool raiseErrorOnUnavailability)
static const ItemType::Ptr comment
int ImportPrecedence
bool isNull() const
Returns true if this QXmlName is not initialized with a valid combination of {namespace URI}...
Definition: qxmlname.cpp:224
static void registerLastPath(const Expression::Ptr &operand)
static void yydestruct(const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, ParserContext *const parseInfo)
static bool isNull(const QVariant::Private *d)
Definition: qvariant.cpp:300
Implements XPath 2.0&#39;s logical expression and.
Implements XPath 2.0&#39;s treat as expression.
Definition: qtreatas_p.h:82
#define YYLLOC_DEFAULT(Current, Rhs, N)
Base class for all instances that represents something at a certain location.
Implements xsl:call-template.
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272
Whether the focus should be checked or not.
static Expression::Ptr createCompatStore(const Expression::Ptr &expr, const YYLTYPE &sourceLocator, const ParserContext *const parseInfo)
Houses the data necessary for a template pattern.
#define YY_SYMBOL_PRINT(Title, Type, Value, Location)
void reserve(int size)
Definition: qset.h:241
NamespaceCode PrefixCode
Definition: qxmlname.h:83