1 /* 2 * Copyright 2006-2012 The FLWOR Foundation. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #pragma once 17 #ifndef ZORBA_PARSENODES_H 18 #define ZORBA_PARSENODES_H 19 20 #include <cassert> 21 #include <iostream> 22 #include <sstream> 23 #include <stdexcept> 24 #include <string> 25 #include <typeinfo> 26 #include <vector> 27 28 #include <zorba/store_consts.h> 29 30 #include "compiler/parser/ft_types.h" 31 #include "compiler/parsetree/parsenode_base.h" 32 33 #include "store/api/item.h" 34 35 #include "zorbatypes/rchandle.h" 36 #include "zorbatypes/schema_types.h" 37 #include "zorbatypes/zstring.h" 38 39 #include "context/static_context_consts.h" 40 #include "context/dynamic_context.h" 41 42 #include "util/string_util.h" 43 44 namespace zorba { 45 46 class AbbrevForwardStep; 47 class AdditiveExpr; 48 class AndExpr; 49 class AnnotationParsenode; 50 class AnnotationListParsenode; 51 class AnnotationLiteralListParsenode; 52 class AnyKindTest; 53 class AposAttrContentList; 54 class AposAttrValueContent; 55 class ArgList; 56 class AtomicType; 57 class AttributeTest; 58 class AxisStep; 59 class BaseURIDecl; 60 class BoundarySpaceDecl; 61 class CaseClause; 62 class CaseClauseList; 63 class CastableExpr; 64 class CastExpr; 65 class CatchExpr; 66 class CatchListExpr; 67 class CDataSection; 68 class CollectionModifier; 69 class CommentTest; 70 class CommonContent; 71 class ComparisonExpr; 72 class CompAttrConstructor; 73 class CompCommentConstructor; 74 class CompDocConstructor; 75 class CompElemConstructor; 76 class CompPIConstructor; 77 class CompTextConstructor; 78 class ConstructionDecl; 79 class ContextItemExpr; 80 class CopyNamespacesDecl; 81 class DefaultCollationDecl; 82 class DefaultNamespaceDecl; 83 class DeleteExpr; 84 class DirAttr; 85 class DirAttributeList; 86 class DirAttributeValue; 87 class DirCommentConstructor; 88 class DirElemConstructor; 89 class DirElemContent; 90 class DirElemContentList; 91 class DirPIConstructor; 92 class DocumentTest; 93 class ElementTest; 94 class EnclosedExpr; 95 class Expr; 96 class ExtensionExpr; 97 class FilterExpr; 98 class ForwardAxis; 99 class ForwardStep; 100 class FTAnd; 101 class FTAnyallOption; 102 class FTBigUnit; 103 class FTCaseOption; 104 class FTContainsExpr; 105 class FTContent; 106 class FTDiacriticsOption; 107 class FTDistance; 108 class FTExtensionOption; 109 class FTExtensionSelection; 110 class FTIgnoreOption; 111 class FTLanguageOption; 112 class FTMatchOption; 113 class FTMatchOptions; 114 class FTMildNot; 115 class FTOptionDecl; 116 class FTOr; 117 class FTOrder; 118 class FTPosFilter; 119 class FTPrimary; 120 class FTPrimaryWithOptions; 121 class FTRange; 122 class FTScope; 123 class FTScoreVar; 124 class FTSelection; 125 class FTStemOption; 126 class FTStopWordOption; 127 class FTStopWords; 128 class FTStopWordsInclExcl; 129 class FTThesaurusID; 130 class FTThesaurusOption; 131 class FTTimes; 132 class FTUnaryNot; 133 class FTUnit; 134 class FTWeight; 135 class FTWildCardOption; 136 class FTWindow; 137 class FTWords; 138 class FTWordsTimes; 139 class FTWordsValue; 140 class FunctionCall; 141 class FunctionDecl; 142 class GeneralComp; 143 class IfExpr; 144 class IndexKeyList; 145 class IndexKeySpec; 146 class IndexProperty; 147 class IndexPropertyList; 148 class InsertExpr; 149 class InstanceofExpr; 150 class IntegrityConstraintDecl; 151 class IntersectExceptExpr; 152 class ItemType; 153 class ModuleDecl; 154 class MultiplicativeExpr; 155 class NamespaceDecl; 156 class NameTest; 157 class NodeComp; 158 class NodeModifier; 159 class NumericLiteral; 160 class OccurrenceIndicator; 161 class OptionDecl; 162 class OrderingModeDecl; 163 class OrExpr; 164 165 class FLWORExpr; 166 class FLWORClauseList; 167 class FLWORClause; 168 class ForOrLetClause; 169 class ForClause; 170 class VarInDeclList; 171 class VarInDecl; 172 class PositionalVar; 173 class LetClause; 174 class VarGetsDeclList; 175 class VarGetsDecl; 176 class WhereClause; 177 class GroupByClause; 178 class GroupSpecList; 179 class GroupSpec; 180 class GroupCollationSpec; 181 class OrderByClause; 182 class OrderSpecList; 183 class OrderSpec; 184 class OrderModifierPN; 185 class OrderCollationSpec; 186 class OrderDirSpec; 187 class OrderEmptySpec; 188 class EmptyOrderDecl; 189 class WindowClause; 190 class WindowVarDecl; 191 class FLWORWinCond; 192 class WindowVars; 193 class CountClause; 194 195 class PITest; 196 class Param; 197 class ParamList; 198 class ParenthesizedExpr; 199 class PathExpr; 200 class PositionalVar; 201 class Pragma; 202 class PragmaList; 203 class PredicateList; 204 class Prolog; 205 class QName; 206 class QuantifiedExpr; 207 class QueryBody; 208 class QuoteAttrContentList; 209 class QuoteAttrValueContent; 210 class QVarInDecl; 211 class QVarInDeclList; 212 class RangeExpr; 213 class RelativePathExpr; 214 class SimpleMapExpr; 215 class RenameExpr; 216 class ReplaceExpr; 217 class RevalidationDecl; 218 class ReverseAxis; 219 class ReverseStep; 220 class SIND_DeclList; 221 class SchemaAttributeTest; 222 class SchemaElementTest; 223 class SchemaImport; 224 class SchemaPrefix; 225 class SequenceType; 226 class SignList; 227 class SingleType; 228 class StringLiteral; 229 class StringConcatExpr; 230 class SwitchCaseClause; 231 class SwitchCaseClauseList; 232 class SwitchCaseOperandList; 233 class TextTest; 234 class TransformExpr; 235 class TreatExpr; 236 class TypeName; 237 class UnaryExpr; 238 class UnionExpr; 239 class UnorderedExpr; 240 class URILiteralList; 241 class VFO_DeclList; 242 class ValidateExpr; 243 class ValueComp; 244 class VarBinding; 245 class VarDecl; 246 class VersionDecl; 247 248 class CopyVarList; 249 class Wildcard; 250 class DecimalFormatNode; 251 252 class JSONArrayConstructor; 253 class JSONObjectConstructor; 254 class JSONPairConstructor; 255 class JSONPairList; 256 class JSON_Test; 257 258 259 /******************************************************************************* 260 [1] Module ::= VersionDecl? (LibraryModule | MainModule) 261 ********************************************************************************/ 262 class Module : public parsenode 263 { 264 protected: 265 rchandle<VersionDecl> version_decl_h; 266 267 public: Module(const QueryLoc & loc_,rchandle<VersionDecl> vd_)268 Module(const QueryLoc& loc_, rchandle<VersionDecl> vd_) 269 : 270 parsenode (loc_), 271 version_decl_h (vd_) 272 { 273 } 274 get_version_decl()275 rchandle<VersionDecl> get_version_decl() const { return version_decl_h; } 276 set_version_decl(rchandle<VersionDecl> vd)277 void set_version_decl(rchandle<VersionDecl> vd) { version_decl_h = vd; } 278 }; 279 280 281 282 /******************************************************************************* 283 [2] VersionDecl ::= XQUERY ENCODING STRING_LITERAL SEMI | 284 XQUERY VERSION STRING_LITERAL SEMI | 285 XQUERY VERSION STRING_LITERAL ENCODING STRING_LITERAL SEMI 286 ********************************************************************************/ 287 class VersionDecl : public parsenode 288 { 289 protected: 290 zstring version; 291 zstring encoding; 292 293 friend class ParseNodePrintXMLVisitor; 294 295 public: 296 VersionDecl( 297 const QueryLoc&, 298 zstring const& version, 299 zstring const& encoding); 300 get_version()301 zstring const& get_version() const { return version; } get_encoding()302 zstring const& get_encoding() const { return encoding; } 303 304 void accept(parsenode_visitor&) const; 305 }; 306 307 308 /******************************************************************************* 309 [3] MainModule ::= Prolog QueryBody | QueryBody 310 ********************************************************************************/ 311 class MainModule : public Module 312 { 313 protected: 314 rchandle<Prolog> prolog_h; 315 rchandle<QueryBody> query_body_h; 316 317 public: 318 MainModule( 319 const QueryLoc&, 320 rchandle<QueryBody>, 321 rchandle<Prolog>, 322 rchandle<VersionDecl> = NULL); 323 get_prolog()324 rchandle<Prolog> get_prolog() const { return prolog_h; } 325 get_query_body()326 rchandle<QueryBody> get_query_body() const { return query_body_h; } 327 set_prolog(rchandle<Prolog> prolog_)328 void set_prolog (rchandle<Prolog> prolog_) { prolog_h = prolog_; } 329 330 void accept(parsenode_visitor&) const; 331 }; 332 333 334 /******************************************************************************* 335 [4] LibraryModule ::= ModuleDecl Prolog 336 ********************************************************************************/ 337 class LibraryModule : public Module 338 { 339 protected: 340 rchandle<ModuleDecl> decl_h; 341 rchandle<Prolog> prolog_h; 342 343 public: 344 LibraryModule( 345 const QueryLoc&, 346 rchandle<ModuleDecl>, 347 rchandle<Prolog>, 348 rchandle<VersionDecl> = NULL); 349 get_decl()350 rchandle<ModuleDecl> get_decl () const { return decl_h; } 351 get_prolog()352 rchandle<Prolog> get_prolog() const { return prolog_h; } 353 354 void accept(parsenode_visitor&) const; 355 }; 356 357 358 /******************************************************************************* 359 [5] ModuleDecl ::= MODULE NAMESPACE NCNAME EQ URI_LITERAL SEMI 360 ********************************************************************************/ 361 class ModuleDecl : public XQDocumentable 362 { 363 protected: 364 zstring const thePrefix; 365 zstring const theTargetNamespace; 366 367 public: 368 ModuleDecl( 369 const QueryLoc&, 370 zstring const& prefix, 371 zstring const& target_namespace); 372 get_prefix()373 const zstring& get_prefix() const { return thePrefix; } 374 get_target_namespace()375 const zstring& get_target_namespace() const { return theTargetNamespace; } 376 377 void accept(parsenode_visitor&) const; 378 }; 379 380 381 /****************************************************************************** 382 [6] Prolog ::= SIND_DeclList? VFO_DeclList? 383 384 [6a] SIND_DeclList ::= SIND_Decl Separator | SIND_DeclList SIND_Decl Separator 385 386 [6b] VFO_DeclList ::= VFO_Decl Separator | VFO_DeclList VFO_Decl Separator 387 388 [6c] SIND_Decl ::= Setter | NamespaceDecl | DefaultNamespaceDecl | Import 389 390 [6d] VFO_Decl ::= VarDecl | ContextItemDecl | FunctionDecl | IndexDecl | OptionDecl 391 392 ********************************************************************************/ 393 class Prolog : public parsenode 394 { 395 protected: 396 rchandle<SIND_DeclList> sind_list_h; 397 rchandle<VFO_DeclList> vfo_list_h; 398 399 public: 400 Prolog( 401 const QueryLoc&, 402 rchandle<SIND_DeclList>, 403 rchandle<VFO_DeclList>); 404 get_sind_list()405 rchandle<SIND_DeclList> get_sind_list() const { return sind_list_h; } 406 get_vfo_list()407 rchandle<VFO_DeclList> get_vfo_list() const { return vfo_list_h; } 408 409 // returns true if the value was NULL before the call 410 bool set_sind_list(SIND_DeclList* list); 411 412 bool set_vfo_list(VFO_DeclList* list); 413 414 // sets one of the above, returns false if it was set before 415 bool set_list(parsenode* list); 416 set_vfo_list(rchandle<VFO_DeclList> vfo_list_)417 void set_vfo_list(rchandle<VFO_DeclList> vfo_list_) { vfo_list_h = vfo_list_; } 418 419 void accept(parsenode_visitor&) const; 420 }; 421 422 423 /******************************************************************************* 424 [6a] SIND_DeclList ::= SIND_Decl Separator | SIND_DeclList SIND_Decl Separator 425 ********************************************************************************/ 426 class SIND_DeclList : public parsenode 427 { 428 protected: 429 std::vector<rchandle<parsenode> > theDecls; 430 std::vector<rchandle<parsenode> > theModuleImports; 431 432 public: 433 SIND_DeclList(const QueryLoc&); 434 435 void push_back(rchandle<parsenode> decl); 436 437 void accept(parsenode_visitor&) const; 438 }; 439 440 441 /******************************************************************************* 442 [9] Separator ::= SEMI (Lexical rule) 443 ********************************************************************************/ 444 445 446 /****************************************************************************** 447 448 [7] Setter ::= BoundarySpaceDecl | 449 OrderingModeDecl | 450 EmptyOrderDecl | 451 CopyNamespacesDecl | 452 DecimalFormatDecl | 453 DefaultCollationDecl | 454 BaseURIDecl | 455 ConstructionDecl | 456 457 ********************************************************************************/ 458 459 460 /******************************************************************************* 461 [11] BoundarySpaceDecl ::= DECLARE_BOUNDARY_SPACE ( PRESERVE | STRIP ) 462 ********************************************************************************/ 463 class BoundarySpaceDecl : public parsenode 464 { 465 protected: 466 StaticContextConsts::boundary_space_mode_t mode; 467 468 public: 469 BoundarySpaceDecl( 470 const QueryLoc&, 471 StaticContextConsts::boundary_space_mode_t); 472 473 StaticContextConsts::boundary_space_mode_t get_boundary_space_mode()474 get_boundary_space_mode() const { return mode; } 475 476 void accept(parsenode_visitor&) const; 477 }; 478 479 480 /******************************************************************************* 481 [14] OrderingModeDecl ::= DECLARE_ORDERING ( ORDERED | UNORDERED ) 482 ********************************************************************************/ 483 class OrderingModeDecl : public parsenode 484 { 485 protected: 486 StaticContextConsts::ordering_mode_t mode; 487 488 public: 489 OrderingModeDecl( 490 const QueryLoc&, 491 StaticContextConsts::ordering_mode_t); 492 get_mode()493 StaticContextConsts::ordering_mode_t get_mode() const { return mode; } 494 495 void accept(parsenode_visitor&) const; 496 }; 497 498 499 /******************************************************************************* 500 [15] EmptyOrderDecl ::= DECLARE_DEFAULT_ORDER EMPTY_GREATEST | 501 DECLARE_DEFAULT_ORDER EMPTY_LEAST 502 ********************************************************************************/ 503 class EmptyOrderDecl : public parsenode 504 { 505 protected: 506 StaticContextConsts::empty_order_mode_t mode; 507 508 public: 509 EmptyOrderDecl( 510 const QueryLoc&, 511 StaticContextConsts::empty_order_mode_t); 512 get_mode()513 StaticContextConsts::empty_order_mode_t get_mode() const { return mode; } 514 515 void accept(parsenode_visitor&) const; 516 }; 517 518 519 /******************************************************************************* 520 [16] CopyNamespacesDecl ::= DECLARE_COPY_NAMESPACES PreserveMode COMMA InheritMode 521 522 [19] PreserveMode ::= "preserve" | "no-preserve" 523 [20] InheritMode ::= "inherit" | "no-inherit" 524 ********************************************************************************/ 525 class CopyNamespacesDecl : public parsenode 526 { 527 protected: 528 bool thePreserveNamespaces; 529 bool theInheritNamespaces; 530 531 public: 532 CopyNamespacesDecl(const QueryLoc&, bool preserve_ns, bool inherit_ns); 533 preserve_ns()534 bool preserve_ns() const { return thePreserveNamespaces; } 535 inherit_ns()536 bool inherit_ns() const { return theInheritNamespaces; } 537 538 void accept(parsenode_visitor&) const; 539 }; 540 541 542 /****************************************************************************** 543 [17] DecimalFormatDecl ::= "declare" 544 (("decimal-format" QName) | ("default" "decimal-format")) 545 (DFPropertyName "=" StringLiteral)* 546 547 [18] DFPropertyName ::= "decimal-separator" | "grouping-separator" | 548 "infinity" | "minus-sign" | "NaN" | "percent" | 549 "per-mille" | "zero-digit" | "digit" | 550 "pattern-separator" 551 ********************************************************************************/ 552 class DecimalFormatNode : public parsenode 553 { 554 public: 555 typedef std::vector<std::pair<zstring,zstring> > param_list_t; 556 557 bool is_default; 558 rchandle<QName> format_name; 559 param_list_t param_list; 560 DecimalFormatNode(const QueryLoc & _loc,rchandle<QName> qname,param_list_t * param_list_)561 DecimalFormatNode( 562 const QueryLoc& _loc, 563 rchandle<QName> qname, 564 param_list_t* param_list_) 565 : 566 parsenode(_loc), 567 is_default(false), 568 format_name(qname) 569 { 570 param_list.swap(*param_list_); 571 } 572 DecimalFormatNode(const QueryLoc & _loc,param_list_t * param_list_)573 DecimalFormatNode( 574 const QueryLoc& _loc, 575 param_list_t* param_list_) 576 : 577 parsenode(_loc), 578 is_default(true) 579 { 580 param_list.swap(*param_list_); 581 } 582 583 void accept(parsenode_visitor&) const; 584 }; 585 586 587 /******************************************************************************* 588 [21] DefaultCollationDecl ::= DECLARE_DEFAULT_COLLATION URI_LITERAL 589 ********************************************************************************/ 590 class DefaultCollationDecl : public parsenode 591 { 592 protected: 593 zstring collation; 594 595 public: 596 DefaultCollationDecl( 597 const QueryLoc&, 598 zstring const& collation); 599 get_collation()600 zstring const& get_collation() const { return collation; } 601 602 void accept(parsenode_visitor&) const; 603 }; 604 605 606 /******************************************************************************* 607 [22] BaseURIDecl ::= DECLARE_BASE_URI URI_LITERAL 608 ********************************************************************************/ 609 class BaseURIDecl : public parsenode 610 { 611 protected: 612 zstring const base_uri; 613 614 public: 615 BaseURIDecl( 616 const QueryLoc&, 617 zstring const& base_uri); 618 get_base_uri()619 const zstring& get_base_uri() const { return base_uri; } 620 621 void accept(parsenode_visitor&) const; 622 }; 623 624 625 /******************************************************************************* 626 [31] ConstructionDecl ::= DECLARE_CONSTRUCTION PRESERVE 627 DECLARE_CONSTRUCTION STRIP 628 ********************************************************************************/ 629 class ConstructionDecl : public parsenode 630 { 631 protected: 632 StaticContextConsts::construction_mode_t mode; 633 634 public: 635 ConstructionDecl( 636 const QueryLoc&, 637 StaticContextConsts::construction_mode_t); 638 get_mode()639 StaticContextConsts::construction_mode_t get_mode() const { return mode; } 640 641 void accept(parsenode_visitor&) const; 642 }; 643 644 645 /******************************************************************************* 646 [10] NamespaceDecl ::= ::= DECLARE_NAMESPACE NCNAME EQ URI_LITERAL 647 ********************************************************************************/ 648 class NamespaceDecl : public parsenode 649 { 650 protected: 651 zstring const thePrefix; 652 zstring const theUri; 653 654 public: 655 NamespaceDecl( 656 const QueryLoc&, 657 const zstring& prefix, 658 const zstring& uri); 659 get_prefix()660 const zstring& get_prefix() const { return thePrefix; } 661 get_uri()662 const zstring& get_uri() const { return theUri; } 663 664 void accept(parsenode_visitor&) const; 665 }; 666 667 668 /******************************************************************************* 669 [12] DefaultNamespaceDecl ::= DECLARE DEFAULT ELEMENT NAMESPACE URILiteral | 670 DECLARE DEFAULT FUNCTION NAMESPACE URILiteral 671 ********************************************************************************/ 672 class DefaultNamespaceDecl : public parsenode 673 { 674 protected: 675 ParseConstants::default_namespace_mode_t theMode; 676 zstring const theUri; 677 678 public: 679 DefaultNamespaceDecl( 680 const QueryLoc&, 681 enum ParseConstants::default_namespace_mode_t mode, 682 const zstring& uri); 683 get_mode()684 ParseConstants::default_namespace_mode_t get_mode() const { return theMode; } 685 get_default_namespace()686 const zstring& get_default_namespace() const { return theUri; } 687 688 void accept(parsenode_visitor&) const; 689 }; 690 691 692 /******************************************************************************* 693 [8] Import ::= SchemaImport | ModuleImport 694 ********************************************************************************/ 695 696 697 /******************************************************************************* 698 [23] SchemaImport ::= "import" "schema" SchemaPrefix? URILiteral 699 ("at" URILiteralList)? 700 ********************************************************************************/ 701 class SchemaImport : public XQDocumentable 702 { 703 protected: 704 rchandle<SchemaPrefix> thePrefix; 705 zstring const theUri; 706 rchandle<URILiteralList> theAtList; 707 708 public: 709 SchemaImport( 710 const QueryLoc&, 711 rchandle<SchemaPrefix>, 712 zstring const& uri, 713 rchandle<URILiteralList>); 714 get_prefix()715 const SchemaPrefix* get_prefix() const { return thePrefix; } 716 get_uri()717 const zstring& get_uri() const { return theUri; } 718 get_at_list()719 const URILiteralList* get_at_list() const { return theAtList; } 720 721 void accept(parsenode_visitor&) const; 722 }; 723 724 725 /****************************************************************************** 726 [23a] URILiteralList ::= URI_LITERAL | URILiteralList COMMA URI_LITERAL 727 ********************************************************************************/ 728 class URILiteralList : public parsenode 729 { 730 protected: 731 std::vector<zstring> theUris; 732 733 public: 734 URILiteralList(const QueryLoc&); 735 push_back(const zstring & uri)736 void push_back(const zstring& uri) 737 { 738 theUris.push_back(uri); 739 } 740 741 const zstring& operator[](int i) const { return theUris[i]; } 742 size()743 ulong size() const { return (ulong)theUris.size(); } 744 745 void accept(parsenode_visitor&) const; 746 }; 747 748 749 /****************************************************************************** 750 [24] SchemaPrefix ::= ("namespace" NCName "=") | ("default" "element" "namespace") 751 ********************************************************************************/ 752 class SchemaPrefix : public parsenode 753 { 754 protected: 755 zstring const thePrefix; 756 bool const theIsDefault; 757 758 public: 759 SchemaPrefix(const QueryLoc& loc, bool isDefault); 760 761 SchemaPrefix(const QueryLoc& loc, const zstring& prefix); 762 get_prefix()763 const zstring& get_prefix() const { return thePrefix; } 764 get_default_bit()765 bool get_default_bit() const { return theIsDefault; } 766 767 void accept(parsenode_visitor&) const; 768 }; 769 770 771 /******************************************************************************* 772 [25] ModuleImport ::= "import" "module" ("namespace" NCName "=")? URILiteral 773 ("at" URILiteralList)? 774 ********************************************************************************/ 775 class ModuleImport : public XQDocumentable 776 { 777 protected: 778 zstring const thePrefix; 779 zstring const theUri; 780 rchandle<URILiteralList> theAtList; 781 782 public: 783 ModuleImport( 784 const QueryLoc&, 785 const zstring& uri, 786 rchandle<URILiteralList> atlist); 787 788 ModuleImport( 789 const QueryLoc&, 790 const zstring& prefix, 791 const zstring& uri, 792 rchandle<URILiteralList> atlist); 793 get_prefix()794 const zstring& get_prefix() const { return thePrefix; } 795 get_uri()796 const zstring& get_uri() const { return theUri; } 797 get_at_list()798 const URILiteralList* get_at_list() const { return theAtList; } 799 800 void accept(parsenode_visitor&) const; 801 }; 802 803 804 /******************************************************************************* 805 [6b] VFO_DeclList ::= VFO_Decl Separator | VFO_DeclList VFO_Decl Separator 806 807 [6d] VFO_Decl ::= VarDecl | ContextItemDecl | FunctionDecl | IndexDecl | OptionDecl 808 ********************************************************************************/ 809 class VFO_DeclList : public parsenode 810 { 811 protected: 812 std::vector<rchandle<parsenode> > theDecls; 813 std::vector<bool> theIndexDeclFlags; 814 815 public: 816 VFO_DeclList(const QueryLoc&); 817 size()818 csize size() const { return theDecls.size(); } 819 820 void push_back(const rchandle<parsenode>& vfo); 821 822 rchandle<parsenode> operator[](int k) const { return theDecls[k]; } 823 begin()824 std::vector<rchandle<parsenode> >::const_iterator begin() const 825 { 826 return theDecls.begin(); 827 } 828 end()829 std::vector<rchandle<parsenode> >::const_iterator end() const 830 { 831 return theDecls.end(); 832 } 833 834 void accept(parsenode_visitor&) const; 835 }; 836 837 838 /******************************************************************************* 839 [13] OptionDecl ::= DECLARE_OPTION QNAME STRING_LITERAL 840 ********************************************************************************/ 841 class OptionDecl : public parsenode 842 { 843 protected: 844 rchandle<QName> qname_h; 845 zstring const val; 846 847 public: 848 OptionDecl( 849 const QueryLoc&, 850 rchandle<QName>, 851 zstring const&); 852 get_qname()853 rchandle<QName> get_qname() const { return qname_h; } 854 get_val()855 zstring const& get_val() const { return val; } 856 857 void accept(parsenode_visitor&) const; 858 }; 859 860 861 /******************************************************************************* 862 ContextItemDecl ::= "declare" "context" "item" ("as" ItemType)? 863 ((":=" VarValue) | ("external" (":=" VarDefaultValue)?)) 864 ********************************************************************************/ 865 class CtxItemDecl : public parsenode 866 { 867 public: 868 rchandle<exprnode> theInitExpr; 869 bool theIsExternal; 870 rchandle<parsenode> theType; 871 CtxItemDecl(const QueryLoc & loc,rchandle<exprnode> expr)872 CtxItemDecl(const QueryLoc& loc, rchandle<exprnode> expr) 873 : 874 parsenode(loc), 875 theInitExpr(expr), 876 theIsExternal(false) 877 { 878 } 879 get_expr()880 rchandle<exprnode> get_expr() const { return theInitExpr; } 881 is_external()882 bool is_external() const { return theIsExternal; } 883 get_type()884 rchandle<ItemType> get_type() const { return theType; } 885 886 void accept(parsenode_visitor&) const; 887 }; 888 889 890 /******************************************************************************* 891 VarDeclWithInit is used as a base class for parse nodes that represent various 892 kinds of variable declarations: global vars, local vars, let vars, for vars, 893 window vars, and grouping vars. 894 895 Global declarations: 896 -------------------- 897 898 AnnotatedDecl ::= "declare" Annotation* (VarDecl | FunctionDecl) 899 900 Annotation ::= "%" EQName ("(" Literal ("," Literal)* ")")? 901 902 VarDecl ::= variable" "$" VarName TypeDeclaration? 903 ((":=" VarValue) | ("external" (":=" VarDefaultValue)?)) 904 905 VarValue ::= ExprSingle 906 907 VarDefaultValue ::= ExprSingle 908 909 910 Local declarations: 911 ------------------- 912 913 VarDeclStatement ::= ("local" Annotation*)? "variable" 914 "$" VarName TypeDeclaration? (":=" ExprSingle)? 915 ("," "$" VarName TypeDeclaration? (":=" ExprSingle)?)* ";" 916 ********************************************************************************/ 917 class VarDeclWithInit : public XQDocumentable 918 { 919 protected: 920 rchandle<QName> theName; 921 rchandle<SequenceType> theType; 922 rchandle<exprnode> theExpr; 923 924 public: VarDeclWithInit(const QueryLoc & loc,rchandle<QName> name,rchandle<SequenceType> type,rchandle<exprnode> expr)925 VarDeclWithInit( 926 const QueryLoc& loc, 927 rchandle<QName> name, 928 rchandle<SequenceType> type, 929 rchandle<exprnode> expr) 930 : 931 XQDocumentable(loc), 932 theName(name), 933 theType(type), 934 theExpr(expr) 935 { 936 } 937 get_var_name()938 const QName* get_var_name() const { return theName; } 939 get_var_type()940 rchandle<SequenceType> get_var_type() const { return theType; } 941 get_binding_expr()942 rchandle<exprnode> get_binding_expr() const { return theExpr; } 943 }; 944 945 946 /******************************************************************************* 947 948 ********************************************************************************/ 949 class GlobalVarDecl : public VarDeclWithInit 950 { 951 protected: 952 bool theIsExternal; 953 954 rchandle<AnnotationListParsenode> theAnnotations; 955 956 public: 957 GlobalVarDecl( 958 const QueryLoc& loc, 959 QName* varname, 960 SequenceType* type_decl, 961 exprnode* init_expr, 962 AnnotationListParsenode* annotations, 963 bool external); 964 is_extern()965 bool is_extern() const { return theIsExternal; } 966 set_annotations(rchandle<AnnotationListParsenode> annotations)967 void set_annotations(rchandle<AnnotationListParsenode> annotations) 968 { 969 theAnnotations = annotations; 970 } 971 get_annotations()972 AnnotationListParsenode* get_annotations() const { return theAnnotations.getp(); } 973 974 void accept(parsenode_visitor&) const; 975 }; 976 977 978 /******************************************************************************* 979 This is a helper node that is never actually placed in the AST. 980 ********************************************************************************/ 981 class VarNameAndType : public XQDocumentable 982 { 983 public: 984 rchandle<QName> theName; 985 rchandle<SequenceType> theType; 986 rchandle<AnnotationListParsenode> theAnnotations; 987 VarNameAndType(const QueryLoc & loc_,rchandle<QName> name,rchandle<SequenceType> type,rchandle<AnnotationListParsenode> annotations)988 VarNameAndType( 989 const QueryLoc& loc_, 990 rchandle<QName> name, 991 rchandle<SequenceType> type, 992 rchandle<AnnotationListParsenode> annotations) 993 : 994 XQDocumentable(loc_), 995 theName(name), 996 theType(type), 997 theAnnotations(annotations) 998 { 999 } 1000 get_annotations()1001 AnnotationListParsenode* get_annotations() const { return theAnnotations.getp(); } 1002 accept(parsenode_visitor &)1003 void accept(parsenode_visitor&) const { } 1004 }; 1005 1006 1007 /******************************************************************************* 1008 1009 AnnotatedDecl ::= "declare" Annotation* (VarDecl | FunctionDecl) 1010 1011 Annotation ::= "%" EQName ("(" Literal ("," Literal)* ")")? 1012 1013 FunctionDecl ::= ("updating")? "function" EQName "(" ParamList? ")" 1014 ("as" SequenceType)? 1015 (BlockExpr | "external") 1016 1017 BlockExpr ::= "{" Statements Expr "}" 1018 1019 Note: the applicable annotations are private vs public, sequential vs 1020 non-sequential, and deterministic vs nondeterministic. 1021 1022 ********************************************************************************/ 1023 class FunctionDecl : public XQDocumentable 1024 { 1025 protected: 1026 rchandle<QName> theName; 1027 rchandle<ParamList> theParams; 1028 rchandle<SequenceType> theReturnType; 1029 rchandle<exprnode> theBody; 1030 1031 bool theIsExternal; 1032 1033 bool theUpdating; 1034 1035 rchandle<AnnotationListParsenode> theAnnotations; 1036 1037 public: 1038 FunctionDecl( 1039 const QueryLoc& loc, 1040 QName* name, 1041 ParamList* params, 1042 SequenceType* retType, 1043 exprnode* body, 1044 bool updating, 1045 bool external); 1046 get_name()1047 rchandle<QName> get_name() const { return theName; } 1048 get_paramlist()1049 rchandle<ParamList> get_paramlist() const { return theParams; } 1050 1051 csize get_param_count() const; 1052 get_return_type()1053 rchandle<SequenceType> get_return_type() const { return theReturnType; } 1054 get_body()1055 rchandle<exprnode> get_body() const { return theBody; } 1056 is_external()1057 bool is_external() const { return theIsExternal; } 1058 is_updating()1059 bool is_updating() const { return theUpdating; } 1060 get_annotations()1061 AnnotationListParsenode* get_annotations() const 1062 { 1063 return theAnnotations.getp(); 1064 } 1065 1066 void set_annotations(AnnotationListParsenode* annotations); 1067 1068 void accept(parsenode_visitor&) const; 1069 }; 1070 1071 1072 /******************************************************************************* 1073 This is a helper node that is never actually placed in the AST. 1074 ********************************************************************************/ 1075 class FunctionSig 1076 { 1077 public: 1078 rchandle<ParamList> theParams; 1079 rchandle<SequenceType> theReturnType; 1080 1081 FunctionSig(ParamList* param, SequenceType* ret = NULL) 1082 : theParams(param)1083 theParams(param), 1084 theReturnType(ret) 1085 { 1086 } 1087 }; 1088 1089 1090 /******************************************************************************* 1091 ParamList ::= Param ("," Param)* 1092 ********************************************************************************/ 1093 class ParamList : public parsenode 1094 { 1095 protected: 1096 std::vector<rchandle<Param> > param_hv; 1097 1098 public: 1099 ParamList(const QueryLoc&); 1100 push_back(rchandle<Param> param_h)1101 void push_back(rchandle<Param> param_h) { param_hv.push_back(param_h); } 1102 1103 rchandle<Param> operator[](int i) const { return param_hv[i]; } 1104 begin()1105 std::vector<rchandle<Param> >::const_iterator begin() const { return param_hv.begin(); } 1106 end()1107 std::vector<rchandle<Param> >::const_iterator end() const { return param_hv.end(); } 1108 size()1109 std::vector<rchandle<Param> >::size_type size() const { return param_hv.size(); } 1110 1111 void accept(parsenode_visitor&) const; 1112 }; 1113 1114 1115 /******************************************************************************* 1116 Param ::= "$" QName TypeDeclaration? 1117 ********************************************************************************/ 1118 class Param : public parsenode 1119 { 1120 protected: 1121 rchandle<QName> theName; 1122 rchandle<SequenceType> theType; 1123 1124 public: 1125 Param( 1126 const QueryLoc& loc, 1127 rchandle<QName> name, 1128 rchandle<SequenceType> type); 1129 get_name()1130 const QName* get_name() const { return theName.getp(); } 1131 get_typedecl()1132 rchandle<SequenceType> get_typedecl() const { return theType; } 1133 1134 void accept(parsenode_visitor&) const; 1135 }; 1136 1137 1138 /******************************************************************************* 1139 AnnotationList ::= Annotation* 1140 ********************************************************************************/ 1141 class AnnotationListParsenode : public parsenode 1142 { 1143 protected: 1144 std::vector<rchandle<AnnotationParsenode> > theAnnotations; 1145 1146 public: 1147 AnnotationListParsenode( 1148 const QueryLoc& loc, 1149 AnnotationParsenode* annotation); 1150 1151 void push_back(AnnotationParsenode* annotation_h); 1152 1153 rchandle<AnnotationParsenode> operator[](int i) const 1154 { 1155 return theAnnotations[i]; 1156 } 1157 begin()1158 std::vector<rchandle<AnnotationParsenode> >::const_iterator begin() const 1159 { 1160 return theAnnotations.begin(); 1161 } 1162 end()1163 std::vector<rchandle<AnnotationParsenode> >::const_iterator end() const 1164 { 1165 return theAnnotations.end(); 1166 } 1167 size()1168 std::vector<rchandle<AnnotationParsenode> >::size_type size() const 1169 { 1170 return theAnnotations.size(); 1171 } 1172 1173 void accept(parsenode_visitor&) const; 1174 }; 1175 1176 1177 /******************************************************************************* 1178 Annotation ::= "%" EQName ("(" Literal ("," Literal)* ")")? 1179 ********************************************************************************/ 1180 class AnnotationParsenode : public parsenode 1181 { 1182 protected: 1183 rchandle<QName> theQName; 1184 rchandle<AnnotationLiteralListParsenode> theLiteralsList; 1185 1186 public: 1187 AnnotationParsenode( 1188 const QueryLoc& loc, 1189 QName* qname, 1190 AnnotationLiteralListParsenode* literal_list); 1191 get_qname()1192 rchandle<QName> get_qname() const { return theQName; } 1193 get_literals()1194 rchandle<AnnotationLiteralListParsenode> get_literals() const 1195 { 1196 return theLiteralsList; 1197 }; 1198 1199 void accept(parsenode_visitor&) const; 1200 }; 1201 1202 1203 /******************************************************************************* 1204 1205 ********************************************************************************/ 1206 class AnnotationLiteralListParsenode : public parsenode 1207 { 1208 protected: 1209 std::vector<rchandle<exprnode> > theLiterals; 1210 1211 public: 1212 AnnotationLiteralListParsenode(const QueryLoc& loc, exprnode* literal); 1213 push_back(rchandle<exprnode> literal)1214 void push_back(rchandle<exprnode> literal) 1215 { 1216 theLiterals.push_back(literal); 1217 } 1218 1219 rchandle<exprnode> operator[](int i) const 1220 { 1221 return theLiterals[i]; 1222 } 1223 begin()1224 std::vector<rchandle<exprnode> >::const_iterator begin() const 1225 { 1226 return theLiterals.begin(); 1227 } 1228 end()1229 std::vector<rchandle<exprnode> >::const_iterator end() const 1230 { 1231 return theLiterals.end(); 1232 } 1233 size()1234 std::vector<rchandle<exprnode> >::size_type size() const 1235 { 1236 return theLiterals.size(); 1237 } 1238 1239 void accept(parsenode_visitor&) const; 1240 }; 1241 1242 1243 /******************************************************************************* 1244 [*] CollectionDecl ::= "declare" %annotations "collection" QName 1245 ("as" CollectionTypeDecl)? 1246 1247 [*] CollectionTypeDecl ::= KindTest OccurenceIndicator? 1248 ********************************************************************************/ 1249 class CollectionDecl : public XQDocumentable 1250 { 1251 protected: 1252 rchandle<QName> theName; 1253 rchandle<SequenceType> theTypeDecl; 1254 rchandle<AnnotationListParsenode> theAnnotations; 1255 1256 public: 1257 CollectionDecl( 1258 const QueryLoc& aLoc, 1259 QName* aName, 1260 rchandle<AnnotationListParsenode>, 1261 SequenceType* aTypeDecl); 1262 getName()1263 const QName* getName() const { return theName.getp(); } 1264 get_annotations()1265 AnnotationListParsenode* get_annotations() const 1266 { 1267 return theAnnotations.getp(); 1268 } 1269 getType()1270 const SequenceType* getType() const { return theTypeDecl.getp(); } 1271 1272 void accept(parsenode_visitor&) const; 1273 }; 1274 1275 /**************************************************************************//** 1276 IndexDecl ::= "declare" IndexPropertyList "index" QName 1277 "on" "nodes" IndexDomainExpr "by" IndexKeyList 1278 1279 IndexPropertyList := ("unique" | "non" "unique" | 1280 "value" "range" | "value" "equality" | 1281 "general" "range" | "general" "equality" | 1282 "automatically" "maintained" | "manually" "maintained")* 1283 1284 IndexDomainExpr := PathExpr 1285 1286 IndexKeyList := IndexKeySpec+ 1287 1288 IndexKeySpec := PathExpr TypeDeclaration? IndexKeyOrderModifier 1289 1290 AtomicType := QName 1291 1292 IndexKeyOrderModifier := ("ascending" | "descending")? ("collation" UriLiteral)? 1293 *******************************************************************************/ 1294 class AST_IndexDecl : public XQDocumentable 1295 { 1296 protected: 1297 rchandle<QName> theName; 1298 rchandle<exprnode> theDomainExpr; 1299 rchandle<IndexKeyList> theKey; 1300 rchandle<AnnotationListParsenode> theAnnotations; 1301 1302 public: 1303 AST_IndexDecl( 1304 const QueryLoc& loc, 1305 QName* name, 1306 exprnode* domainExpr, 1307 IndexKeyList* key, 1308 rchandle<AnnotationListParsenode>); 1309 getName()1310 const QName* getName() const { return theName.getp(); } 1311 get_annotations()1312 AnnotationListParsenode* get_annotations() const 1313 { 1314 return theAnnotations.getp(); 1315 } 1316 getDomainExpr()1317 const exprnode* getDomainExpr() const { return theDomainExpr; } 1318 1319 void accept(parsenode_visitor&) const; 1320 }; 1321 1322 1323 1324 /***************************************************************************//** 1325 IndexKeyList ::= IndexKeySpec ("," IndexKeySpec)* 1326 ********************************************************************************/ 1327 class IndexKeyList : public parsenode 1328 { 1329 protected: 1330 std::vector<rchandle<IndexKeySpec> > theKeySpecs; 1331 1332 public: IndexKeyList(const QueryLoc & loc)1333 IndexKeyList(const QueryLoc& loc) : parsenode(loc) { } 1334 addKeySpec(IndexKeySpec * spec)1335 void addKeySpec(IndexKeySpec* spec) { theKeySpecs.push_back(spec); } 1336 size()1337 ulong size() const { return (ulong)theKeySpecs.size(); } 1338 getKeySpec(ulong i)1339 const IndexKeySpec* getKeySpec(ulong i) const { return theKeySpecs[i].getp(); } 1340 1341 void accept(parsenode_visitor&) const; 1342 }; 1343 1344 1345 /******************************************************************************* 1346 IndexKeySpec ::= PathExpr TypeDeclaration? IndexKeyOrderModifier 1347 1348 IndexKeyOrderModifier ::= OrderDirSpec? OrderCollationSpec? 1349 1350 OrderDirSpec ::= "ascending" | "descending" 1351 1352 OrderCollationSpec ::= "collation" URILiteral 1353 ********************************************************************************/ 1354 class IndexKeySpec : public parsenode 1355 { 1356 protected: 1357 rchandle<exprnode> theExpr; 1358 rchandle<SequenceType> theType; 1359 rchandle<OrderCollationSpec> theCollationSpec; 1360 1361 public: IndexKeySpec(const QueryLoc & loc,exprnode * expr,SequenceType * type,OrderCollationSpec * collation)1362 IndexKeySpec( 1363 const QueryLoc& loc, 1364 exprnode* expr, 1365 SequenceType* type, 1366 OrderCollationSpec* collation) 1367 : 1368 parsenode(loc), 1369 theExpr(expr), 1370 theType(type), 1371 theCollationSpec(collation) 1372 { 1373 } 1374 getExpr()1375 const exprnode* getExpr() const { return theExpr.getp(); } 1376 getType()1377 const SequenceType* getType() const { return theType.getp(); } 1378 getCollationSpec()1379 const OrderCollationSpec* getCollationSpec() const { return theCollationSpec.getp(); } 1380 1381 void accept(parsenode_visitor&) const; 1382 }; 1383 1384 1385 /***************************************************************************//** 1386 IntegrityConstraintDecl ::= "declare" "unchecked"? "integrity" "constraint" 1387 QName ICType 1388 ICType ::= ICCollSimpleCheck | ICCollUniqueKey | ICCollForeachNode | 1389 ICNodeOfType | ICForeighKey 1390 ICCollSimpleCheck ::= "on" "collection" QName "$" QName "check" ExprSimple 1391 ICCollUniqueKey ::= "on" "collection" QNAME "$" QName "check" "unique" 1392 "key" "(" Expr ")" 1393 ICCollForeachNode ::= "on" "collection" QNAME "foreach" "node" "$" QName 1394 "check" ExprSingle 1395 ICNodeOfType ::= "on" "node" QName "of""type" KindTest "check" ExprSingle 1396 ICForeighKey ::= "on" "foreign" "key" 1397 "from" "collection" QName "node" "$" QName "keys" 1398 "(" Expr ")" 1399 "to" "collection" QName "node" "$" QName "keys" 1400 "(" Expr ")" 1401 *******************************************************************************/ 1402 class IntegrityConstraintDecl : public parsenode 1403 { 1404 public: 1405 enum ICKind 1406 { coll_check_simple, coll_check_unique_key, coll_foreach_node, 1407 foreign_key }; 1408 1409 protected: 1410 rchandle<QName> theICName; 1411 ICKind theICKind; 1412 1413 public: 1414 IntegrityConstraintDecl( 1415 const QueryLoc& loc, 1416 QName* name, 1417 ICKind icKind); 1418 getName()1419 const QName* getName() const { return theICName.getp(); } 1420 getICKind()1421 ICKind getICKind() const { return theICKind; } 1422 1423 virtual void accept(parsenode_visitor&) const = 0; 1424 }; 1425 1426 1427 class ICColl : public IntegrityConstraintDecl 1428 { 1429 protected: 1430 rchandle<QName> theCollName; 1431 1432 public: ICColl(const QueryLoc & loc,QName * name,ICKind icKind,QName * collName)1433 ICColl( 1434 const QueryLoc& loc, 1435 QName* name, 1436 ICKind icKind, 1437 QName* collName) 1438 : 1439 IntegrityConstraintDecl(loc, name, icKind), 1440 theCollName(collName) 1441 { 1442 } 1443 getCollName()1444 const QName* getCollName() const { return theCollName.getp(); } 1445 }; 1446 1447 1448 class ICCollSimpleCheck : public ICColl 1449 { 1450 protected: 1451 rchandle<QName> theCollVarName; 1452 rchandle<exprnode> theExprSingle; // make type exprnode_t 1453 1454 public: ICCollSimpleCheck(const QueryLoc & loc,QName * name,QName * collName,QName * collVarName,rchandle<exprnode> exprSingle)1455 ICCollSimpleCheck( 1456 const QueryLoc& loc, 1457 QName* name, 1458 QName* collName, 1459 QName* collVarName, 1460 rchandle<exprnode> exprSingle) 1461 : 1462 ICColl(loc, 1463 name, 1464 IntegrityConstraintDecl::coll_check_simple, 1465 collName), 1466 theCollVarName(collVarName), 1467 theExprSingle(exprSingle) 1468 { 1469 } 1470 getCollVarName()1471 const QName* getCollVarName() const { return theCollVarName.getp(); } 1472 getExpr()1473 const exprnode* getExpr() const { return theExprSingle.getp(); } 1474 1475 virtual void accept(parsenode_visitor&) const; 1476 }; 1477 1478 1479 class ICCollUniqueKeyCheck : public ICColl 1480 { 1481 protected: 1482 rchandle<QName> theNodeVarName; 1483 rchandle<exprnode> theExpr; 1484 1485 public: ICCollUniqueKeyCheck(const QueryLoc & loc,QName * name,QName * collName,QName * nodeVarName,rchandle<exprnode> expr)1486 ICCollUniqueKeyCheck ( const QueryLoc& loc, 1487 QName* name, 1488 QName* collName, 1489 QName* nodeVarName, 1490 rchandle<exprnode> expr) 1491 : 1492 ICColl(loc, 1493 name, 1494 IntegrityConstraintDecl::coll_check_unique_key, 1495 collName), 1496 theNodeVarName(nodeVarName), 1497 theExpr(expr) 1498 { 1499 } 1500 getNodeVarName()1501 const QName* getNodeVarName() const { return theNodeVarName.getp(); } getExpr()1502 const exprnode* getExpr() const { return theExpr.getp(); } 1503 1504 virtual void accept(parsenode_visitor&) const; 1505 }; 1506 1507 1508 class ICCollForeachNode : public ICColl 1509 { 1510 protected: 1511 rchandle<QName> theCollVarName; 1512 rchandle<exprnode> theExprSingle; 1513 1514 public: ICCollForeachNode(const QueryLoc & loc,QName * name,QName * collName,QName * collVarName,rchandle<exprnode> exprSingle)1515 ICCollForeachNode ( const QueryLoc& loc, 1516 QName* name, 1517 QName* collName, 1518 QName* collVarName, 1519 rchandle<exprnode> exprSingle) 1520 : 1521 ICColl(loc, 1522 name, 1523 IntegrityConstraintDecl::coll_foreach_node, 1524 collName), 1525 theCollVarName(collVarName), 1526 theExprSingle(exprSingle) 1527 { 1528 } 1529 getCollVarName()1530 const QName* getCollVarName() const { return theCollVarName.getp(); } getExpr()1531 const exprnode* getExpr() const { return theExprSingle.getp(); } 1532 1533 virtual void accept(parsenode_visitor&) const; 1534 }; 1535 1536 1537 class ICForeignKey : public IntegrityConstraintDecl 1538 { 1539 protected: 1540 rchandle<QName> theFromCollName; 1541 rchandle<QName> theFromNodeVarName; 1542 rchandle<exprnode> theFromExpr; 1543 rchandle<QName> theToCollName; 1544 rchandle<QName> theToNodeVarName; 1545 rchandle<exprnode> theToExpr; 1546 1547 public: ICForeignKey(const QueryLoc & loc,QName * name,QName * fromCollName,QName * fromNodeVarName,rchandle<exprnode> fromExpr,QName * toCollName,QName * toNodeVarName,rchandle<exprnode> toExpr)1548 ICForeignKey ( const QueryLoc& loc, 1549 QName* name, 1550 QName* fromCollName, 1551 QName* fromNodeVarName, 1552 rchandle<exprnode> fromExpr, 1553 QName* toCollName, 1554 QName* toNodeVarName, 1555 rchandle<exprnode> toExpr) 1556 : 1557 IntegrityConstraintDecl(loc, 1558 name, 1559 IntegrityConstraintDecl::foreign_key), 1560 theFromCollName(fromCollName), 1561 theFromNodeVarName(fromNodeVarName), 1562 theFromExpr(fromExpr), 1563 theToCollName(toCollName), 1564 theToNodeVarName(toNodeVarName), 1565 theToExpr(toExpr) 1566 { 1567 } 1568 getFromCollName()1569 const QName* getFromCollName() const { return theFromCollName; } getFromNodeVarName()1570 const QName* getFromNodeVarName() const { return theFromNodeVarName; } getFromExpr()1571 const exprnode* getFromExpr() const { return theFromExpr.getp(); } getToCollName()1572 const QName* getToCollName() const { return theToCollName; } getToNodeVarName()1573 const QName* getToNodeVarName() const { return theToNodeVarName; } getToExpr()1574 const exprnode* getToExpr() const { return theToExpr.getp(); } 1575 1576 virtual void accept(parsenode_visitor&) const; 1577 }; 1578 1579 1580 /******************************************************************************* 1581 QueryBody ::= 1582 ********************************************************************************/ 1583 class QueryBody : public exprnode 1584 { 1585 protected: 1586 rchandle<exprnode> theExpr; 1587 1588 public: 1589 QueryBody(const QueryLoc&, exprnode*); 1590 1591 QueryBody(); 1592 get_expr()1593 exprnode* get_expr() const { return theExpr.getp(); } 1594 1595 void accept(parsenode_visitor&) const; 1596 }; 1597 1598 1599 /******************************************************************************* 1600 1601 ********************************************************************************/ 1602 class BlockBody : public exprnode 1603 { 1604 protected: 1605 std::vector<rchandle<parsenode> > theStatements; 1606 bool theIsTopLevel; 1607 1608 public: BlockBody(const QueryLoc & loc)1609 BlockBody (const QueryLoc& loc) 1610 : 1611 exprnode(loc), 1612 theIsTopLevel(false) 1613 { 1614 } 1615 1616 const parsenode* operator[](ulong k) const { return theStatements[k].getp(); } 1617 1618 parsenode* operator[](ulong k) { return theStatements[k].getp(); } 1619 size()1620 csize size() const { return theStatements.size(); } 1621 isTopLevel()1622 bool isTopLevel() const { return theIsTopLevel; } 1623 setTopLevel(bool v)1624 void setTopLevel(bool v) { theIsTopLevel = v; } 1625 1626 void add(parsenode* statement); 1627 1628 void accept(parsenode_visitor&) const; 1629 }; 1630 1631 1632 /******************************************************************************* 1633 VarDeclStatement ::= ("local" Annotation*)? "variable" 1634 "$" VarName TypeDeclaration? (":=" ExprSingle)? 1635 ("," "$" VarName TypeDeclaration? (":=" ExprSingle)?)* ";" 1636 ********************************************************************************/ 1637 class VarDeclStmt : public exprnode 1638 { 1639 protected: 1640 std::vector<rchandle<parsenode> > theDecls; 1641 rchandle<AnnotationListParsenode> theAnnotations; 1642 1643 public: 1644 VarDeclStmt(const QueryLoc& loc, AnnotationListParsenode* annotations); 1645 1646 void add(parsenode* decl); 1647 size()1648 csize size() const { return theDecls.size(); } 1649 getDecl(csize i)1650 parsenode* getDecl(csize i) const { return theDecls[i].getp(); } 1651 1652 void accept(parsenode_visitor&) const; 1653 }; 1654 1655 1656 /******************************************************************************* 1657 1658 ********************************************************************************/ 1659 class LocalVarDecl : public VarDeclWithInit 1660 { 1661 protected: 1662 rchandle<AnnotationListParsenode> theAnnotations; 1663 1664 public: 1665 LocalVarDecl( 1666 const QueryLoc& loc, 1667 QName* varname, 1668 SequenceType* type_decl, 1669 exprnode* init_expr, 1670 AnnotationListParsenode* annotations); 1671 set_annotations(rchandle<AnnotationListParsenode> annotations)1672 void set_annotations(rchandle<AnnotationListParsenode> annotations) 1673 { 1674 theAnnotations = annotations; 1675 } 1676 get_annotations()1677 AnnotationListParsenode* get_annotations() const { return theAnnotations.getp(); } 1678 1679 void accept(parsenode_visitor&) const; 1680 }; 1681 1682 1683 /******************************************************************************* 1684 1685 ********************************************************************************/ 1686 class AssignExpr : public exprnode 1687 { 1688 rchandle<QName> theName; 1689 rchandle<exprnode> theValue; 1690 1691 public: AssignExpr(const QueryLoc & loc,rchandle<QName> name,exprnode * val)1692 AssignExpr(const QueryLoc& loc, rchandle<QName> name, exprnode* val) 1693 : 1694 exprnode(loc), 1695 theName(name), 1696 theValue(val) 1697 { 1698 } 1699 get_name()1700 const QName* get_name() const { return theName.getp(); } 1701 get_value()1702 exprnode* get_value() const { return theValue.getp(); } 1703 1704 void accept(parsenode_visitor&) const; 1705 }; 1706 1707 1708 /******************************************************************************* 1709 ApplyExpr 1710 ********************************************************************************/ 1711 class ApplyExpr : public exprnode 1712 { 1713 protected: 1714 rchandle<exprnode> theExpr; 1715 1716 public: ApplyExpr(const QueryLoc & loc,exprnode * expr)1717 ApplyExpr(const QueryLoc& loc, exprnode* expr) 1718 : 1719 exprnode(loc), 1720 theExpr(expr) 1721 { 1722 } 1723 get_apply_expr()1724 const exprnode* get_apply_expr() { return theExpr.getp(); } 1725 1726 void accept(parsenode_visitor&) const; 1727 }; 1728 1729 1730 /******************************************************************************* 1731 1732 ********************************************************************************/ 1733 class ExitExpr : public exprnode 1734 { 1735 rchandle<exprnode> theValue; 1736 1737 public: ExitExpr(const QueryLoc & loc,exprnode * val)1738 ExitExpr(const QueryLoc& loc, exprnode* val) 1739 : 1740 exprnode(loc), 1741 theValue(val) 1742 { 1743 } 1744 get_value()1745 exprnode* get_value() { return theValue.getp(); } 1746 1747 void accept(parsenode_visitor&) const; 1748 }; 1749 1750 1751 /******************************************************************************* 1752 1753 ********************************************************************************/ 1754 class WhileExpr : public exprnode 1755 { 1756 rchandle<exprnode> cond; 1757 rchandle<BlockBody> body; 1758 1759 public: WhileExpr(const QueryLoc & loc_,rchandle<exprnode> cond_,rchandle<BlockBody> body_)1760 WhileExpr(const QueryLoc& loc_, rchandle<exprnode> cond_, rchandle<BlockBody> body_) 1761 : 1762 exprnode (loc_), 1763 cond (cond_), 1764 body (body_) 1765 { 1766 } 1767 get_cond()1768 exprnode* get_cond() { return cond; } 1769 get_body()1770 BlockBody* get_body() { return body; } 1771 1772 void accept(parsenode_visitor&) const; 1773 }; 1774 1775 1776 /******************************************************************************* 1777 1778 ********************************************************************************/ 1779 class FlowCtlStatement : public exprnode 1780 { 1781 public: 1782 enum action { BREAK, CONTINUE }; 1783 1784 private: 1785 enum action action; 1786 1787 public: FlowCtlStatement(const QueryLoc & loc,enum action action_)1788 FlowCtlStatement(const QueryLoc& loc, enum action action_) 1789 : 1790 exprnode(loc), 1791 action(action_) 1792 { 1793 } 1794 get_action()1795 enum action get_action() const { return action; } 1796 1797 void accept(parsenode_visitor&) const; 1798 }; 1799 1800 1801 /******************************************************************************* 1802 1803 ********************************************************************************/ 1804 class Expr : public exprnode 1805 { 1806 protected: 1807 std::vector<rchandle<exprnode> > expr_hv; 1808 1809 public: 1810 Expr(const QueryLoc&); 1811 push_back(rchandle<exprnode> expr_h)1812 void push_back(rchandle<exprnode> expr_h) 1813 { 1814 expr_hv.push_back(expr_h); 1815 // update the location of the current expression to 1816 // end at the location of the last child that was added 1817 loc.setLineEnd(expr_h->get_location().getLineEnd()); 1818 loc.setColumnEnd(expr_h->get_location().getColumnEnd()); 1819 } 1820 1821 rchandle<exprnode> operator[](int i) const { return expr_hv[i]; } 1822 1823 int numberOfChildren() const; 1824 1825 void accept(parsenode_visitor&) const; 1826 }; 1827 1828 1829 /******************************************************************************* 1830 [39] ExprSingle ::= 1831 1832 ** XQuery 3.0 exprs 1833 FLWORExpr | 1834 QuantifiedExpr | 1835 TypeswitchExpr | 1836 IfExpr | 1837 OrExpr | 1838 TryExpr | 1839 1840 ** scripting 1841 BlockExpr | 1842 ExitExpr | 1843 WhileExpr | 1844 AssignExpr | 1845 FlowCtlStatement | 1846 1847 ** eval 1848 EvalExpr | 1849 1850 ** updates 1851 InsertExpr | 1852 DeleteExpr | 1853 RenameExpr | 1854 ReplaceExpr | 1855 TransformExpr 1856 1857 ********************************************************************************/ 1858 1859 1860 1861 1862 /******************************************************************************* 1863 FLWORExpr ::= InitialClause FLWORClauseList? ReturnClause 1864 1865 - For the Generalized FLWOR: 1866 1867 InitialClause ::= ForClause | LetClause | WindowClause 1868 1869 FLWORClauseList ::= FLWORClause* 1870 1871 1872 - For the traditional FLWOR: 1873 1874 InitialClause ::= ForClause | LetClause 1875 1876 FLWORClauseList ::= (ForClause | LetClause)* 1877 WhereCluase? 1878 GroupByClause? 1879 OrderByClause? 1880 ********************************************************************************/ 1881 class FLWORExpr : public exprnode 1882 { 1883 protected: 1884 rchandle<FLWORClauseList> clauses; 1885 rchandle<exprnode> return_val_h; 1886 bool general; //< needs to be translated into gflwor_expr? 1887 bool non_10; //< non-conformant to XQuery 1.0 spec? 1888 QueryLoc return_location; 1889 1890 public: 1891 FLWORExpr( 1892 const QueryLoc& loc_, 1893 rchandle<FLWORClauseList> clauses_, 1894 rchandle<exprnode> ret_, 1895 const QueryLoc& return_loc_, 1896 bool force_general = false); 1897 is_general()1898 bool is_general () const { return general; } 1899 is_non_10()1900 bool is_non_10 () const { return non_10; } 1901 get_return_location()1902 const QueryLoc& get_return_location() const { return return_location; } 1903 get_clause_list()1904 rchandle<FLWORClauseList> get_clause_list() const { return clauses; } 1905 get_return_val()1906 rchandle<exprnode> get_return_val() const { return return_val_h; } 1907 1908 GroupByClause* get_groupby() const; 1909 1910 OrderByClause* get_orderby() const; 1911 1912 WhereClause* get_where() const; 1913 1914 void accept(parsenode_visitor&) const; 1915 1916 protected: 1917 void compute_general (); 1918 }; 1919 1920 1921 /******************************************************************************* 1922 - For the Generalized FLWOR: 1923 1924 FLWORClauseList ::= FLWORClause* 1925 1926 - For the traditional FLWOR: 1927 1928 FLWORClauseList ::= (ForClause | LetClause)* 1929 WhereCluase? 1930 GroupByClause? 1931 OrderByClause? 1932 ********************************************************************************/ 1933 class FLWORClauseList : public parsenode 1934 { 1935 protected: 1936 std::vector<rchandle<FLWORClause> > theClauses; 1937 1938 public: 1939 FLWORClauseList(const QueryLoc&); 1940 1941 public: push_back(rchandle<FLWORClause> cl)1942 void push_back(rchandle<FLWORClause> cl) { theClauses.push_back(cl); } 1943 1944 rchandle<FLWORClause> operator[](int i) const { return theClauses[i]; } 1945 size()1946 csize size() const { return theClauses.size(); } 1947 1948 void accept(parsenode_visitor&) const; 1949 }; 1950 1951 1952 /******************************************************************************* 1953 FLWORClause ::= ForClause | 1954 LetClause | 1955 WindowClause | 1956 WhereClause | 1957 GroupByClause | 1958 OrderByClause | 1959 CountClause 1960 ********************************************************************************/ 1961 class FLWORClause : public parsenode 1962 { 1963 public: FLWORClause(const QueryLoc & loc)1964 FLWORClause(const QueryLoc& loc) : parsenode(loc) {} 1965 }; 1966 1967 1968 /******************************************************************************* 1969 ForOrLetClause ::= ForClause | LetClause 1970 ********************************************************************************/ 1971 class ForOrLetClause : public FLWORClause 1972 { 1973 public: 1974 typedef enum { for_clause, let_clause } for_or_let_t; 1975 ForOrLetClause(const QueryLoc & loc)1976 ForOrLetClause (const QueryLoc& loc) : FLWORClause(loc) {} 1977 1978 virtual for_or_let_t for_or_let() const = 0; 1979 1980 virtual int get_decl_count() const = 0; 1981 }; 1982 1983 1984 /******************************************************************************* 1985 ForClause ::= "outer"? "for" "$" VarInDeclList 1986 ********************************************************************************/ 1987 class ForClause : public ForOrLetClause 1988 { 1989 protected: 1990 rchandle<VarInDeclList> vardecl_list_h; 1991 bool allowing_empty; 1992 1993 public: 1994 ForClause(const QueryLoc&, rchandle<VarInDeclList>); 1995 for_or_let()1996 for_or_let_t for_or_let () const { return for_clause; } 1997 has_allowing_empty()1998 bool has_allowing_empty() const { return allowing_empty; } 1999 get_vardecl_list()2000 rchandle<VarInDeclList> get_vardecl_list() const { return vardecl_list_h; } 2001 2002 int get_decl_count () const; 2003 2004 void accept(parsenode_visitor&) const; 2005 }; 2006 2007 2008 /******************************************************************************* 2009 VarInDeclList ::= VarInDecl | VarInDeclList "," "$" VarInDecl 2010 ********************************************************************************/ 2011 class VarInDeclList : public parsenode 2012 { 2013 protected: 2014 std::vector<rchandle<VarInDecl> > vardecl_hv; 2015 2016 public: 2017 VarInDeclList(const QueryLoc&); 2018 push_back(rchandle<VarInDecl> vardecl_h)2019 void push_back(rchandle<VarInDecl> vardecl_h) { vardecl_hv.push_back(vardecl_h); } 2020 2021 rchandle<VarInDecl> operator[](int i) const { return vardecl_hv[i]; } 2022 size()2023 csize size() const { return vardecl_hv.size ();} 2024 2025 void accept(parsenode_visitor&) const; 2026 }; 2027 2028 2029 /******************************************************************************* 2030 VarInDecl ::= VarName TypeDeclaration? PositionalVar? FTScoreVar? "in" ExprSingle 2031 ********************************************************************************/ 2032 class VarInDecl : public VarDeclWithInit 2033 { 2034 protected: 2035 rchandle<PositionalVar> posvar_h; 2036 rchandle<FTScoreVar> ftscorevar_h; 2037 rchandle<exprnode> valexpr_h; 2038 bool allowing_empty; 2039 2040 public: 2041 VarInDecl( 2042 const QueryLoc&, 2043 rchandle<QName> varname, 2044 rchandle<SequenceType>, 2045 rchandle<PositionalVar>, 2046 rchandle<FTScoreVar>, 2047 rchandle<exprnode>, 2048 bool _allowing_empty); 2049 get_posvar()2050 rchandle<PositionalVar> get_posvar() const { return posvar_h; } 2051 get_ftscorevar()2052 rchandle<FTScoreVar> get_ftscorevar() const { return ftscorevar_h; } 2053 get_allowing_empty()2054 bool get_allowing_empty() const { return allowing_empty; } 2055 2056 void accept(parsenode_visitor&) const; 2057 }; 2058 2059 2060 /******************************************************************************* 2061 PositionalVar ::= "at" "$" VarName 2062 ********************************************************************************/ 2063 class PositionalVar : public parsenode 2064 { 2065 protected: 2066 rchandle<QName> theName; 2067 2068 public: 2069 PositionalVar(const QueryLoc&, rchandle<QName> varname); 2070 get_name()2071 const QName* get_name() const { return theName.getp(); } 2072 2073 void accept(parsenode_visitor&) const; 2074 }; 2075 2076 2077 /******************************************************************************* 2078 LetClause ::= "let" "$" VarGetsDeclList | 2079 "let" "score $" VarGetsDeclList 2080 ********************************************************************************/ 2081 class LetClause : public ForOrLetClause 2082 { 2083 protected: 2084 rchandle<VarGetsDeclList> vardecl_list_h; 2085 2086 public: 2087 LetClause(const QueryLoc&, rchandle<VarGetsDeclList>); 2088 get_vardecl_list()2089 rchandle<VarGetsDeclList> get_vardecl_list() const { return vardecl_list_h; } 2090 for_or_let()2091 for_or_let_t for_or_let () const { return let_clause; } 2092 2093 int get_decl_count () const; 2094 2095 void accept(parsenode_visitor&) const; 2096 }; 2097 2098 2099 /******************************************************************************* 2100 VarGetsDeclList ::= VarGetsDecl | 2101 VarGetsDeclList "," "$" VarGetsDecl 2102 ********************************************************************************/ 2103 class VarGetsDeclList : public parsenode 2104 { 2105 protected: 2106 std::vector<rchandle<VarGetsDecl> > vardecl_hv; 2107 2108 public: 2109 VarGetsDeclList(const QueryLoc&); 2110 push_back(rchandle<VarGetsDecl> vardecl_h)2111 void push_back(rchandle<VarGetsDecl> vardecl_h) { vardecl_hv.push_back(vardecl_h); } 2112 2113 rchandle<VarGetsDecl> operator[](int i) const { return vardecl_hv[i]; } 2114 size()2115 size_t size () const { return vardecl_hv.size (); } 2116 2117 void accept(parsenode_visitor&) const; 2118 }; 2119 2120 2121 /******************************************************************************* 2122 VarGetsDecl ::= VarName TypeDeclaration? ":=" ExprSingle | 2123 VarName TypeDeclaration? FTScoreVar ":=" ExprSingle 2124 2125 Note: This ast node also represents EVAL external vars 2126 ********************************************************************************/ 2127 class VarGetsDecl : public VarDeclWithInit 2128 { 2129 public: 2130 enum var_kind { let_var, eval_var }; 2131 2132 protected: 2133 rchandle<FTScoreVar> ftscorevar_h; 2134 enum var_kind kind; 2135 2136 public: 2137 VarGetsDecl( 2138 const QueryLoc& loc, 2139 rchandle<QName> varname, 2140 rchandle<SequenceType> typedecl_h, 2141 rchandle<FTScoreVar> ftscorevar_h, 2142 rchandle<exprnode> valexpr_h, 2143 enum var_kind kind_ = let_var) 2144 : VarDeclWithInit(loc,varname,typedecl_h,valexpr_h)2145 VarDeclWithInit(loc, varname, typedecl_h, valexpr_h), 2146 ftscorevar_h(ftscorevar_h), 2147 kind (kind_) 2148 { 2149 } 2150 get_ftscorevar()2151 rchandle<FTScoreVar> get_ftscorevar() const { return ftscorevar_h; } 2152 get_kind()2153 enum var_kind get_kind () const { return kind; } 2154 set_kind(enum var_kind kind_)2155 void set_kind (enum var_kind kind_) { kind = kind_; } 2156 2157 void accept(parsenode_visitor&) const; 2158 }; 2159 2160 2161 /******************************************************************************* 2162 FTScoreVar ::= SCORE DOLLAR VarName 2163 ********************************************************************************/ 2164 class FTScoreVar : public parsenode 2165 { 2166 protected: 2167 rchandle<QName> var_name_h; 2168 2169 public: 2170 FTScoreVar(const QueryLoc&, 2171 rchandle<QName>); 2172 get_var_name()2173 QName* get_var_name() const { return var_name_h.getp(); } 2174 2175 void accept( parsenode_visitor& ) const; 2176 }; 2177 2178 2179 /******************************************************************************* 2180 WhereClause ::= "where" ExprSingle 2181 ********************************************************************************/ 2182 class WhereClause : public FLWORClause 2183 { 2184 protected: 2185 rchandle<exprnode> predicate_h; 2186 2187 public: 2188 WhereClause(const QueryLoc&, rchandle<exprnode>); 2189 get_predicate()2190 rchandle<exprnode> get_predicate() const { return predicate_h; } 2191 2192 void accept(parsenode_visitor&) const; 2193 }; 2194 2195 2196 /******************************************************************************* 2197 GroupByClause ::= "group" "by" GroupingSpecList 2198 ********************************************************************************/ 2199 class GroupByClause : public FLWORClause 2200 { 2201 protected: 2202 FLWORExpr* flwor_h; 2203 rchandle<GroupSpecList> spec_list_h; 2204 2205 public: 2206 GroupByClause(const QueryLoc&, rchandle<GroupSpecList>); 2207 set_flwor(FLWORExpr * a)2208 void set_flwor(FLWORExpr* a) { flwor_h = a; } 2209 get_flwor()2210 FLWORExpr* get_flwor() const { return flwor_h; } 2211 get_spec_list()2212 GroupSpecList* get_spec_list() const { return spec_list_h.getp(); } 2213 2214 void accept(parsenode_visitor&) const; 2215 }; 2216 2217 2218 /******************************************************************************* 2219 GroupSpecList ::= GroupingSpec ("," GroupingSpec)* 2220 ********************************************************************************/ 2221 class GroupSpecList : public parsenode 2222 { 2223 protected: 2224 std::vector<rchandle<GroupSpec> > theSpecs; 2225 2226 public: 2227 GroupSpecList(const QueryLoc& loc); 2228 2229 void push_back(rchandle<GroupSpec> spec); 2230 2231 GroupSpec* operator[](int i) const { return theSpecs[i].getp(); } 2232 size()2233 csize size() const { return theSpecs.size(); } 2234 2235 void accept(parsenode_visitor&) const; 2236 }; 2237 2238 2239 /******************************************************************************* 2240 GroupSpec ::= "$" VarName 2241 (TypeDeclaration? ":=" ExprSingle)? 2242 ("collation" URILiteral)? 2243 ********************************************************************************/ 2244 class GroupSpec : public VarDeclWithInit 2245 { 2246 protected: 2247 rchandle<GroupCollationSpec> theCollationSpec; 2248 2249 public: 2250 GroupSpec( 2251 const QueryLoc& loc, 2252 rchandle<QName> name, 2253 rchandle<SequenceType> type, 2254 rchandle<exprnode> expr, 2255 rchandle<GroupCollationSpec> collation); 2256 get_collation_spec()2257 const GroupCollationSpec* get_collation_spec() const { return theCollationSpec.getp(); } 2258 2259 void accept(parsenode_visitor&) const; 2260 }; 2261 2262 2263 /******************************************************************************* 2264 2265 ********************************************************************************/ 2266 class GroupCollationSpec : public parsenode 2267 { 2268 protected: 2269 const zstring theUri; 2270 2271 public: 2272 GroupCollationSpec(const QueryLoc&, const zstring& uri); 2273 get_uri()2274 const zstring& get_uri() const { return theUri; } 2275 2276 void accept(parsenode_visitor&) const; 2277 }; 2278 2279 2280 /******************************************************************************* 2281 OrderByClause ::= (("order" "by") | ("stable" "order" "by")) OrderSpecList 2282 ********************************************************************************/ 2283 class OrderByClause : public FLWORClause 2284 { 2285 protected: 2286 rchandle<OrderSpecList> spec_list_h; 2287 bool stable_b; 2288 const FLWORExpr *flwor; 2289 2290 public: 2291 OrderByClause( 2292 const QueryLoc&, 2293 rchandle<OrderSpecList>, 2294 bool stable_b = false); 2295 get_spec_list()2296 OrderSpecList* get_spec_list() const { return spec_list_h.getp(); } 2297 get_stable_bit()2298 bool get_stable_bit() const { return stable_b; } 2299 get_flwor()2300 const FLWORExpr *get_flwor () const { return flwor; } 2301 set_flwor(const FLWORExpr * flwor_)2302 void set_flwor (const FLWORExpr* flwor_) { flwor = flwor_; } 2303 2304 void accept(parsenode_visitor&) const; 2305 }; 2306 2307 2308 /******************************************************************************* 2309 OrderSpecList ::= OrderSpec ("," OrderSpec)* 2310 ********************************************************************************/ 2311 class OrderSpecList : public parsenode 2312 { 2313 protected: 2314 std::vector<rchandle<OrderSpec> > spec_hv; 2315 2316 public: 2317 OrderSpecList(const QueryLoc&); 2318 push_back(rchandle<OrderSpec> spec_h)2319 void push_back(rchandle<OrderSpec> spec_h) { spec_hv.push_back(spec_h); } 2320 2321 OrderSpec* operator[](int i) const { return spec_hv[i].getp(); } 2322 size()2323 size_t size () const { return spec_hv.size (); } 2324 2325 void accept(parsenode_visitor&) const; 2326 }; 2327 2328 2329 /******************************************************************************* 2330 OrderSpec ::= ExprSingle OrderModifier 2331 ********************************************************************************/ 2332 class OrderSpec : public parsenode 2333 { 2334 protected: 2335 rchandle<exprnode> spec_h; 2336 rchandle<OrderModifierPN> modifier_h; 2337 2338 public: 2339 OrderSpec( 2340 const QueryLoc&, 2341 exprnode*, 2342 OrderModifierPN*); 2343 get_spec()2344 rchandle<exprnode> get_spec() const { return spec_h; } 2345 get_modifier()2346 const OrderModifierPN* get_modifier() const { return modifier_h.getp(); } 2347 2348 void accept(parsenode_visitor&) const; 2349 }; 2350 2351 2352 /******************************************************************************* 2353 OrderModifier ::= OrderDirSpec? OrderEmptySpec? OrderCollationSpec? 2354 ********************************************************************************/ 2355 class OrderModifierPN : public parsenode 2356 { 2357 protected: 2358 rchandle<OrderDirSpec> dir_spec_h; 2359 rchandle<OrderEmptySpec> empty_spec_h; 2360 rchandle<OrderCollationSpec> collation_spec_h; 2361 2362 public: 2363 OrderModifierPN( 2364 const QueryLoc&, 2365 OrderDirSpec*, 2366 OrderEmptySpec*, 2367 OrderCollationSpec*); 2368 get_dir_spec()2369 const OrderDirSpec* get_dir_spec() const { return dir_spec_h; } 2370 get_empty_spec()2371 const OrderEmptySpec* get_empty_spec() const { return empty_spec_h; } 2372 get_collation_spec()2373 const OrderCollationSpec* get_collation_spec() const { return collation_spec_h; } 2374 2375 void accept(parsenode_visitor&) const; 2376 }; 2377 2378 2379 /******************************************************************************* 2380 OrderDirSpec ::= "ascending" | "descending" 2381 ********************************************************************************/ 2382 class OrderDirSpec : public parsenode 2383 { 2384 protected: 2385 ParseConstants::dir_spec_t dir_spec; 2386 2387 public: 2388 OrderDirSpec(const QueryLoc&, ParseConstants::dir_spec_t dir_spec); 2389 getValue()2390 ParseConstants::dir_spec_t getValue() const { return dir_spec; } 2391 2392 void accept(parsenode_visitor&) const; 2393 }; 2394 2395 2396 /******************************************************************************* 2397 OrderEmptySpec ::= "empty" ("greatest" | "least") 2398 ********************************************************************************/ 2399 class OrderEmptySpec : public parsenode 2400 { 2401 protected: 2402 StaticContextConsts::empty_order_mode_t empty_order_spec; 2403 2404 public: 2405 OrderEmptySpec( 2406 const QueryLoc&, 2407 StaticContextConsts::empty_order_mode_t empty_order_spec); 2408 getValue()2409 StaticContextConsts::empty_order_mode_t getValue() const 2410 { 2411 return empty_order_spec; 2412 } 2413 2414 void accept(parsenode_visitor&) const; 2415 }; 2416 2417 2418 /******************************************************************************* 2419 OrderCollationSpec ::= "collation" URILiteral 2420 ********************************************************************************/ 2421 class OrderCollationSpec : public parsenode 2422 { 2423 protected: 2424 zstring uri; 2425 2426 public: 2427 OrderCollationSpec(const QueryLoc&, zstring const& uri); 2428 get_uri()2429 zstring const& get_uri() const { return uri; } 2430 2431 void accept(parsenode_visitor&) const; 2432 }; 2433 2434 2435 /******************************************************************************* 2436 ReturnExpr ::= "return" ExprSingle 2437 ********************************************************************************/ 2438 class ReturnExpr: public exprnode 2439 { 2440 protected: 2441 rchandle<exprnode> return_val_h; 2442 2443 public: ReturnExpr(const QueryLoc & loc_,rchandle<exprnode> ret_)2444 ReturnExpr(const QueryLoc& loc_, rchandle<exprnode> ret_): exprnode(loc_), return_val_h(ret_){} get_return_val()2445 rchandle<exprnode> get_return_val() const { return return_val_h; } accept(parsenode_visitor &)2446 void accept(parsenode_visitor&) const { /* do nothing... */ } 2447 }; 2448 2449 2450 /******************************************************************************* 2451 WindowClause ::= "for" (TumblingWindowClause | SlidingWindowClause) 2452 2453 TumblingWindowClause ::= "tumbling" "window" WindowVarDecl 2454 WindowStartCondition WindowEndCondition? 2455 2456 SlidingWindowClause ::= "sliding" "window" WindowVarDecl 2457 WindowStartCondition WindowEndCondition 2458 ********************************************************************************/ 2459 class WindowClause : public FLWORClause 2460 { 2461 public: 2462 typedef enum { tumbling_window, sliding_window } win_clause_t; 2463 2464 private: 2465 rchandle<WindowVarDecl> var; 2466 win_clause_t type; 2467 rchandle<FLWORWinCond> conditions [2]; 2468 2469 public: WindowClause(const QueryLoc & loc,win_clause_t type_,rchandle<WindowVarDecl> var_,rchandle<FLWORWinCond> start_,rchandle<FLWORWinCond> end_)2470 WindowClause ( 2471 const QueryLoc& loc, 2472 win_clause_t type_, 2473 rchandle<WindowVarDecl> var_, 2474 rchandle<FLWORWinCond> start_, 2475 rchandle<FLWORWinCond> end_) 2476 : 2477 FLWORClause(loc), 2478 var(var_), 2479 type(type_) 2480 { 2481 conditions[0] = start_; 2482 conditions[1] = end_; 2483 } 2484 get_wintype()2485 win_clause_t get_wintype () const { return type; } 2486 get_var()2487 rchandle<WindowVarDecl> get_var () const { return var; } 2488 2489 rchandle<FLWORWinCond> operator[] (unsigned i) const 2490 { 2491 assert (i <= 2); 2492 return conditions [i]; 2493 } 2494 2495 void accept(parsenode_visitor&) const; 2496 }; 2497 2498 2499 /******************************************************************************* 2500 WindowVarDecl ::= "$" VarName TypeDeclaration? "in" ExprSingle 2501 ********************************************************************************/ 2502 class WindowVarDecl : public VarDeclWithInit 2503 { 2504 public: WindowVarDecl(const QueryLoc & loc_,rchandle<QName> varname_,rchandle<SequenceType> td_,rchandle<exprnode> init_)2505 WindowVarDecl ( 2506 const QueryLoc& loc_, 2507 rchandle<QName> varname_, 2508 rchandle<SequenceType> td_, 2509 rchandle<exprnode> init_) 2510 : 2511 VarDeclWithInit (loc_, varname_, td_, init_) 2512 { 2513 } 2514 2515 void accept(parsenode_visitor&) const; 2516 }; 2517 2518 2519 /******************************************************************************* 2520 WindowStartCondition ::= "start" WindowVars "when" ExprSingle 2521 2522 WindowEndCondition ::= "only"? "end" WindowVars "when" ExprSingle 2523 ********************************************************************************/ 2524 class FLWORWinCond : public parsenode 2525 { 2526 rchandle<WindowVars> winvars; 2527 rchandle<exprnode> val; 2528 bool isStart; 2529 bool isOnly; // only when isStart == false 2530 2531 public: 2532 FLWORWinCond ( 2533 const QueryLoc& loc_, 2534 rchandle<WindowVars> winvars_, 2535 rchandle<exprnode> val_, 2536 bool isStart_, 2537 bool isOnly_ = false) 2538 : parsenode(loc_)2539 parsenode (loc_), 2540 winvars (winvars_), 2541 val (val_), 2542 isStart (isStart_), 2543 isOnly (isOnly_) 2544 { 2545 } 2546 get_winvars()2547 rchandle<WindowVars> get_winvars () const { return winvars; } get_val()2548 rchandle<exprnode> get_val () const { return val; } is_start()2549 bool is_start () const { return isStart; } is_only()2550 bool is_only () const { return isOnly; } 2551 2552 void accept(parsenode_visitor&) const; 2553 }; 2554 2555 2556 /******************************************************************************* 2557 WindowVars ::= ("$" CurrentItem)? PositionalVar? 2558 ("previous" "$" PreviousItem)? 2559 ("next" "$" NextItem)? 2560 ********************************************************************************/ 2561 class WindowVars : public parsenode 2562 { 2563 rchandle<PositionalVar> posvar; 2564 rchandle<QName> curr; 2565 rchandle<QName> prev; 2566 rchandle<QName> next; 2567 2568 public: WindowVars(const QueryLoc & loc,rchandle<PositionalVar> posvar_,rchandle<QName> curr_,rchandle<QName> prev_,rchandle<QName> next_)2569 WindowVars( 2570 const QueryLoc& loc, 2571 rchandle<PositionalVar> posvar_, 2572 rchandle<QName> curr_, 2573 rchandle<QName> prev_, 2574 rchandle<QName> next_) 2575 : 2576 parsenode(loc), 2577 posvar(posvar_), 2578 curr(curr_), 2579 prev(prev_), 2580 next(next_) 2581 { 2582 } 2583 get_posvar()2584 rchandle<PositionalVar> get_posvar() const { return posvar; } 2585 get_curr()2586 const QName* get_curr() const { return curr.getp(); } 2587 get_prev()2588 const QName* get_prev() const { return prev.getp(); } 2589 get_next()2590 const QName* get_next() const { return next.getp(); } 2591 set_curr(rchandle<QName> curr_)2592 void set_curr(rchandle<QName> curr_) { curr = curr_; } 2593 set_posvar(rchandle<PositionalVar> posvar_)2594 void set_posvar(rchandle<PositionalVar> posvar_) { posvar = posvar_; } 2595 2596 void accept(parsenode_visitor&) const; 2597 }; 2598 2599 2600 /******************************************************************************* 2601 CountClause ::= "count" "$" VarName 2602 ********************************************************************************/ 2603 class CountClause : public FLWORClause 2604 { 2605 rchandle<QName> varname; 2606 2607 public: CountClause(const QueryLoc & loc,rchandle<QName> varname_)2608 CountClause (const QueryLoc& loc, rchandle<QName> varname_) 2609 : 2610 FLWORClause(loc), 2611 varname(varname_) 2612 { 2613 } 2614 get_varname()2615 const QName* get_varname() const { return varname.getp(); } 2616 2617 void accept(parsenode_visitor&) const; 2618 }; 2619 2620 2621 2622 /******************************************************************************* 2623 [65] QuantifiedExpr ::= ("some" | "every") QVarInDeclList "satisfies" ExprSingle 2624 ********************************************************************************/ 2625 class QuantifiedExpr : public exprnode 2626 { 2627 protected: 2628 ParseConstants::quantification_mode_t qmode; 2629 rchandle<QVarInDeclList> decl_list_h; 2630 rchandle<exprnode> expr_h; 2631 2632 public: 2633 QuantifiedExpr( 2634 const QueryLoc&, 2635 ParseConstants::quantification_mode_t qmode, 2636 rchandle<QVarInDeclList>, 2637 rchandle<exprnode>); 2638 get_qmode()2639 ParseConstants::quantification_mode_t get_qmode() const { return qmode; } 2640 get_decl_list()2641 rchandle<QVarInDeclList> get_decl_list() const { return decl_list_h; } 2642 get_expr()2643 rchandle<exprnode> get_expr() const { return expr_h; } 2644 2645 void accept(parsenode_visitor&) const; 2646 }; 2647 2648 2649 /******************************************************************************* 2650 QVarInDeclList := QVarInDecl ("," QVarInDecl)* 2651 ********************************************************************************/ 2652 class QVarInDeclList : public parsenode 2653 { 2654 protected: 2655 std::vector<rchandle<QVarInDecl> > qvar_decl_hv; 2656 2657 public: 2658 QVarInDeclList(const QueryLoc&); 2659 push_back(rchandle<QVarInDecl> decl_h)2660 void push_back(rchandle<QVarInDecl> decl_h) { qvar_decl_hv.push_back(decl_h); } 2661 2662 rchandle<QVarInDecl> operator[](int i) const { return qvar_decl_hv[i]; } 2663 size()2664 ulong size () const { return (ulong)qvar_decl_hv.size ();} 2665 2666 void accept(parsenode_visitor&) const; 2667 }; 2668 2669 2670 /******************************************************************************* 2671 QVarInDecl := "$" VarName TypeDeclaration? "in" ExprSingle 2672 ********************************************************************************/ 2673 class QVarInDecl : public parsenode 2674 { 2675 protected: 2676 rchandle<QName> name; 2677 rchandle<SequenceType> typedecl_h; 2678 rchandle<exprnode> val_h; 2679 2680 public: 2681 QVarInDecl( 2682 const QueryLoc&, 2683 rchandle<QName> name, 2684 rchandle<exprnode>); 2685 2686 QVarInDecl( 2687 const QueryLoc&, 2688 rchandle<QName> name, 2689 rchandle<SequenceType>, 2690 rchandle<exprnode>); 2691 get_name()2692 const QName* get_name() const { return name.getp(); } 2693 get_typedecl()2694 rchandle<SequenceType> get_typedecl() const { return typedecl_h; } 2695 get_val()2696 rchandle<exprnode> get_val() const { return val_h; } 2697 2698 void accept(parsenode_visitor&) const; 2699 }; 2700 2701 2702 /******************************************************************************* 2703 [71] SwitchExpr ::= "switch" "(" Expr ")" SwitchCaseClause+ "default" "return" ExprSingle 2704 ********************************************************************************/ 2705 class SwitchExpr : public exprnode 2706 { 2707 protected: 2708 rchandle<exprnode> switch_expr_h; 2709 rchandle<SwitchCaseClauseList> clause_list_h; 2710 rchandle<exprnode> default_expr_h; 2711 2712 public: 2713 SwitchExpr(const QueryLoc&, 2714 rchandle<exprnode>, 2715 rchandle<SwitchCaseClauseList>, 2716 rchandle<exprnode>); 2717 get_switch_expr()2718 rchandle<exprnode> get_switch_expr() const { return switch_expr_h; } 2719 get_clause_list()2720 rchandle<SwitchCaseClauseList> get_clause_list() const { return clause_list_h; } 2721 get_default_expr()2722 rchandle<exprnode> get_default_expr() const { return default_expr_h; } 2723 2724 void accept(parsenode_visitor&) const; 2725 }; 2726 2727 2728 class SwitchCaseClauseList : public parsenode 2729 { 2730 protected: 2731 std::vector<rchandle<SwitchCaseClause> > clause_hv; 2732 2733 public: 2734 SwitchCaseClauseList(const QueryLoc&); 2735 push_back(rchandle<SwitchCaseClause> clause_h)2736 void push_back(rchandle<SwitchCaseClause> clause_h) 2737 { clause_hv.push_back(clause_h); } 2738 2739 rchandle<SwitchCaseClause> operator[](int i) const 2740 { return clause_hv[i]; } 2741 begin()2742 std::vector<rchandle<SwitchCaseClause> >::const_iterator begin() const 2743 { return clause_hv.begin(); } 2744 end()2745 std::vector<rchandle<SwitchCaseClause> >::const_iterator end() const 2746 { return clause_hv.end(); } 2747 rbegin()2748 std::vector<rchandle<SwitchCaseClause> >::const_reverse_iterator rbegin() const 2749 { return clause_hv.rbegin(); } 2750 rend()2751 std::vector<rchandle<SwitchCaseClause> >::const_reverse_iterator rend() const 2752 { return clause_hv.rend(); } 2753 size()2754 uint32_t size () const 2755 { return (uint32_t)clause_hv.size (); } 2756 2757 void accept(parsenode_visitor&) const; 2758 }; 2759 2760 2761 /******************************************************************************* 2762 [72] SwitchCaseClause ::= ("case" SwitchCaseOperand)+ "return" ExprSingle 2763 ********************************************************************************/ 2764 class SwitchCaseClause : public exprnode 2765 { 2766 protected: 2767 rchandle<SwitchCaseOperandList> operand_list_h; 2768 rchandle<exprnode> return_expr_h; 2769 2770 public: 2771 SwitchCaseClause(const QueryLoc&, 2772 rchandle<SwitchCaseOperandList>, 2773 rchandle<exprnode>); 2774 get_operand_list()2775 rchandle<SwitchCaseOperandList> get_operand_list() const { return operand_list_h; } 2776 get_return_expr()2777 rchandle<exprnode> get_return_expr() const { return return_expr_h; } 2778 2779 void accept(parsenode_visitor&) const; 2780 }; 2781 2782 2783 class SwitchCaseOperandList : public parsenode 2784 { 2785 protected: 2786 std::vector<rchandle<exprnode> > operand_hv; 2787 2788 public: 2789 SwitchCaseOperandList(const QueryLoc&); 2790 push_back(rchandle<exprnode> operand_h)2791 void push_back(rchandle<exprnode> operand_h) 2792 { operand_hv.push_back(operand_h); } 2793 2794 rchandle<exprnode> operator[](int i) const 2795 { return operand_hv[i]; } 2796 begin()2797 std::vector<rchandle<exprnode> >::const_iterator begin() const 2798 { return operand_hv.begin(); } 2799 end()2800 std::vector<rchandle<exprnode> >::const_iterator end() const 2801 { return operand_hv.end(); } 2802 rbegin()2803 std::vector<rchandle<exprnode> >::const_reverse_iterator rbegin() const 2804 { return operand_hv.rbegin(); } 2805 rend()2806 std::vector<rchandle<exprnode> >::const_reverse_iterator rend() const 2807 { return operand_hv.rend(); } 2808 size()2809 uint32_t size () const 2810 { return (uint32_t)operand_hv.size (); } 2811 2812 void accept(parsenode_visitor&) const; 2813 }; 2814 2815 /******************************************************************************* 2816 [66] TypeswitchExpr ::= "typeswitch" "(" Expr ")" 2817 CaseClauseList 2818 "default" ("$" VarName)? "return" ExprSingle 2819 ********************************************************************************/ 2820 class TypeswitchExpr : public exprnode 2821 { 2822 protected: 2823 rchandle<exprnode> switch_expr_h; 2824 rchandle<CaseClauseList> clause_list_h; 2825 rchandle<QName> default_varname; 2826 rchandle<exprnode> default_clause_h; 2827 2828 public: 2829 TypeswitchExpr( 2830 const QueryLoc&, 2831 rchandle<exprnode>, 2832 rchandle<CaseClauseList>, 2833 rchandle<exprnode>); 2834 2835 TypeswitchExpr( 2836 const QueryLoc&, 2837 rchandle<exprnode>, 2838 rchandle<CaseClauseList>, 2839 rchandle<QName> default_varname, 2840 rchandle<exprnode>); 2841 get_switch_expr()2842 rchandle<exprnode> get_switch_expr() const { return switch_expr_h; } 2843 get_clause_list()2844 rchandle<CaseClauseList> get_clause_list() const { return clause_list_h; } 2845 get_default_varname()2846 const QName* get_default_varname() const { return default_varname.getp(); } 2847 get_default_clause()2848 rchandle<exprnode> get_default_clause() const { return default_clause_h; } 2849 2850 void accept(parsenode_visitor&) const; 2851 }; 2852 2853 2854 /******************************************************************************* 2855 CaseClauseList := CaseClause+ 2856 ********************************************************************************/ 2857 class CaseClauseList : public parsenode 2858 { 2859 protected: 2860 std::vector<rchandle<CaseClause> > clause_hv; 2861 2862 public: 2863 CaseClauseList(const QueryLoc&); 2864 push_back(rchandle<CaseClause> clause_h)2865 void push_back(rchandle<CaseClause> clause_h) 2866 { clause_hv.push_back(clause_h); } 2867 2868 rchandle<CaseClause> operator[](int i) const 2869 { return clause_hv[i]; } 2870 begin()2871 std::vector<rchandle<CaseClause> >::const_iterator begin() const 2872 { return clause_hv.begin(); } 2873 end()2874 std::vector<rchandle<CaseClause> >::const_iterator end() const 2875 { return clause_hv.end(); } 2876 rbegin()2877 std::vector<rchandle<CaseClause> >::const_reverse_iterator rbegin() const 2878 { return clause_hv.rbegin(); } 2879 rend()2880 std::vector<rchandle<CaseClause> >::const_reverse_iterator rend() const 2881 { return clause_hv.rend(); } 2882 size()2883 uint32_t size () const 2884 { return (uint32_t)clause_hv.size (); } 2885 2886 void accept(parsenode_visitor&) const; 2887 }; 2888 2889 2890 /******************************************************************************* 2891 [67] CaseClause ::= "case" ("$" VarName "as")? SequenceType "return" ExprSingle 2892 ********************************************************************************/ 2893 class CaseClause : public parsenode 2894 { 2895 protected: 2896 rchandle<QName> varname; 2897 rchandle<SequenceType> type_h; 2898 rchandle<exprnode> val_h; 2899 2900 public: 2901 CaseClause( 2902 const QueryLoc&, 2903 rchandle<QName> varname, 2904 rchandle<SequenceType>, 2905 rchandle<exprnode>); 2906 2907 CaseClause( 2908 const QueryLoc&, 2909 rchandle<SequenceType>, 2910 rchandle<exprnode>); 2911 get_varname()2912 const QName* get_varname() const { return varname.getp(); } 2913 get_type()2914 rchandle<SequenceType> get_type() const { return type_h; } 2915 get_expr()2916 rchandle<exprnode> get_expr() const { return val_h; } 2917 2918 void accept(parsenode_visitor&) const; 2919 }; 2920 2921 2922 2923 /******************************************************************************* 2924 [68] IfExpr ::= "if" "(" Expr ")" "then" ExprSingle "else" ExprSingle 2925 ********************************************************************************/ 2926 class IfExpr : public exprnode 2927 { 2928 protected: 2929 rchandle<exprnode> cond_expr_h; 2930 rchandle<exprnode> then_expr_h; 2931 rchandle<exprnode> else_expr_h; 2932 2933 public: 2934 IfExpr( 2935 const QueryLoc&, 2936 rchandle<exprnode>, 2937 rchandle<exprnode>, 2938 rchandle<exprnode>); 2939 get_cond_expr()2940 rchandle<exprnode> get_cond_expr() const { return cond_expr_h; } get_then_expr()2941 rchandle<exprnode> get_then_expr() const { return then_expr_h; } get_else_expr()2942 rchandle<exprnode> get_else_expr() const { return else_expr_h; } 2943 2944 void accept(parsenode_visitor&) const; 2945 }; 2946 2947 2948 /******************************************************************************* 2949 [69] OrExpr ::= AndExpr ( "or" AndExpr )* 2950 ********************************************************************************/ 2951 class OrExpr : public exprnode 2952 { 2953 protected: 2954 rchandle<exprnode> or_expr_h; 2955 rchandle<exprnode> and_expr_h; 2956 2957 public: 2958 OrExpr( 2959 const QueryLoc&, 2960 rchandle<exprnode>, 2961 rchandle<exprnode>); 2962 get_or_expr()2963 rchandle<exprnode> get_or_expr() const { return or_expr_h; } get_and_expr()2964 rchandle<exprnode> get_and_expr() const { return and_expr_h; } 2965 2966 virtual void accept(parsenode_visitor&) const; 2967 }; 2968 2969 2970 /******************************************************************************* 2971 [70] AndExpr ::= ComparisonExpr ( "and" ComparisonExpr )* 2972 ********************************************************************************/ 2973 class AndExpr : public exprnode 2974 { 2975 protected: 2976 rchandle<exprnode> and_expr_h; 2977 rchandle<exprnode> comp_expr_h; 2978 2979 public: 2980 AndExpr( 2981 const QueryLoc&, 2982 rchandle<exprnode>, 2983 rchandle<exprnode>); 2984 get_and_expr()2985 rchandle<exprnode> get_and_expr() const { return and_expr_h; } get_comp_expr()2986 rchandle<exprnode> get_comp_expr() const { return comp_expr_h; } 2987 2988 virtual void accept(parsenode_visitor&) const; 2989 }; 2990 2991 2992 /******************************************************************************* 2993 [71] ComparisonExpr ::= RangeExpr 2994 ((ValueComp | GeneralComp | NodeComp) RangeExpr)? 2995 2996 Note: For the full-text extension, the rule for ComparisonExpr is: 2997 2998 ComparisonExpr ::= FTContainsExpr 2999 ((ValueComp | GeneralComp | NodeComp) FTContainsExpr)? 3000 3001 ********************************************************************************/ 3002 class ComparisonExpr : public exprnode 3003 { 3004 protected: 3005 rchandle<exprnode> left_h; 3006 rchandle<exprnode> right_h; 3007 rchandle<ValueComp> valcomp_h; 3008 rchandle<GeneralComp> gencomp_h; 3009 rchandle<NodeComp> nodecomp_h; 3010 // XXX could use a union for these three 3011 3012 public: 3013 ComparisonExpr( 3014 const QueryLoc&, 3015 rchandle<ValueComp>, 3016 rchandle<exprnode>, 3017 rchandle<exprnode>); 3018 3019 ComparisonExpr( 3020 const QueryLoc&, 3021 rchandle<GeneralComp>, 3022 rchandle<exprnode>, 3023 rchandle<exprnode>); 3024 3025 ComparisonExpr( 3026 const QueryLoc&, 3027 rchandle<NodeComp>, 3028 rchandle<exprnode>, 3029 rchandle<exprnode>); 3030 get_left()3031 rchandle<exprnode> get_left() const { return left_h; } get_right()3032 rchandle<exprnode> get_right() const { return right_h; } 3033 get_valcomp()3034 rchandle<ValueComp> get_valcomp() const { return valcomp_h; } 3035 get_gencomp()3036 rchandle<GeneralComp> get_gencomp() const { return gencomp_h; } 3037 get_nodecomp()3038 rchandle<NodeComp> get_nodecomp() const { return nodecomp_h; } 3039 3040 virtual void accept(parsenode_visitor&) const; 3041 }; 3042 3043 3044 /******************************************************************************* 3045 [83] GeneralComp ::= "=" | "!=" | "<" | "<=" | ">" | ">=" 3046 ********************************************************************************/ 3047 class GeneralComp : public parsenode 3048 { 3049 protected: 3050 enum ParseConstants::gencomp_t type; 3051 3052 public: 3053 GeneralComp( 3054 const QueryLoc&, 3055 enum ParseConstants::gencomp_t); 3056 3057 GeneralComp(); 3058 get_type()3059 enum ParseConstants::gencomp_t get_type() const { return type; } 3060 3061 void accept(parsenode_visitor&) const; 3062 }; 3063 3064 3065 /******************************************************************************* 3066 [84] ValueComp ::= "eq" | "ne" | "lt" | "le" | "gt" | "ge" 3067 ********************************************************************************/ 3068 class ValueComp : public parsenode 3069 { 3070 protected: 3071 enum ParseConstants::valcomp_t type; 3072 3073 public: 3074 ValueComp( 3075 const QueryLoc&, 3076 enum ParseConstants::valcomp_t); 3077 3078 ValueComp(); 3079 get_type()3080 enum ParseConstants::valcomp_t get_type() const { return type; } 3081 3082 void accept(parsenode_visitor&) const; 3083 }; 3084 3085 3086 /******************************************************************************* 3087 [85] NodeComp ::= "is" | "<<" | ">>" 3088 ********************************************************************************/ 3089 class NodeComp : public parsenode 3090 { 3091 protected: 3092 enum ParseConstants::nodecomp_t type; 3093 3094 public: 3095 NodeComp( 3096 const QueryLoc&, 3097 enum ParseConstants::nodecomp_t); 3098 3099 NodeComp(); 3100 get_type()3101 enum ParseConstants::nodecomp_t get_type() const { return type; } 3102 3103 void accept(parsenode_visitor&) const; 3104 }; 3105 3106 3107 /******************************************************************************* 3108 FTContainsExpr := RangeExpr (FTCONTAINS FTSelection FTIgnoreOption?)? 3109 ********************************************************************************/ 3110 class FTContainsExpr : public exprnode { 3111 public: 3112 FTContainsExpr( 3113 QueryLoc const&, 3114 exprnode const *range_expr, 3115 FTSelection const*, 3116 FTIgnoreOption const* 3117 ); 3118 ~FTContainsExpr(); 3119 get_range_expr()3120 exprnode const* get_range_expr() const { return range_expr_; } get_selection()3121 FTSelection const* get_selection() const { return ftselection_; } get_ignore()3122 FTIgnoreOption const* get_ignore() const { return ftignore_; } 3123 3124 virtual void accept( parsenode_visitor& ) const; 3125 3126 private: 3127 exprnode const *const range_expr_; 3128 FTSelection const *const ftselection_; 3129 FTIgnoreOption const *const ftignore_; 3130 }; 3131 3132 /****************************************************************************** 3133 * StringConcatExpr ::= RangeExpr ( "||" RangeExpr )* 3134 *****************************************************************************/ 3135 class StringConcatExpr: public exprnode 3136 { 3137 protected: 3138 rchandle<exprnode> left; 3139 rchandle<exprnode> right; 3140 3141 public: StringConcatExpr(const QueryLoc & aLoc,rchandle<exprnode> aLeft,rchandle<exprnode> aRight)3142 StringConcatExpr( 3143 const QueryLoc& aLoc, 3144 rchandle<exprnode> aLeft, 3145 rchandle<exprnode> aRight): exprnode(aLoc), left(aLeft), right(aRight) {} 3146 get_left_expr()3147 rchandle<exprnode> get_left_expr() const { return left; } get_right_expr()3148 rchandle<exprnode> get_right_expr() const { return right; } 3149 3150 virtual void accept(parsenode_visitor&) const; 3151 }; 3152 3153 /******************************************************************************* 3154 [72] RangeExpr ::= AdditiveExpr ( "to" AdditiveExpr )? 3155 ********************************************************************************/ 3156 class RangeExpr : public exprnode 3157 { 3158 protected: 3159 rchandle<exprnode> from_expr_h; 3160 rchandle<exprnode> to_expr_h; 3161 3162 public: 3163 RangeExpr( 3164 const QueryLoc&, 3165 rchandle<exprnode>, 3166 rchandle<exprnode>); 3167 get_from_expr()3168 rchandle<exprnode> get_from_expr() const { return from_expr_h; } get_to_expr()3169 rchandle<exprnode> get_to_expr() const { return to_expr_h; } 3170 3171 virtual void accept(parsenode_visitor&) const; 3172 }; 3173 3174 3175 /******************************************************************************* 3176 [73] AdditiveExpr ::= MultiplicativeExpr ( ("+" | "-") MultiplicativeExpr )* 3177 ********************************************************************************/ 3178 class AdditiveExpr : public exprnode 3179 { 3180 protected: 3181 ParseConstants::add_op_t add_op; 3182 rchandle<exprnode> add_expr_h; 3183 rchandle<exprnode> mult_expr_h; 3184 3185 public: 3186 AdditiveExpr( 3187 const QueryLoc&, 3188 ParseConstants::add_op_t add_op, 3189 rchandle<exprnode>, 3190 rchandle<exprnode>); 3191 3192 3193 public: get_add_op()3194 ParseConstants::add_op_t get_add_op() const { return add_op; } get_add_expr()3195 rchandle<exprnode> get_add_expr() const { return add_expr_h; } get_mult_expr()3196 rchandle<exprnode> get_mult_expr() const { return mult_expr_h; } 3197 3198 public: 3199 virtual void accept(parsenode_visitor&) const; 3200 3201 }; 3202 3203 3204 /******************************************************************************* 3205 [74] MultiplicativeExpr ::= UnionExpr (("*" | "div" | "idiv" | "mod") UnionExpr)* 3206 ********************************************************************************/ 3207 class MultiplicativeExpr : public exprnode 3208 { 3209 protected: 3210 ParseConstants::mult_op_t mult_op; 3211 rchandle<exprnode> mult_expr_h; 3212 rchandle<exprnode> union_expr_h; 3213 3214 public: 3215 MultiplicativeExpr( 3216 const QueryLoc&, 3217 ParseConstants::mult_op_t, 3218 rchandle<exprnode>, 3219 rchandle<exprnode>); 3220 get_mult_expr()3221 rchandle<exprnode> get_mult_expr() const { return mult_expr_h; } get_union_expr()3222 rchandle<exprnode> get_union_expr() const { return union_expr_h; } get_mult_op()3223 ParseConstants::mult_op_t get_mult_op() const { return mult_op; } 3224 3225 virtual void accept(parsenode_visitor&) const; 3226 }; 3227 3228 3229 /******************************************************************************* 3230 [75] UnionExpr ::= IntersectExceptExpr (("union" | "|") IntersectExceptExpr)* 3231 ********************************************************************************/ 3232 class UnionExpr : public exprnode 3233 { 3234 protected: 3235 rchandle<exprnode> union_expr_h; 3236 rchandle<exprnode> intex_expr_h; 3237 3238 public: 3239 UnionExpr( 3240 const QueryLoc&, 3241 rchandle<exprnode>, 3242 rchandle<exprnode>); 3243 union_expr()3244 rchandle<exprnode> union_expr() const { return union_expr_h; } intex_expr()3245 rchandle<exprnode> intex_expr() const { return intex_expr_h; } 3246 3247 virtual void accept(parsenode_visitor&) const; 3248 }; 3249 3250 3251 /******************************************************************************* 3252 [76] IntersectExceptExpr ::= InstanceofExpr 3253 (("intersect" | "except") InstanceofExpr)* 3254 ********************************************************************************/ 3255 class IntersectExceptExpr : public exprnode 3256 { 3257 protected: 3258 enum ParseConstants::intex_op_t intex_op; 3259 rchandle<exprnode> intex_expr_h; 3260 rchandle<exprnode> instof_expr_h; 3261 3262 public: 3263 IntersectExceptExpr( 3264 const QueryLoc&, 3265 ParseConstants::intex_op_t, 3266 rchandle<exprnode>, 3267 rchandle<exprnode>); 3268 get_intex_expr()3269 rchandle<exprnode> get_intex_expr() const { return intex_expr_h; } get_intex_op()3270 enum ParseConstants::intex_op_t get_intex_op() const { return intex_op; } get_instof_expr()3271 rchandle<exprnode> get_instof_expr() const { return instof_expr_h; } 3272 3273 virtual void accept(parsenode_visitor&) const; 3274 }; 3275 3276 3277 /******************************************************************************* 3278 [77] InstanceofExpr ::= TreatExpr ( "instance" "of" SequenceType )? 3279 ********************************************************************************/ 3280 class InstanceofExpr : public exprnode 3281 { 3282 protected: 3283 rchandle<exprnode> treat_expr_h; 3284 rchandle<SequenceType> seqtype_h; 3285 3286 public: 3287 InstanceofExpr( 3288 const QueryLoc&, 3289 rchandle<exprnode>, 3290 rchandle<SequenceType>); 3291 get_treat_expr()3292 rchandle<exprnode> get_treat_expr() const { return treat_expr_h; } get_seqtype()3293 rchandle<SequenceType> get_seqtype() const { return seqtype_h; } 3294 3295 virtual void accept(parsenode_visitor&) const; 3296 }; 3297 3298 3299 /******************************************************************************* 3300 [78] TreatExpr ::= CastableExpr ( "treat" "as" SequenceType )? 3301 ********************************************************************************/ 3302 class TreatExpr : public exprnode 3303 { 3304 protected: 3305 rchandle<exprnode> castable_expr_h; 3306 rchandle<SequenceType> seqtype_h; 3307 3308 public: 3309 TreatExpr( 3310 const QueryLoc&, 3311 rchandle<exprnode>, 3312 rchandle<SequenceType>); 3313 get_castable_expr()3314 rchandle<exprnode> get_castable_expr() const { return castable_expr_h; } get_seqtype()3315 rchandle<SequenceType> get_seqtype() const { return seqtype_h; } 3316 3317 virtual void accept(parsenode_visitor&) const; 3318 }; 3319 3320 3321 /******************************************************************************* 3322 [79] CastableExpr ::= CastExpr ( "castable" "as" SingleType )? 3323 ********************************************************************************/ 3324 class CastableExpr : public exprnode 3325 { 3326 protected: 3327 rchandle<exprnode> cast_expr_h; 3328 rchandle<SingleType> singletype_h; 3329 3330 public: 3331 CastableExpr( 3332 const QueryLoc&, 3333 rchandle<exprnode>, 3334 rchandle<SingleType>); 3335 cast_expr()3336 rchandle<exprnode> cast_expr() const { return cast_expr_h; } singletype()3337 rchandle<SingleType> singletype() const { return singletype_h; } 3338 3339 virtual void accept(parsenode_visitor&) const; 3340 }; 3341 3342 3343 /******************************************************************************* 3344 [80] CastExpr ::= UnaryExpr ( "cast" "as" SingleType )? 3345 ********************************************************************************/ 3346 class CastExpr : public exprnode 3347 { 3348 protected: 3349 rchandle<exprnode> unary_expr_h; 3350 rchandle<SingleType> singletype_h; 3351 3352 public: 3353 CastExpr( 3354 const QueryLoc&, 3355 rchandle<exprnode>, 3356 rchandle<SingleType>); 3357 get_unary_expr()3358 rchandle<exprnode> get_unary_expr() const { return unary_expr_h; } get_singletype()3359 rchandle<SingleType> get_singletype() const { return singletype_h; } 3360 3361 virtual void accept(parsenode_visitor&) const; 3362 }; 3363 3364 3365 /******************************************************************************* 3366 [81] UnaryExpr ::= SignList? ValueExpr 3367 ********************************************************************************/ 3368 class UnaryExpr : public exprnode 3369 { 3370 protected: 3371 rchandle<exprnode> value_expr_h; 3372 rchandle<SignList> signlist_h; 3373 3374 public: 3375 UnaryExpr( 3376 const QueryLoc&, 3377 rchandle<SignList>, 3378 rchandle<exprnode>); 3379 get_value_expr()3380 rchandle<exprnode> get_value_expr() const { return value_expr_h; } get_signlist()3381 rchandle<SignList> get_signlist() const { return signlist_h; } 3382 3383 virtual void accept(parsenode_visitor&) const; 3384 }; 3385 3386 3387 /******************************************************************************* 3388 SignList := ("-" | "+")+ 3389 ********************************************************************************/ 3390 class SignList : public parsenode 3391 { 3392 protected: 3393 bool sign; 3394 3395 public: 3396 SignList(const QueryLoc&, bool sign); 3397 get_sign()3398 bool get_sign() const { return sign; } 3399 negate()3400 void negate() { sign = !sign; } 3401 3402 void accept(parsenode_visitor&) const; 3403 }; 3404 3405 3406 /******************************************************************************* 3407 [82] ValueExpr ::= ValidateExpr | SimpleMapExpr | ExtensionExpr 3408 ********************************************************************************/ 3409 3410 3411 /******************************************************************************* 3412 [86] ValidateExpr ::= "validate" (ValidationMode | ("as" TypeName))? "{" Expr "}" 3413 [87] ValidationMode ::= "lax" | "strict" 3414 ********************************************************************************/ 3415 class ValidateExpr : public exprnode 3416 { 3417 protected: 3418 enum ParseConstants::validation_mode_t valmode; 3419 rchandle<exprnode> expr_h; 3420 rchandle<QName> type_name; 3421 3422 public: 3423 ValidateExpr( 3424 const QueryLoc&, 3425 zstring const& _valmode, 3426 rchandle<exprnode>); 3427 3428 ValidateExpr( 3429 const QueryLoc&, 3430 rchandle<QName> _valmode, 3431 rchandle<exprnode>); 3432 get_expr()3433 rchandle<exprnode> get_expr() const { return expr_h; } get_type_name()3434 rchandle<QName> get_type_name() const { return type_name; } get_valmode()3435 enum ParseConstants::validation_mode_t get_valmode() const { return valmode; } 3436 3437 void accept(parsenode_visitor&) const; 3438 }; 3439 3440 3441 /******************************************************************************* 3442 [88] ExtensionExpr ::= PragmaList "{" Expr? "}" 3443 ********************************************************************************/ 3444 class ExtensionExpr : public exprnode 3445 { 3446 3447 public: 3448 ExtensionExpr( 3449 const QueryLoc&, 3450 rchandle<PragmaList> const&, 3451 rchandle<exprnode> const&); 3452 get_pragma_list()3453 rchandle<PragmaList> const& get_pragma_list() const { return pragmas_; } get_expr()3454 rchandle<exprnode> const& get_expr() const { return expr_; } 3455 3456 void accept(parsenode_visitor&) const; 3457 3458 private: 3459 rchandle<PragmaList> pragmas_; 3460 rchandle<exprnode> expr_; 3461 }; 3462 3463 3464 /******************************************************************************* 3465 PragmaList ::= Pragma | PragmaList Pragma 3466 ********************************************************************************/ 3467 class PragmaList : public parsenode 3468 { 3469 public: 3470 typedef std::list< rchandle<Pragma> > list_t; 3471 3472 PragmaList(const QueryLoc&); 3473 push_back(Pragma * p)3474 void push_back( Pragma *p ) { pragmas_.push_back( p ); } get_pragmas()3475 list_t const& get_pragmas() const { return pragmas_; } 3476 3477 void accept(parsenode_visitor&) const; 3478 3479 private: 3480 list_t pragmas_; 3481 }; 3482 3483 3484 /******************************************************************************* 3485 [89] Pragma ::= "(#" S? QName (S PragmaContents)? "#)" // ws: explicitXQ 3486 [90] PragmaContents ::= (Char* - (Char* '#)' Char*)) 3487 ********************************************************************************/ 3488 class Pragma : public parsenode 3489 { 3490 protected: 3491 rchandle<QName> name_h; 3492 zstring const pragma_lit; 3493 3494 public: 3495 Pragma( 3496 const QueryLoc&, 3497 rchandle<QName>, 3498 zstring const &pragma_lit); 3499 get_name()3500 rchandle<QName> get_name() const { return name_h; } get_pragma_lit()3501 zstring const& get_pragma_lit() const { return pragma_lit; } 3502 3503 void accept(parsenode_visitor&) const; 3504 }; 3505 3506 3507 /******************************************************************************* 3508 SimpleMapExpr :: PathExpr | 3509 SimpleMapExpr "!" PathExpr 3510 3511 This creates a left-deep tree of SimpleMapExpr nodes: the right child of each 3512 such node is a PathExpr, and the left child is another SimpleMapExpr except 3513 from the left-most SimpleMapExpr node, whose left chils is a PathExpr. 3514 ********************************************************************************/ 3515 class SimpleMapExpr : public exprnode 3516 { 3517 protected: 3518 rchandle<exprnode> left_expr_h; 3519 rchandle<exprnode> right_expr_h; 3520 3521 public: 3522 SimpleMapExpr( 3523 const QueryLoc&, 3524 rchandle<exprnode>, 3525 rchandle<exprnode> 3526 ); 3527 get_left_expr()3528 rchandle<exprnode> get_left_expr() const { return left_expr_h; } 3529 get_right_expr()3530 rchandle<exprnode> get_right_expr() const { return right_expr_h; } 3531 3532 void accept(parsenode_visitor&) const; 3533 }; 3534 3535 3536 /******************************************************************************* 3537 3538 [91] PathExpr ::= ("/" RelativePathExpr?) | 3539 ("//" RelativePathExpr) | 3540 RelativePathExpr // gn: leading-lone-slashXQ 3541 3542 [92] RelativePathExpr ::= StepExpr (("/" | "//") StepExpr)* 3543 3544 [93] StepExpr ::= FilterExpr | AxisStep 3545 3546 [94] AxisStep ::= (ReverseStep | ForwardStep) PredicateList 3547 3548 [95] ForwardStep ::= (ForwardAxis NodeTest) | AbbrevForwardStep 3549 3550 [96] ForwardAxis ::= ("child" "::") | 3551 ("descendant" "::") | 3552 ("attribute" "::") | 3553 ("self" "::") | 3554 ("descendant-or-self" "::") | 3555 ("following-sibling" "::") | 3556 ("following" "::") 3557 3558 [97] AbbrevForwardStep ::= "@"? NodeTest 3559 3560 [98] ReverseStep ::= (ReverseAxis NodeTest) | AbbrevReverseStep 3561 3562 [99] ReverseAxis ::= ("parent" "::") | 3563 ("ancestor" "::") | 3564 ("preceding-sibling" "::") | 3565 ("preceding" "::") | 3566 ("ancestor-or-self" "::") 3567 3568 [100] AbbrevReverseStep ::= ".." 3569 3570 [101] NodeTest ::= KindTest | NameTest 3571 3572 [102] NameTest ::= QName | Wildcard 3573 3574 [103] Wildcard ::= "*" | (NCName ":" "*") | ("*" ":" NCName) 3575 3576 [104] FilterExpr ::= PrimaryExpr PredicateList 3577 3578 [105] PredicateList ::= Predicate* 3579 3580 [106] Predicate ::= "[" Expr "]" 3581 ********************************************************************************/ 3582 class PathExpr : public exprnode 3583 { 3584 protected: 3585 enum ParseConstants::pathtype_t type; 3586 rchandle<exprnode> relpath_expr_h; 3587 3588 public: 3589 PathExpr( 3590 const QueryLoc&, 3591 enum ParseConstants::pathtype_t type, 3592 rchandle<exprnode>); 3593 get_type()3594 enum ParseConstants::pathtype_t get_type() const { return type; } 3595 get_relpath_expr()3596 rchandle<exprnode> get_relpath_expr() const { return relpath_expr_h; } 3597 3598 void accept(parsenode_visitor&) const; 3599 }; 3600 3601 3602 /******************************************************************************* 3603 3604 [92] RelativePathExpr ::= StepExpr (("/" | "//") StepExpr)* 3605 3606 Note: If a RelativePathExpr consists of a single StepExpr, a RelativePathExpr 3607 node is generated whose left child is a ContextItemExpr and its right child 3608 is the StepExpr. 3609 3610 ********************************************************************************/ 3611 class RelativePathExpr : public exprnode 3612 { 3613 protected: 3614 enum ParseConstants::steptype_t step_type; 3615 rchandle<exprnode> step_expr_h; 3616 rchandle<exprnode> relpath_expr_h; 3617 bool is_implicit_b; 3618 3619 public: 3620 RelativePathExpr( 3621 const QueryLoc&, 3622 ParseConstants::steptype_t, 3623 rchandle<exprnode>, 3624 rchandle<exprnode>, 3625 bool implicit); 3626 get_step_type()3627 enum ParseConstants::steptype_t get_step_type() const { return step_type; } 3628 get_step_expr()3629 exprnode* get_step_expr() const { return step_expr_h.getp(); } 3630 get_relpath_expr()3631 exprnode* get_relpath_expr() const { return relpath_expr_h.getp(); } 3632 is_implicit()3633 bool is_implicit() const { return is_implicit_b; } 3634 3635 virtual void accept(parsenode_visitor&) const; 3636 }; 3637 3638 3639 /******************************************************************************* 3640 [93] StepExpr ::= FilterExpr | AxisStep 3641 ********************************************************************************/ 3642 3643 3644 /******************************************************************************* 3645 [94] AxisStep ::= (ReverseStep | ForwardStep) PredicateList 3646 ********************************************************************************/ 3647 class AxisStep : public exprnode 3648 { 3649 protected: 3650 rchandle<ForwardStep> forward_step_h; 3651 rchandle<ReverseStep> reverse_step_h; 3652 rchandle<PredicateList> predicate_list_h; 3653 3654 public: 3655 AxisStep( 3656 const QueryLoc&, 3657 rchandle<ForwardStep>, 3658 rchandle<PredicateList>); 3659 3660 AxisStep( 3661 const QueryLoc&, 3662 rchandle<ReverseStep>, 3663 rchandle<PredicateList>); 3664 get_forward_step()3665 ForwardStep* get_forward_step() const { return forward_step_h.getp(); } 3666 get_reverse_step()3667 ReverseStep* get_reverse_step() const { return reverse_step_h.getp(); } 3668 get_predicate_list()3669 PredicateList* get_predicate_list() const { return predicate_list_h.getp(); } 3670 3671 enum ParseConstants::axis_kind_t get_axis_kind() const; 3672 3673 virtual void accept(parsenode_visitor&) const; 3674 }; 3675 3676 3677 /******************************************************************************* 3678 [95] ForwardStep ::= (ForwardAxis NodeTest) | AbbrevForwardStep 3679 ********************************************************************************/ 3680 class ForwardStep : public parsenode 3681 { 3682 protected: 3683 rchandle<ForwardAxis> theForwardAxis; 3684 rchandle<parsenode> node_test_h; 3685 rchandle<AbbrevForwardStep> theAbbrevStep; 3686 3687 public: 3688 ForwardStep( 3689 const QueryLoc& loc, 3690 rchandle<ForwardAxis> axis, 3691 rchandle<parsenode> node_test); 3692 3693 ForwardStep( 3694 const QueryLoc&, 3695 rchandle<AbbrevForwardStep>); 3696 get_forward_axis()3697 ForwardAxis* get_forward_axis() const { return theForwardAxis.getp(); } 3698 get_node_test()3699 parsenode* get_node_test() const { return node_test_h.getp(); } 3700 get_abbrev_step()3701 AbbrevForwardStep* get_abbrev_step() const { return theAbbrevStep.getp(); } 3702 3703 enum ParseConstants::axis_kind_t get_axis_kind() const; 3704 3705 void accept(parsenode_visitor&) const; 3706 }; 3707 3708 3709 /******************************************************************************* 3710 [96] ForwardAxis ::= ("child" "::") | 3711 ("descendant" "::") | 3712 ("attribute" "::") | 3713 ("self" "::") | 3714 ("descendant-or-self" "::") | 3715 ("following-sibling" "::") | 3716 ("following" "::") 3717 ********************************************************************************/ 3718 class ForwardAxis : public parsenode 3719 { 3720 protected: 3721 enum ParseConstants::axis_kind_t axis; 3722 3723 public: 3724 ForwardAxis( 3725 const QueryLoc&, 3726 enum ParseConstants::axis_kind_t); 3727 get_axis()3728 enum ParseConstants::axis_kind_t get_axis() const { return axis; } 3729 3730 void accept(parsenode_visitor&) const; 3731 }; 3732 3733 3734 /******************************************************************************* 3735 [97] AbbrevForwardStep ::= "@"? NodeTest 3736 ********************************************************************************/ 3737 class AbbrevForwardStep : public parsenode 3738 { 3739 protected: 3740 rchandle<parsenode> node_test_h; 3741 bool attr_b; 3742 3743 public: 3744 AbbrevForwardStep( 3745 const QueryLoc&, 3746 rchandle<parsenode>, 3747 bool attr_b); 3748 get_node_test()3749 const parsenode* get_node_test() const { return node_test_h.getp(); } 3750 get_attr_bit()3751 bool get_attr_bit() const { return attr_b; } 3752 3753 void accept(parsenode_visitor&) const; 3754 }; 3755 3756 3757 /******************************************************************************* 3758 [98] ReverseStep ::= (ReverseAxis NodeTest) | AbbrevReverseStep 3759 ********************************************************************************/ 3760 class ReverseStep : public parsenode 3761 { 3762 protected: 3763 rchandle<ReverseAxis> axis_h; 3764 rchandle<parsenode> node_test_h; 3765 3766 public: 3767 ReverseStep( 3768 const QueryLoc&, 3769 rchandle<ReverseAxis>, 3770 rchandle<parsenode>); 3771 get_axis()3772 rchandle<ReverseAxis> get_axis() const { return axis_h; } 3773 3774 enum ParseConstants::axis_kind_t get_axis_kind() const; 3775 get_node_test()3776 rchandle<parsenode> get_node_test() const { return node_test_h; } 3777 3778 void accept(parsenode_visitor&) const; 3779 }; 3780 3781 3782 /******************************************************************************* 3783 [99] ReverseAxis ::= ("parent" "::") | 3784 ("ancestor" "::") | 3785 ("preceding-sibling" "::") | 3786 ("preceding" "::") | 3787 ("ancestor-or-self" "::") 3788 ********************************************************************************/ 3789 class ReverseAxis : public parsenode 3790 { 3791 protected: 3792 enum ParseConstants::axis_kind_t axis; 3793 3794 public: 3795 ReverseAxis( 3796 const QueryLoc&, 3797 enum ParseConstants::axis_kind_t); 3798 get_axis()3799 enum ParseConstants::axis_kind_t get_axis() const { return axis; } 3800 3801 void accept(parsenode_visitor&) const; 3802 }; 3803 3804 3805 /******************************************************************************* 3806 [100] AbbrevReverseStep ::= ".." (folded into [98]) 3807 ********************************************************************************/ 3808 3809 3810 /******************************************************************************* 3811 [101] NodeTest ::= KindTest | NameTest 3812 ********************************************************************************/ 3813 3814 3815 /******************************************************************************* 3816 [102] NameTest ::= QName | Wildcard 3817 3818 qname_h and wild_h cannot both be non-NULL 3819 ********************************************************************************/ 3820 class NameTest : public parsenode 3821 { 3822 protected: 3823 rchandle<QName> theQName; 3824 rchandle<Wildcard> theWildcard; 3825 3826 public: 3827 NameTest(const QueryLoc& l, rchandle<QName> n); 3828 3829 NameTest(const QueryLoc& l, rchandle<Wildcard> w); 3830 getQName()3831 rchandle<QName> getQName() const { return theQName; } 3832 getWildcard()3833 rchandle<Wildcard> getWildcard() const { return theWildcard; } 3834 3835 void accept(parsenode_visitor&) const; 3836 }; 3837 3838 3839 /******************************************************************************* 3840 [103] Wildcard ::= "*" | (NCName ":" "*") | ("*" ":" NCName) 3841 3842 At least one of thePrefix and theLocalName will be the empty string. 3843 ********************************************************************************/ 3844 class Wildcard : public parsenode 3845 { 3846 protected: 3847 ParseConstants::wildcard_t theKind; 3848 zstring const theNsOrPrefix; 3849 zstring const theLocalName; 3850 bool theIsEQnameMatch; // If true, then theNsOrPrefix holds a namespace instead of a prefix. 3851 // This is used for EQName-style element wildcard matches. 3852 3853 public: 3854 Wildcard( 3855 const QueryLoc& loc_, 3856 const zstring& nsOrPrefix, 3857 const zstring& lname, 3858 enum ParseConstants::wildcard_t type, 3859 bool isEQnameMatch); 3860 getKind()3861 ParseConstants::wildcard_t getKind() const { return theKind; } 3862 getNsOrPrefix()3863 const zstring& getNsOrPrefix() const { return theNsOrPrefix; } 3864 getLocalName()3865 const zstring& getLocalName() const { return theLocalName; } 3866 isEQnameMatch()3867 bool isEQnameMatch() const { return theIsEQnameMatch; } 3868 3869 void accept(parsenode_visitor&) const; 3870 }; 3871 3872 3873 /******************************************************************************* 3874 [104] FilterExpr ::= PrimaryExpr PredicateList 3875 ********************************************************************************/ 3876 class FilterExpr : public exprnode 3877 { 3878 protected: 3879 rchandle<exprnode> primary_h; 3880 rchandle<PredicateList> pred_list_h; 3881 bool theIsPathStep; 3882 3883 public: 3884 FilterExpr( 3885 const QueryLoc&, 3886 rchandle<exprnode>, 3887 rchandle<PredicateList>); 3888 get_primary()3889 rchandle<exprnode> get_primary() const { return primary_h; } 3890 get_pred_list()3891 rchandle<PredicateList> get_pred_list() const { return pred_list_h; } 3892 isPathStep()3893 bool isPathStep() const { return theIsPathStep; } 3894 setIsPathStep()3895 void setIsPathStep() { theIsPathStep = true; } 3896 3897 void accept(parsenode_visitor&) const; 3898 }; 3899 3900 3901 /******************************************************************************* 3902 [105] PredicateList ::= Predicate* 3903 ********************************************************************************/ 3904 class PredicateList : public parsenode 3905 { 3906 protected: 3907 std::vector<rchandle<exprnode> > pred_hv; 3908 3909 public: 3910 PredicateList(const QueryLoc&); 3911 push_back(rchandle<exprnode> pred_h)3912 void push_back(rchandle<exprnode> pred_h) { pred_hv.push_back(pred_h); } 3913 3914 rchandle<exprnode> operator[](int i) { return pred_hv[i]; } 3915 size()3916 ulong size () const { return (ulong)pred_hv.size (); } 3917 3918 void accept(parsenode_visitor&) const; 3919 }; 3920 3921 3922 /******************************************************************************* 3923 [106] Predicate ::= "[" Expr "]" 3924 ********************************************************************************/ 3925 3926 3927 /******************************************************************************* 3928 [107] PrimaryExpr ::= Literal | 3929 VarRef | 3930 ParenthesizedExpr | 3931 ContextItemExpr | 3932 FunctionCall | 3933 OrderedExpr | 3934 UnorderedExpr | 3935 Constructor 3936 ********************************************************************************/ 3937 3938 3939 /******************************************************************************* 3940 [108] Literal ::= NumericLiteral | StringLiteral 3941 [126] Literal ::= NumericLiteral | StringLiteral (XQuery 3.0) 3942 3943 ********************************************************************************/ 3944 // Used by Annotations classes 3945 class Literal : public exprnode 3946 { 3947 public: 3948 typedef enum 3949 { 3950 NUMERIC_LITERAL = 0, 3951 STRING_LITERAL = 1 3952 } LITERAL_TYPE; 3953 3954 protected: 3955 rchandle<NumericLiteral> numeric_literal; 3956 rchandle<StringLiteral> string_literal; 3957 LITERAL_TYPE type; // =0 -> Numeric, =1 -> String 3958 3959 3960 public: 3961 Literal(exprnode* expression); 3962 get_type()3963 LITERAL_TYPE get_type() const { return type; }; get_numeric_literal()3964 rchandle<NumericLiteral> get_numeric_literal() const { return numeric_literal; } get_string_literal()3965 rchandle<StringLiteral> get_string_literal() const { return string_literal; } 3966 3967 void accept(parsenode_visitor&) const; 3968 }; 3969 3970 3971 /******************************************************************************* 3972 [181] StringLiteral ::= ('"' (PredefinedEntityRef | 3973 CharRef | 3974 EscapeQuot | 3975 [^"&])* 3976 '"') | 3977 ("'" (PredefinedEntityRef | 3978 CharRef | 3979 EscapeApos | 3980 [^'&])* 3981 "'") 3982 3983 [182] PredefinedEntityRef ::= "&" ("lt" | "gt" | "amp" | "quot" | "apos") ";" 3984 3985 [183] EscapeQuot ::= '""' 3986 3987 [184] EscapeApos ::= "''" 3988 3989 [190] CharRef ::= [http://www.w3.org/TR/REC-xml#NT-CharRef] 3990 ********************************************************************************/ 3991 class StringLiteral : public exprnode 3992 { 3993 protected: 3994 zstring const strval; 3995 3996 public: 3997 StringLiteral( 3998 const QueryLoc&, 3999 zstring const&); 4000 get_strval()4001 zstring const& get_strval() const { return strval; } 4002 4003 void accept(parsenode_visitor&) const; 4004 }; 4005 4006 4007 /******************************************************************************* 4008 [109] NumericLiteral ::= IntegerLiteral | DecimalLiteral | DoubleLiteral 4009 4010 [178] IntegerLiteral ::= Digits 4011 4012 [179] DecimalLiteral :: ("." Digits) | (Digits "." [0-9]*) 4013 4014 [180] DoubleLiteral ::= (("." Digits) | (Digits ("." [0-9]*)?)) [eE] [+-]? Digits 4015 ********************************************************************************/ 4016 class NumericLiteral : public exprnode 4017 { 4018 protected: 4019 class ValueBase 4020 { 4021 public: ~ValueBase()4022 virtual ~ValueBase () {} 4023 4024 virtual std::string toString () const = 0; 4025 }; 4026 4027 template<typename T> class Value : public ValueBase 4028 { 4029 public: 4030 T data; 4031 Value(const T & x)4032 Value (const T& x) : data (x) {} 4033 toString()4034 std::string toString () const { return ztd::to_string (data); } 4035 }; 4036 4037 protected: 4038 enum ParseConstants::numeric_type_t type; 4039 4040 ValueBase * theValue; 4041 4042 protected: NumericLiteral(const QueryLoc & loc_,ParseConstants::numeric_type_t type_,ValueBase * val)4043 NumericLiteral( 4044 const QueryLoc& loc_, 4045 ParseConstants::numeric_type_t type_, 4046 ValueBase* val) 4047 : 4048 exprnode (loc_), 4049 type (type_), 4050 theValue (val) 4051 { 4052 } 4053 4054 public: ~NumericLiteral()4055 ~NumericLiteral () { delete theValue; } 4056 new_literal(const QueryLoc & loc_,ParseConstants::numeric_type_t type_,const T & x)4057 template<typename T> static NumericLiteral* new_literal( 4058 const QueryLoc& loc_, 4059 ParseConstants::numeric_type_t type_, 4060 const T& x) 4061 { 4062 return new NumericLiteral(loc_, type_, new Value<T>(x)); 4063 } 4064 get_type()4065 enum ParseConstants::numeric_type_t get_type() const { return type; } 4066 toString()4067 std::string toString () const { return theValue->toString (); } 4068 get()4069 template<typename T> T get() const { return static_cast<Value<T>*>(theValue)->data; } 4070 4071 void accept(parsenode_visitor&) const; 4072 }; 4073 4074 4075 /******************************************************************************* 4076 [110] VarRef ::= "$" VarName 4077 [111] VarName ::= QName 4078 ********************************************************************************/ 4079 class VarRef : public exprnode 4080 { 4081 protected: 4082 rchandle<QName> theName; 4083 4084 public: 4085 VarRef(const QueryLoc&, rchandle<QName> name); 4086 get_name()4087 const QName* get_name() const { return theName.getp(); } 4088 4089 void accept(parsenode_visitor&) const; 4090 }; 4091 4092 4093 /******************************************************************************* 4094 [112] ParenthesizedExpr ::= "(" Expr? ")" 4095 ********************************************************************************/ 4096 class ParenthesizedExpr : public exprnode 4097 { 4098 protected: 4099 rchandle<exprnode> expr_h; 4100 4101 public: 4102 ParenthesizedExpr( 4103 const QueryLoc&, 4104 rchandle<exprnode>); 4105 get_expr()4106 rchandle<exprnode> get_expr() const { return expr_h; } 4107 4108 void accept(parsenode_visitor&) const; 4109 }; 4110 4111 4112 /******************************************************************************* 4113 [113] ContextItemExpr ::= "." 4114 ********************************************************************************/ 4115 class ContextItemExpr : public exprnode 4116 { 4117 protected: 4118 bool placeholder; 4119 4120 public: 4121 ContextItemExpr(const QueryLoc&, bool _placeholder = false); 4122 is_placeholder()4123 bool is_placeholder() const { return placeholder; } 4124 4125 void accept(parsenode_visitor&) const; 4126 }; 4127 4128 4129 /******************************************************************************* 4130 [114] OrderedExpr ::= "ordered" "{" Expr "}" 4131 ********************************************************************************/ 4132 class OrderedExpr : public exprnode 4133 { 4134 protected: 4135 rchandle<exprnode> expr_h; 4136 4137 public: 4138 OrderedExpr( 4139 const QueryLoc&, 4140 rchandle<exprnode>); 4141 get_expr()4142 rchandle<exprnode> get_expr() const { return expr_h; } 4143 4144 void accept(parsenode_visitor&) const; 4145 }; 4146 4147 4148 /******************************************************************************* 4149 [115] UnorderedExpr ::= "unordered" "{" Expr "}" 4150 ********************************************************************************/ 4151 class UnorderedExpr : public exprnode 4152 { 4153 protected: 4154 rchandle<exprnode> expr_h; 4155 4156 public: 4157 UnorderedExpr( 4158 const QueryLoc&, 4159 rchandle<exprnode>); 4160 get_expr()4161 rchandle<exprnode> get_expr() const { return expr_h; } 4162 4163 void accept(parsenode_visitor&) const; 4164 }; 4165 4166 4167 /******************************************************************************* 4168 [116] FunctionCall ::= QName "(" ArgList? ")" 4169 ********************************************************************************/ 4170 class FunctionCall : public exprnode 4171 { 4172 protected: 4173 rchandle<QName> fname_h; 4174 rchandle<ArgList> arg_list_h; 4175 4176 public: 4177 FunctionCall( 4178 const QueryLoc&, 4179 rchandle<QName>, 4180 rchandle<ArgList>); 4181 get_fname()4182 rchandle<QName> get_fname() const { return fname_h; } 4183 get_arg_list()4184 rchandle<ArgList> get_arg_list() const { return arg_list_h; } 4185 4186 void accept(parsenode_visitor&) const; 4187 }; 4188 4189 4190 /******************************************************************************* 4191 [116a] ArgList := ExprSingle ("," ExprSingle)* 4192 ********************************************************************************/ 4193 class ArgList : public parsenode 4194 { 4195 protected: 4196 std::vector<rchandle<exprnode> > arg_hv; 4197 4198 public: 4199 ArgList(const QueryLoc&); 4200 push_back(rchandle<exprnode> arg_h)4201 void push_back(rchandle<exprnode> arg_h) { arg_hv.push_back(arg_h); } 4202 4203 rchandle<exprnode> operator[](int i) const { return arg_hv[i]; } 4204 size()4205 ulong size() const { return (ulong)arg_hv.size (); } 4206 4207 void accept(parsenode_visitor&) const; 4208 }; 4209 4210 4211 /******************************************************************************* 4212 4213 [117] Constructor ::= DirectConstructor | ComputedConstructor 4214 4215 [118] DirectConstructor ::= DirElemConstructor | 4216 DirCommentConstructor | 4217 DirPIConstructor 4218 4219 [119] DirElemConstructor ::= "<" QName DirAttributeList? 4220 ("/>" | (">" DirElemContentList? "</" QName S? ">")) 4221 4222 [120] DirAttributeList ::= DirAttr | DirAttributeList DirAttr 4223 4224 [120a] DirAttr ::= (S (QName S? "=" S? DirAttributeValue) 4225 4226 [121] DirAttributeValue ::= '"' QuoteAttrContentList? '"' | 4227 "'" AposAttrContentList? "'" 4228 4229 [121a] QuoteAttrContentList ::= QuotAttrValueContent+ 4230 4231 [121b] AposAttrContentList ::= AposAttrValueContent+ 4232 4233 [122] QuotAttrValueContent ::= EscapeQuot | QuotAttrContentChar | CommonContent 4234 4235 [123] AposAttrValueContent ::= EscapeApos | AposAttrContentChar | CommonContent 4236 4237 [119a] DirElemContentList ::= DirElemContent+ 4238 4239 [124] DirElemContent ::= DirectConstructor | 4240 CDataSection | 4241 CommonContent | 4242 ElementContentChar 4243 4244 [125] CommonContent ::= PredefinedEntityRef | CharRef | "{{" | "}}" | EnclosedExpr 4245 4246 [126] DirCommentConstructor ::= "<!--" DirCommentContents "-->" 4247 4248 [127] DirCommentContents ::= ((Char - '-') | ('-' (Char - '-')))* 4249 4250 [128] DirPIConstructor ::= "<?" PITarget (S DirPIContents)? "?>" 4251 4252 [129] DirPIContents ::= (Char* - (Char* '?>' Char*)) 4253 4254 [130] CDataSection ::= "<![CDATA[" CDataSectionContents "]]>" 4255 4256 [131] CDataSectionContents ::= (Char* - (Char* ']]>' Char*)) 4257 4258 [132] ComputedConstructor ::= CompDocConstructor | 4259 CompElemConstructor | 4260 CompAttrConstructor | 4261 CompNamespaceConstructor | 4262 CompTextConstructor | 4263 CompCommentConstructor | 4264 CompPIConstructor 4265 4266 [133] CompDocConstructor ::= "document" "{" Expr "}" 4267 4268 [134] CompElemConstructor ::= "element" (QName | ("{" Expr "}")) "{" ContentExpr? "}" 4269 4270 [135] ContentExpr ::= Expr 4271 4272 [136] CompAttrConstructor ::= "attribute" (QName | ("{" Expr "}")) "{" Expr? "}" 4273 4274 [137] CompNamespaceConstructor ::= "namespace" (Prefix | ("{" PrefixExpr "}")) 4275 "{" URIExpr? "}" 4276 4277 [138] PrefixExpr ::= Expr 4278 4279 [139] URIExpr ::= Expr 4280 4281 [140] CompTextConstructor ::= "text" "{" Expr "}" 4282 4283 [141] CompCommentConstructor ::= "comment" "{" Expr "}" 4284 4285 [142] CompPIConstructor ::= "processing-instruction" (NCName | ("{" Expr "}")) 4286 "{" Expr? "}" 4287 4288 [183] EscapeQuot ::= '""' 4289 [184] EscapeApos ::= "''" 4290 [185] ElementContentChar ::= Char - [{}<&] 4291 [186] QuotAttrContentChar ::= Char - ["{}<&] 4292 [187] AposAttrContentChar ::= Char - ['{}<&] 4293 ********************************************************************************/ 4294 4295 4296 /******************************************************************************* 4297 EnclosedExpr ::= "{" Expr "}" 4298 *******************************************************************************/ 4299 class EnclosedExpr : public exprnode 4300 { 4301 protected: 4302 rchandle<exprnode> expr_h; 4303 4304 public: 4305 EnclosedExpr( 4306 const QueryLoc&, 4307 rchandle<exprnode>); 4308 get_expr()4309 rchandle<exprnode> get_expr() const { return expr_h; } 4310 4311 void accept(parsenode_visitor&) const; 4312 }; 4313 4314 4315 /******************************************************************************* 4316 [119] DirElemConstructor ::= "<" QName DirAttributeList 4317 ("/>" | 4318 (">" DirElemContentList? "</" QName S? ">")) 4319 ********************************************************************************/ 4320 class DirElemConstructor : public exprnode 4321 { 4322 protected: 4323 rchandle<QName> elem_name_h, end_name_h; 4324 rchandle<DirAttributeList> attr_list_h; 4325 rchandle<DirElemContentList> dir_content_list_h; 4326 4327 public: 4328 DirElemConstructor( 4329 const QueryLoc&, 4330 rchandle<QName>, 4331 rchandle<QName>, 4332 rchandle<DirAttributeList>, 4333 rchandle<DirElemContentList>); 4334 get_elem_name()4335 rchandle<QName> get_elem_name() const { return elem_name_h; } 4336 get_end_name()4337 rchandle<QName> get_end_name() const { return end_name_h; } 4338 get_attr_list()4339 rchandle<DirAttributeList> get_attr_list() const { return attr_list_h; } 4340 get_dir_content_list()4341 rchandle<DirElemContentList> get_dir_content_list() const { return dir_content_list_h; } 4342 4343 void accept(parsenode_visitor&) const; 4344 }; 4345 4346 4347 /******************************************************************************* 4348 [120] DirAttributeList ::= DirAttr | DirAttributeList DirAttr 4349 ********************************************************************************/ 4350 class DirAttributeList : public parsenode 4351 { 4352 protected: 4353 std::vector<rchandle<DirAttr> > theAttributes; 4354 4355 public: 4356 DirAttributeList(const QueryLoc&); 4357 push_back(rchandle<DirAttr> attr)4358 void push_back(rchandle<DirAttr> attr) { theAttributes.push_back(attr); } 4359 4360 rchandle<DirAttr> operator[](int i) { return theAttributes[i]; } 4361 4362 const DirAttr *operator[] (int i) const { return theAttributes[i]; } 4363 size()4364 ulong size () const { return (ulong)theAttributes.size (); } 4365 4366 void accept(parsenode_visitor&) const; 4367 }; 4368 4369 4370 /******************************************************************************* 4371 [120a] DirAttr ::= (S (QName S? "=" S? DirAttributeValue) 4372 ********************************************************************************/ 4373 class DirAttr : public parsenode 4374 { 4375 protected: 4376 rchandle<QName> theName; 4377 rchandle<DirAttributeValue> theValue; 4378 4379 public: 4380 DirAttr( 4381 const QueryLoc&, 4382 rchandle<QName>, 4383 rchandle<DirAttributeValue>); 4384 4385 4386 public: get_name()4387 rchandle<QName> get_name() const { return theName; } get_value()4388 rchandle<DirAttributeValue> get_value() const { return theValue; } 4389 4390 public: 4391 void accept(parsenode_visitor&) const; 4392 }; 4393 4394 4395 /****************************************************************************** 4396 4397 [121] DirAttributeValue ::= '"' QuoteAttrContentList? '"' | 4398 "'" AposAttrContentList? "'" 4399 4400 *******************************************************************************/ 4401 class DirAttributeValue : public parsenode 4402 { 4403 protected: 4404 rchandle<QuoteAttrContentList> quot_attr_content_h; 4405 rchandle<AposAttrContentList> apos_attr_content_h; 4406 4407 public: 4408 DirAttributeValue( 4409 const QueryLoc&, 4410 rchandle<QuoteAttrContentList>); 4411 4412 DirAttributeValue( 4413 const QueryLoc&, 4414 rchandle<AposAttrContentList>); 4415 4416 get_quot_attr_content()4417 rchandle<QuoteAttrContentList> get_quot_attr_content() const 4418 { 4419 return quot_attr_content_h; 4420 } 4421 get_apos_attr_content()4422 rchandle<AposAttrContentList> get_apos_attr_content() const 4423 { 4424 return apos_attr_content_h; 4425 } 4426 4427 void accept(parsenode_visitor&) const; 4428 }; 4429 4430 4431 /****************************************************************************** 4432 [121a] QuoteAttrContentList ::= QuotAttrValueContent+ 4433 ********************************************************************************/ 4434 class QuoteAttrContentList : public parsenode 4435 { 4436 protected: 4437 std::vector<rchandle<QuoteAttrValueContent> > quot_atval_content_hv; 4438 4439 public: 4440 QuoteAttrContentList(const QueryLoc&); 4441 push_back(rchandle<QuoteAttrValueContent> quot_atval_content_h)4442 void push_back(rchandle<QuoteAttrValueContent> quot_atval_content_h) 4443 { 4444 quot_atval_content_hv.push_back(quot_atval_content_h); 4445 } 4446 4447 rchandle<QuoteAttrValueContent> operator[](int i) const 4448 { 4449 return quot_atval_content_hv[i]; 4450 } 4451 4452 void accept(parsenode_visitor&) const; 4453 }; 4454 4455 4456 /******************************************************************************* 4457 [121b] AposAttrContentList ::= AposAttrValueContent+ 4458 ********************************************************************************/ 4459 class AposAttrContentList : public parsenode 4460 { 4461 protected: 4462 std::vector<rchandle<AposAttrValueContent> > apos_atval_content_hv; 4463 4464 public: 4465 AposAttrContentList(const QueryLoc&); 4466 push_back(rchandle<AposAttrValueContent> apos_atval_content_h)4467 void push_back(rchandle<AposAttrValueContent> apos_atval_content_h) 4468 { 4469 apos_atval_content_hv.push_back(apos_atval_content_h); 4470 } 4471 4472 rchandle<AposAttrValueContent> operator[](int i) const 4473 { 4474 return apos_atval_content_hv[i]; 4475 } 4476 4477 void accept(parsenode_visitor&) const; 4478 }; 4479 4480 4481 /******************************************************************************* 4482 [122] QuotAttrValueContent ::= EscapeQuot | QuotAttrContentChar | CommonContent 4483 4484 [183] EscapeQuot ::= '""' 4485 4486 [186] QuotAttrContentChar ::= Char - ["{}<&] 4487 ********************************************************************************/ 4488 class QuoteAttrValueContent : public parsenode 4489 { 4490 protected: 4491 zstring quot_atcontent; 4492 rchandle<CommonContent> common_content_h; 4493 4494 public: 4495 QuoteAttrValueContent( 4496 const QueryLoc&, 4497 zstring quot_atcontent); 4498 4499 QuoteAttrValueContent( 4500 const QueryLoc&, 4501 rchandle<CommonContent>); 4502 get_quot_atcontent()4503 zstring const& get_quot_atcontent() const { return quot_atcontent; } 4504 get_common_content()4505 rchandle<CommonContent> get_common_content() const { return common_content_h; } 4506 4507 void accept(parsenode_visitor&) const; 4508 }; 4509 4510 4511 /******************************************************************************* 4512 [123] AposAttrValueContent ::= EscapeApos | AposAttrContentChar | CommonContent 4513 4514 [184] EscapeApos ::= "''" 4515 4516 [187] AposAttrContentChar ::= Char - ['{}<&] 4517 ********************************************************************************/ 4518 class AposAttrValueContent : public parsenode 4519 { 4520 protected: 4521 zstring apos_atcontent; 4522 rchandle<CommonContent> common_content_h; 4523 4524 public: 4525 AposAttrValueContent( 4526 const QueryLoc&, 4527 zstring apos_atcontent); 4528 4529 AposAttrValueContent( 4530 const QueryLoc&, 4531 rchandle<CommonContent>); 4532 get_apos_atcontent()4533 zstring const& get_apos_atcontent() const { return apos_atcontent; } 4534 get_common_content()4535 rchandle<CommonContent> get_common_content() const { return common_content_h; } 4536 4537 void accept(parsenode_visitor&) const; 4538 }; 4539 4540 4541 /******************************************************************************* 4542 [119a] DirElemContentList ::= DirElemContent+ 4543 ********************************************************************************/ 4544 class DirElemContentList : public parsenode 4545 { 4546 protected: 4547 std::vector<rchandle<DirElemContent> > dir_content_hv; 4548 4549 public: 4550 DirElemContentList(const QueryLoc&); 4551 push_back(rchandle<DirElemContent> dir_content_h)4552 void push_back(rchandle<DirElemContent> dir_content_h) 4553 { 4554 dir_content_hv.push_back(dir_content_h); 4555 } 4556 4557 rchandle<DirElemContent> operator[](int i) const 4558 { 4559 return dir_content_hv[i]; 4560 } 4561 4562 void accept(parsenode_visitor&) const; 4563 }; 4564 4565 4566 /**************************a***************************************************** 4567 [124] DirElemContent ::= DirectConstructor | 4568 CDataSection | 4569 CommonContent | 4570 ElementContentChar 4571 4572 [185] ElementContentChar ::= Char - [{}<&] 4573 ********************************************************************************/ 4574 class DirElemContent : public exprnode 4575 { 4576 protected: 4577 rchandle<exprnode> direct_cons_h; 4578 zstring elem_content; 4579 rchandle<CDataSection> cdata_h; 4580 rchandle<CommonContent> common_content_h; 4581 mutable bool theIsStripped; 4582 4583 public: 4584 DirElemContent( 4585 const QueryLoc&, 4586 rchandle<exprnode>); 4587 4588 DirElemContent( 4589 const QueryLoc&, 4590 zstring elem_content); 4591 4592 DirElemContent( 4593 const QueryLoc&, 4594 rchandle<CDataSection>); 4595 4596 DirElemContent( 4597 const QueryLoc&, 4598 rchandle<CommonContent>); 4599 get_direct_cons()4600 rchandle<exprnode> get_direct_cons() const { return direct_cons_h; } 4601 get_elem_content()4602 zstring const& get_elem_content() const { return elem_content; } 4603 get_cdata()4604 rchandle<CDataSection> get_cdata() const { return cdata_h; } 4605 get_common_content()4606 rchandle<CommonContent> get_common_content() const { return common_content_h; } 4607 isStripped()4608 bool isStripped() const { return theIsStripped; } 4609 setIsStripped(bool aIsStripped)4610 void setIsStripped(bool aIsStripped) const { theIsStripped = aIsStripped; } 4611 4612 void accept(parsenode_visitor&) const; 4613 }; 4614 4615 4616 /******************************************************************************* 4617 [125] CommonContent ::= PredefinedEntityRef | 4618 CharRef | 4619 "{{" | 4620 "}}" | 4621 EnclosedExpr 4622 ********************************************************************************/ 4623 class CommonContent : public exprnode 4624 { 4625 protected: 4626 enum ParseConstants::common_content_t type; 4627 zstring ref; 4628 rchandle<EnclosedExpr> expr_h; 4629 4630 public: 4631 CommonContent( 4632 const QueryLoc&, 4633 ParseConstants::common_content_t, 4634 zstring const& ref); 4635 4636 CommonContent( 4637 const QueryLoc&, 4638 rchandle<EnclosedExpr> expr_h); 4639 4640 CommonContent( 4641 const QueryLoc&, 4642 enum ParseConstants::common_content_t); 4643 get_type()4644 enum ParseConstants::common_content_t get_type() const { return type; } 4645 get_ref()4646 const zstring& get_ref() const { return ref; } 4647 get_expr()4648 rchandle<EnclosedExpr> get_expr() const { return expr_h; } 4649 4650 void accept(parsenode_visitor&) const; 4651 }; 4652 4653 4654 /******************************************************************************* 4655 [130] CDataSection ::= "<![CDATA[" CDataSectionContents "]]>" 4656 4657 [131] CDataSectionContents ::= (Char* - (Char* ']]>' Char*)) 4658 ********************************************************************************/ 4659 class CDataSection : public exprnode 4660 { 4661 protected: 4662 zstring const cdata_content; 4663 4664 public: 4665 CDataSection( 4666 const QueryLoc&, 4667 zstring const& cdata_content); 4668 get_cdata_content()4669 zstring const& get_cdata_content() const { return cdata_content; } 4670 4671 void accept(parsenode_visitor&) const; 4672 }; 4673 4674 4675 /******************************************************************************* 4676 [126] DirCommentConstructor ::= "<!--" DirCommentContents "-->" 4677 4678 [127] DirCommentContents ::= ((Char - '-') | ('-' (Char - '-')))* 4679 ********************************************************************************/ 4680 class DirCommentConstructor : public exprnode 4681 { 4682 protected: 4683 zstring const comment; 4684 4685 public: 4686 DirCommentConstructor( 4687 const QueryLoc&, 4688 zstring const& comment); 4689 get_comment()4690 zstring const& get_comment() const { return comment; } 4691 4692 void accept(parsenode_visitor&) const; 4693 }; 4694 4695 4696 /******************************************************************************* 4697 [128] DirPIConstructor ::= "<?" PITarget (S DirPIContents)? "?>" 4698 4699 [129] DirPIContents ::= (Char* - (Char* '?>' Char*)) 4700 ********************************************************************************/ 4701 class DirPIConstructor : public exprnode 4702 { 4703 protected: 4704 zstring const pi_target; 4705 zstring const pi_content; 4706 4707 public: 4708 DirPIConstructor( 4709 const QueryLoc&, 4710 zstring const& pi_target); 4711 4712 DirPIConstructor( 4713 const QueryLoc&, 4714 zstring const& pi_target, 4715 zstring const& pi_content); 4716 get_pi_target()4717 zstring const& get_pi_target() const { return pi_target; } 4718 get_pi_content()4719 zstring const& get_pi_content() const { return pi_content; } 4720 4721 void accept(parsenode_visitor&) const; 4722 }; 4723 4724 4725 /******************************************************************************* 4726 [132] ComputedConstructor ::= CompDocConstructor | 4727 CompElemConstructor | 4728 CompAttrConstructor | 4729 CompTextConstructor | 4730 CompCommentConstructor | 4731 CompPIConstructor 4732 ********************************************************************************/ 4733 4734 4735 /******************************************************************************* 4736 [133] CompDocConstructor ::= "document" "{" Expr "}" 4737 ********************************************************************************/ 4738 class CompDocConstructor : public exprnode 4739 { 4740 protected: 4741 rchandle<exprnode> expr_h; 4742 4743 public: 4744 CompDocConstructor( 4745 const QueryLoc&, 4746 rchandle<exprnode>); 4747 get_expr()4748 rchandle<exprnode> get_expr() const { return expr_h; } 4749 4750 void accept(parsenode_visitor&) const; 4751 }; 4752 4753 4754 /******************************************************************************* 4755 [134] CompElemConstructor ::= "element" (QName | ("{" Expr "}")) "{" ContentExpr? "}" 4756 4757 [135] ContentExpr ::= Expr 4758 ********************************************************************************/ 4759 class CompElemConstructor : public exprnode 4760 { 4761 protected: 4762 rchandle<exprnode> qname_expr_h; 4763 rchandle<exprnode> content_expr_h; 4764 4765 public: 4766 CompElemConstructor( 4767 const QueryLoc&, 4768 rchandle<exprnode>, 4769 rchandle<exprnode>); 4770 get_qname_expr()4771 rchandle<exprnode> get_qname_expr() const { return qname_expr_h; } 4772 get_content_expr()4773 rchandle<exprnode> get_content_expr() const { return content_expr_h; } 4774 4775 void accept(parsenode_visitor&) const; 4776 }; 4777 4778 4779 /******************************************************************************* 4780 [136] CompAttrConstructor ::= "attribute" (QName | ("{" Expr "}")) "{" Expr? "}" 4781 ********************************************************************************/ 4782 class CompAttrConstructor : public exprnode 4783 { 4784 protected: 4785 rchandle<exprnode> qname_expr_h; 4786 rchandle<exprnode> val_expr_h; 4787 4788 public: 4789 CompAttrConstructor( 4790 const QueryLoc&, 4791 rchandle<exprnode>, 4792 rchandle<exprnode>); 4793 get_qname_expr()4794 rchandle<exprnode> get_qname_expr() const { return qname_expr_h; } 4795 get_val_expr()4796 rchandle<exprnode> get_val_expr() const { return val_expr_h; } 4797 4798 void accept(parsenode_visitor&) const; 4799 }; 4800 4801 4802 4803 /******************************************************************************* 4804 [140] CompTextConstructor ::= "text" "{" Expr "}" 4805 ********************************************************************************/ 4806 class CompTextConstructor : public exprnode 4807 { 4808 protected: 4809 rchandle<exprnode> text_expr_h; 4810 4811 public: 4812 CompTextConstructor( 4813 const QueryLoc&, 4814 rchandle<exprnode> text_expr_h); 4815 get_text_expr()4816 rchandle<exprnode> get_text_expr() const { return text_expr_h; } 4817 4818 void accept(parsenode_visitor&) const; 4819 }; 4820 4821 4822 /******************************************************************************* 4823 [141] CompCommentConstructor ::= "comment" "{" Expr "}" 4824 ********************************************************************************/ 4825 class CompCommentConstructor : public exprnode 4826 { 4827 protected: 4828 rchandle<exprnode> comment_expr_h; 4829 4830 public: 4831 CompCommentConstructor( 4832 const QueryLoc&, 4833 rchandle<exprnode>); 4834 get_comment_expr()4835 rchandle<exprnode> get_comment_expr() const { return comment_expr_h; } 4836 4837 void accept(parsenode_visitor&) const; 4838 }; 4839 4840 4841 /******************************************************************************* 4842 [142] CompPIConstructor ::= "processing-instruction" (NCName | ("{" Expr "}")) 4843 "{" Expr? "}" 4844 ********************************************************************************/ 4845 class CompPIConstructor : public exprnode 4846 { 4847 protected: 4848 zstring target; 4849 rchandle<exprnode> target_expr_h; 4850 rchandle<exprnode> content_expr_h; 4851 4852 public: 4853 CompPIConstructor( 4854 const QueryLoc&, 4855 zstring const &target, 4856 rchandle<exprnode>); 4857 4858 CompPIConstructor( 4859 const QueryLoc&, 4860 rchandle<exprnode>, 4861 rchandle<exprnode>); 4862 get_target()4863 zstring const& get_target() const { return target; } 4864 get_target_expr()4865 rchandle<exprnode> get_target_expr() const { return target_expr_h; } 4866 get_content_expr()4867 rchandle<exprnode> get_content_expr() const { return content_expr_h; } 4868 4869 void accept(parsenode_visitor&) const; 4870 }; 4871 4872 4873 /******************************************************************************* 4874 [143] SingleType ::= AtomicType "?"? 4875 4876 [144] TypeDeclaration ::= "as" SequenceType 4877 4878 [145] SequenceType ::= ("empty-sequence" "(" ")") | (ItemType OccurrenceIndicator?) 4879 4880 [146] OccurrenceIndicator ::= "?" | "*" | "+" 4881 4882 [147] ItemType ::= KindTest | ("item" "(" ")") | AtomicType 4883 4884 [148] AtomicType ::= QName 4885 4886 [149] KindTest ::= DocumentTest | 4887 ElementTest | 4888 AttributeTest | 4889 SchemaElementTest | 4890 SchemaAttributeTest | 4891 PITest | 4892 CommentTest | 4893 TextTest | 4894 AnyKindTest 4895 4896 [150] AnyKindTest ::= "node" "(" ")" 4897 4898 [151] DocumentTest ::= "document-node" "(" (ElementTest | SchemaElementTest)? ")" 4899 4900 [152] TextTest ::= "text" "(" ")" 4901 4902 [153] CommentTest ::= "comment" "(" ")" 4903 4904 [154] NamespaceNodeTest ::= "namespace-node" "(" ")" 4905 4906 [155] PITest ::= "processing-instruction" "(" (NCName | StringLiteral)? ")" 4907 4908 [156] AttributeTest ::= "attribute" "(" (AttribNameOrWildcard ("," TypeName)?)? ")" 4909 4910 [157] AttribNameOrWildcard ::= AttributeName | "*" 4911 4912 [158] SchemaAttributeTest ::= "schema-attribute" "(" AttributeDeclaration ")" 4913 4914 [159] AttributeDeclaration ::= AttributeName 4915 4916 [160] ElementTest ::= "element" "(" (ElementNameOrWildcard ("," TypeName "?"?)?)? ")" 4917 4918 [161] ElementNameOrWildcard ::= ElementName | "*" 4919 4920 [162] SchemaElementTest ::= "schema-element" "(" ElementDeclaration ")" 4921 4922 [163] ElementDeclaration ::= ElementName 4923 4924 [164] AttributeName ::= QName 4925 4926 [165] ElementName ::= QName 4927 4928 [166] TypeName ::= QName 4929 4930 [167] URILiteral ::= StringLiteral 4931 4932 [168] Prefix ::= NCName 4933 ********************************************************************************/ 4934 4935 4936 /******************************************************************************* 4937 [143] SingleType ::= AtomicType "?"? 4938 ********************************************************************************/ 4939 class SingleType : public parsenode 4940 { 4941 protected: 4942 rchandle<AtomicType> atomic_type_h; 4943 bool hook_b; 4944 4945 public: 4946 SingleType( 4947 const QueryLoc&, 4948 rchandle<AtomicType>, 4949 bool hook_b); 4950 get_atomic_type()4951 rchandle<AtomicType> get_atomic_type() const { return atomic_type_h; } 4952 get_hook_bit()4953 bool get_hook_bit() const { return hook_b; } 4954 4955 void accept(parsenode_visitor&) const; 4956 }; 4957 4958 4959 /******************************************************************************* 4960 [144] TypeDeclaration ::= "as" SequenceType 4961 ********************************************************************************/ 4962 4963 4964 /******************************************************************************* 4965 [145] SequenceType ::= ("empty-sequence" "(" ")") | 4966 (ItemType OccurrenceIndicator?) 4967 ********************************************************************************/ 4968 class SequenceType : public parsenode 4969 { 4970 protected: 4971 rchandle<parsenode> itemtype_h; 4972 rchandle<OccurrenceIndicator> occur_h; 4973 4974 public: 4975 SequenceType( 4976 const QueryLoc&, 4977 rchandle<parsenode>, 4978 rchandle<OccurrenceIndicator>); 4979 get_itemtype()4980 rchandle<parsenode> get_itemtype() const { return itemtype_h; } 4981 get_occur()4982 rchandle<OccurrenceIndicator> get_occur() const { return occur_h; } 4983 get_void_bit()4984 bool get_void_bit() const { return itemtype_h==NULL; } 4985 4986 void accept(parsenode_visitor&) const; 4987 }; 4988 4989 4990 /******************************************************************************* 4991 [146] OccurrenceIndicator ::= "?" | "*" | "+" 4992 ********************************************************************************/ 4993 class OccurrenceIndicator : public parsenode 4994 { 4995 protected: 4996 enum ParseConstants::occurrence_t type; 4997 4998 public: 4999 OccurrenceIndicator( 5000 const QueryLoc&, 5001 enum ParseConstants::occurrence_t); 5002 get_type()5003 enum ParseConstants::occurrence_t get_type() const { return type; } 5004 5005 void accept(parsenode_visitor&) const; 5006 }; 5007 5008 5009 /******************************************************************************* 5010 [147] ItemType ::= KindTest | ("item" "(" ")") | AtomicType 5011 ********************************************************************************/ 5012 class ItemType : public parsenode 5013 { 5014 protected: 5015 bool item_test_b; 5016 5017 public: 5018 ItemType( 5019 const QueryLoc&, 5020 bool item_test_b); 5021 5022 ItemType(const QueryLoc&); 5023 get_item_test_bit()5024 bool get_item_test_bit() const { return item_test_b; } 5025 5026 virtual void accept(parsenode_visitor&) const; 5027 }; 5028 5029 5030 /******************************************************************************* 5031 5032 ********************************************************************************/ 5033 class StructuredItemType : public parsenode 5034 { 5035 public: StructuredItemType(const QueryLoc & loc)5036 StructuredItemType(const QueryLoc& loc) : parsenode(loc) 5037 { 5038 } 5039 5040 void accept(parsenode_visitor&) const; 5041 }; 5042 5043 5044 /******************************************************************************* 5045 [148] AtomicType ::= QName 5046 ********************************************************************************/ 5047 class AtomicType : public parsenode 5048 { 5049 protected: 5050 rchandle<QName> qname_h; 5051 5052 public: 5053 AtomicType(const QueryLoc&, rchandle<QName>); 5054 get_qname()5055 rchandle<QName> get_qname() const { return qname_h; } 5056 5057 void accept(parsenode_visitor&) const; 5058 }; 5059 5060 5061 /******************************************************************************* 5062 [149] KindTest ::= DocumentTest | 5063 ElementTest | 5064 AttributeTest | 5065 SchemaElementTest | 5066 SchemaAttributeTest | 5067 PITest | 5068 CommentTest | 5069 TextTest | 5070 AnyKindTest 5071 ********************************************************************************/ 5072 5073 5074 /******************************************************************************* 5075 [150] AnyKindTest ::= "node" "(" ")" 5076 ********************************************************************************/ 5077 class AnyKindTest : public parsenode 5078 { 5079 public: 5080 AnyKindTest(const QueryLoc&); 5081 5082 void accept(parsenode_visitor&) const; 5083 }; 5084 5085 5086 /******************************************************************************* 5087 [151] DocumentTest ::= "document-node" "(" (ElementTest | SchemaElementTest)? ")" 5088 ********************************************************************************/ 5089 class DocumentTest : public parsenode 5090 { 5091 protected: 5092 rchandle<ElementTest> elem_test_h; 5093 rchandle<SchemaElementTest> schema_elem_test_h; 5094 5095 public: 5096 DocumentTest(const QueryLoc&); 5097 5098 DocumentTest(const QueryLoc&, rchandle<ElementTest>); 5099 5100 DocumentTest(const QueryLoc&, rchandle<SchemaElementTest>); 5101 get_elem_test()5102 rchandle<ElementTest> get_elem_test() const 5103 { 5104 return elem_test_h; 5105 } 5106 get_schema_elem_test()5107 rchandle<SchemaElementTest> get_schema_elem_test() const 5108 { 5109 return schema_elem_test_h; 5110 } 5111 5112 void accept(parsenode_visitor&) const; 5113 }; 5114 5115 5116 /******************************************************************************* 5117 [152] TextTest ::= "text" "(" ")" 5118 ********************************************************************************/ 5119 class TextTest : public parsenode 5120 { 5121 public: 5122 TextTest(const QueryLoc&); 5123 5124 void accept(parsenode_visitor&) const; 5125 }; 5126 5127 5128 /******************************************************************************* 5129 [153] CommentTest ::= "comment" "(" ")" 5130 ********************************************************************************/ 5131 class CommentTest : public parsenode 5132 { 5133 public: 5134 CommentTest(const QueryLoc&); 5135 5136 void accept(parsenode_visitor&) const; 5137 }; 5138 5139 5140 /******************************************************************************* 5141 [155] PITest ::= "processing-instruction" "(" (NCName | StringLiteral)? ")" 5142 ********************************************************************************/ 5143 class PITest : public parsenode 5144 { 5145 protected: 5146 zstring const target; 5147 5148 public: 5149 PITest( 5150 const QueryLoc&, 5151 zstring const& target); 5152 get_target()5153 zstring const& get_target() const { return target; } 5154 5155 void accept(parsenode_visitor&) const; 5156 }; 5157 5158 5159 /****************************************************************************** 5160 [156] AttributeTest ::= "attribute" "(" (AttribNameOrWildcard ("," TypeName)?)? ")" 5161 5162 [157] AttribNameOrWildcard ::= AttributeName | "*" 5163 ********************************************************************************/ 5164 class AttributeTest : public parsenode 5165 { 5166 protected: 5167 rchandle<QName> theAttrName; 5168 rchandle<TypeName> theTypeName; 5169 5170 public: 5171 AttributeTest( 5172 const QueryLoc&, 5173 rchandle<QName>, 5174 rchandle<TypeName>); 5175 get_attr_name()5176 rchandle<QName> get_attr_name() const { return theAttrName; } 5177 get_type_name()5178 rchandle<TypeName> get_type_name() const { return theTypeName; } 5179 is_wild()5180 bool is_wild() const { return theAttrName == NULL; } 5181 5182 void accept(parsenode_visitor&) const; 5183 }; 5184 5185 5186 /******************************************************************************* 5187 [158] SchemaAttributeTest ::= "schema-attribute" "(" AttributeDeclaration ")" 5188 5189 [159] AttributeDeclaration ::= AttributeName 5190 ********************************************************************************/ 5191 class SchemaAttributeTest : public parsenode 5192 { 5193 protected: 5194 rchandle<QName> attr_h; 5195 5196 public: 5197 SchemaAttributeTest( 5198 const QueryLoc&, 5199 rchandle<QName>); 5200 get_attr()5201 rchandle<QName> get_attr() const { return attr_h; } 5202 5203 void accept(parsenode_visitor&) const; 5204 }; 5205 5206 5207 /******************************************************************************* 5208 [160] ElementTest ::= "element" 5209 "(" (ElementNameOrWildcard ("," TypeName "?"?)?)? ")" 5210 5211 [161] ElementNameOrWildcard ::= ElementName | "*" 5212 ********************************************************************************/ 5213 class ElementTest : public parsenode 5214 { 5215 protected: 5216 rchandle<QName> theElementName; 5217 rchandle<TypeName> theTypeName; 5218 bool theNilledAllowed; 5219 5220 public: 5221 ElementTest( 5222 const QueryLoc& l, 5223 rchandle<QName> qn, 5224 rchandle<TypeName> tn, 5225 bool na); 5226 getElementName()5227 rchandle<QName> getElementName() const { return theElementName; } 5228 getTypeName()5229 rchandle<TypeName> getTypeName() const { return theTypeName; } 5230 isWildcard()5231 bool isWildcard() const { return theElementName == NULL; } 5232 isNilledAllowed()5233 bool isNilledAllowed() const { return theNilledAllowed; } 5234 5235 void accept(parsenode_visitor&) const; 5236 }; 5237 5238 5239 /******************************************************************************* 5240 [162] SchemaElementTest ::= "schema-element" "(" ElementDeclaration ")" 5241 5242 [163] ElementDeclaration ::= ElementName 5243 ********************************************************************************/ 5244 class SchemaElementTest : public parsenode 5245 { 5246 protected: 5247 rchandle<QName> elem_h; 5248 5249 public: 5250 SchemaElementTest( 5251 const QueryLoc&, 5252 rchandle<QName> _elem_h); 5253 get_elem()5254 rchandle<QName> get_elem() const { return elem_h; } 5255 5256 void accept(parsenode_visitor&) const; 5257 }; 5258 5259 5260 /******************************************************************************* 5261 [166] TypeName ::= QName 5262 ********************************************************************************/ 5263 class TypeName : public parsenode 5264 { 5265 protected: 5266 rchandle<QName> qname_h; 5267 bool optional_b; 5268 5269 public: 5270 TypeName( 5271 const QueryLoc&, 5272 rchandle<QName>); 5273 5274 TypeName( 5275 const QueryLoc&, 5276 rchandle<QName>, 5277 bool); 5278 get_name()5279 rchandle<QName> get_name() const { return qname_h; } 5280 get_optional_bit()5281 bool get_optional_bit() const { return optional_b; } 5282 5283 void accept(parsenode_visitor&) const; 5284 }; 5285 5286 5287 /******************************************************************************* 5288 [169] TryCatchExpr ::= TryClause CatchClauseList 5289 5290 [170] TryClause ::= "try" "{" TryTargetExpr "}" 5291 5292 [171] TryTargetExpr ::= Expr 5293 ********************************************************************************/ 5294 class TryExpr : public exprnode 5295 { 5296 protected: 5297 rchandle<exprnode> theExprSingle; 5298 rchandle<exprnode> theCatchListExpr; 5299 5300 public: TryExpr(const QueryLoc & aQueryLoc,rchandle<exprnode> aExprSingle,rchandle<exprnode> aCatchListExpr)5301 TryExpr( 5302 const QueryLoc& aQueryLoc, 5303 rchandle<exprnode> aExprSingle, 5304 rchandle<exprnode> aCatchListExpr) 5305 : exprnode(aQueryLoc), 5306 theExprSingle(aExprSingle), 5307 theCatchListExpr(aCatchListExpr) 5308 {} 5309 getExprSingle()5310 rchandle<exprnode> getExprSingle() const { return theExprSingle; } 5311 getCatchListExpr()5312 rchandle<CatchListExpr> getCatchListExpr() const 5313 { 5314 return theCatchListExpr.cast<CatchListExpr> (); 5315 } 5316 5317 void accept(parsenode_visitor&) const; 5318 }; 5319 5320 5321 /******************************************************************************* 5322 CatchClauseList := CatchClause+ 5323 ********************************************************************************/ 5324 class CatchListExpr : public exprnode 5325 { 5326 protected: 5327 std::vector<rchandle<CatchExpr> > theCatchExprs; 5328 5329 public: CatchListExpr(const QueryLoc & aQueryLoc)5330 CatchListExpr(const QueryLoc& aQueryLoc) 5331 : exprnode(aQueryLoc) 5332 {} 5333 push_back(rchandle<CatchExpr> aCatchExpr)5334 void push_back(rchandle<CatchExpr> aCatchExpr) 5335 { 5336 theCatchExprs.push_back(aCatchExpr); 5337 } 5338 5339 rchandle<CatchExpr> operator[](int i) const 5340 { 5341 return theCatchExprs[i]; 5342 } 5343 5344 void accept(parsenode_visitor&) const; 5345 }; 5346 5347 5348 5349 /******************************************************************************* 5350 [172] CatchClause ::= "catch" CatchErrorList "{" Expr "}" 5351 5352 [173] CatchErrorList ::= NameTest ("|" NameTest)* 5353 ********************************************************************************/ 5354 class CatchExpr : public exprnode 5355 { 5356 public: 5357 typedef std::vector<rchandle<NameTest> > NameTestList; 5358 5359 protected: 5360 NameTestList theNameTests; 5361 rchandle<parsenode> theExprSingle; 5362 5363 public: CatchExpr(const QueryLoc & aQueryLoc,NameTestList & aNameTest,rchandle<parsenode> aExprSingle)5364 CatchExpr( 5365 const QueryLoc& aQueryLoc, 5366 NameTestList& aNameTest, 5367 rchandle<parsenode> aExprSingle) 5368 : 5369 exprnode(aQueryLoc), 5370 theNameTests(aNameTest), 5371 theExprSingle(aExprSingle) 5372 { 5373 } 5374 getNameTests()5375 const NameTestList &getNameTests() const { return theNameTests; } 5376 getExprSingle()5377 rchandle<parsenode> getExprSingle() const { return theExprSingle; } 5378 5379 void accept(parsenode_visitor&) const; 5380 }; 5381 5382 5383 /******************************************************************************* 5384 [191] QName ::= [http://www.w3.org/TR/REC-xml-names/#NT-QName] 5385 5386 [196] EQName ::= QName | (URILiteral ":" NCName) 5387 5388 The "qname" data member is either (a) the empty string, or (b) a single NCName, 5389 or (c) NCName1:NCName2. In cases (a) and (b), get_prefix() returns the empty 5390 string, and get_localname() returns "qname". 5391 5392 In case of EQNames, the theIsEQName member is set to true, thePrefix is empty, 5393 and the theNamespace member contains the part before the ":". 5394 5395 ********************************************************************************/ 5396 class QName : public exprnode 5397 { 5398 protected: 5399 zstring const theQName; 5400 zstring theNamespace; 5401 zstring thePrefix; 5402 zstring theLocalName; 5403 bool theIsEQName; 5404 5405 public: 5406 QName(const QueryLoc&, const zstring& qname, bool isEQName = false); 5407 get_qname()5408 const zstring& get_qname() const { return theQName; } 5409 get_localname()5410 const zstring& get_localname() const { return theLocalName; } 5411 get_prefix()5412 const zstring& get_prefix() const { return thePrefix; } 5413 get_namespace()5414 const zstring& get_namespace() const { return theNamespace; } 5415 is_eqname()5416 bool is_eqname() const { return theIsEQName; } 5417 5418 bool operator==(const QName& other) const; 5419 5420 void accept(parsenode_visitor&) const; 5421 }; 5422 5423 5424 ///////////////////////////////////////////////////////////////////////////////// 5425 // // 5426 // Update productions // 5427 // // 5428 ///////////////////////////////////////////////////////////////////////////////// 5429 5430 5431 /******************************************************************************* 5432 5433 ********************************************************************************/ 5434 // [241] RevalidationDecl 5435 // ----------------------- 5436 class RevalidationDecl : public parsenode 5437 /*______________________________________________________________________ 5438 | 5439 | ::= QNAME DECLARE_REVALIDATION_MODE 5440 |_______________________________________________________________________*/ 5441 { 5442 protected: 5443 enum StaticContextConsts::validation_mode_t mode; 5444 public: RevalidationDecl(const QueryLoc & loc,enum StaticContextConsts::validation_mode_t mode_)5445 RevalidationDecl(const QueryLoc& loc, 5446 enum StaticContextConsts::validation_mode_t mode_) 5447 : parsenode (loc), mode (mode_) 5448 {} 5449 5450 5451 public: get_mode()5452 enum StaticContextConsts::validation_mode_t get_mode () const { return mode; } 5453 void accept(parsenode_visitor&) const; 5454 5455 }; 5456 5457 5458 /******************************************************************************* 5459 5460 ********************************************************************************/ 5461 // [242] InsertExpr 5462 // ---------------- 5463 class InsertExpr : public exprnode 5464 /*______________________________________________________________________ 5465 | 5466 | ::= INSERT_NODE ExprSingle INTO ExprSingle 5467 | | INSERT_NODE ExprSingle AS FIRST_INTO ExprSingle 5468 | | INSERT_NODE ExprSingle AS LAST_INTO ExprSingle 5469 | | INSERT_NODE ExprSingle AFTER ExprSingle 5470 | | INSERT_NODE ExprSingle BEFORE ExprSingle 5471 | | INSERT_NODES ExprSingle INTO ExprSingle 5472 | | INSERT_NODES ExprSingle AS FIRST_INTO ExprSingle 5473 | | INSERT_NODES ExprSingle AS LAST_INTO ExprSingle 5474 | | INSERT_NODES ExprSingle AFTER ExprSingle 5475 | | INSERT_NODES ExprSingle BEFORE ExprSingle 5476 |_______________________________________________________________________*/ 5477 { 5478 protected: 5479 store::UpdateConsts::InsertType theInsertType; 5480 rchandle<exprnode> theSourceExpr; 5481 rchandle<exprnode> theTargetExpr; 5482 5483 public: 5484 InsertExpr( 5485 const QueryLoc&, 5486 store::UpdateConsts::InsertType, 5487 rchandle<exprnode> aSourceExpr, 5488 rchandle<exprnode> aTargetExpr); 5489 5490 public: getSourceExpr()5491 rchandle<exprnode> getSourceExpr() const { return theSourceExpr; } getTargetExpr()5492 rchandle<exprnode> getTargetExpr() const { return theTargetExpr; } getType()5493 store::UpdateConsts::InsertType getType() const { return theInsertType; } 5494 5495 public: 5496 void accept(parsenode_visitor&) const; 5497 }; 5498 5499 5500 /******************************************************************************* 5501 5502 ********************************************************************************/ 5503 // [243] DeleteExpr 5504 // ---------------- 5505 class DeleteExpr : public exprnode 5506 /*______________________________________________________________________ 5507 | 5508 | ::= DO_DELETE ExprSingle 5509 |_______________________________________________________________________*/ 5510 { 5511 protected: 5512 rchandle<exprnode> theTargetExpr; 5513 5514 public: 5515 DeleteExpr( 5516 const QueryLoc&, 5517 rchandle<exprnode>); 5518 5519 public: getTargetExpr()5520 rchandle<exprnode> getTargetExpr() const { return theTargetExpr; } 5521 5522 public: 5523 void accept(parsenode_visitor&) const; 5524 }; 5525 5526 5527 /******************************************************************************* 5528 5529 ********************************************************************************/ 5530 // [244] ReplaceExpr 5531 // ----------------- 5532 class ReplaceExpr : public exprnode 5533 /*______________________________________________________________________ 5534 | 5535 | ::= DO_REPLACE ExprSingle WITH ExprSingle 5536 | | DO_REPLACE VALUE_OF ExprSingle WITH ExprSingle 5537 |_______________________________________________________________________*/ 5538 { 5539 protected: 5540 store::UpdateConsts::ReplaceType theReplaceType; 5541 rchandle<exprnode> theTargetExpr; 5542 rchandle<exprnode> theReplaceExpr; 5543 5544 public: 5545 ReplaceExpr( 5546 const QueryLoc&, 5547 store::UpdateConsts::ReplaceType aReplaceType, 5548 rchandle<exprnode> aTargetExpr, 5549 rchandle<exprnode> aReplaceExpr); 5550 5551 5552 public: getType()5553 store::UpdateConsts::ReplaceType getType() const { return theReplaceType; } getTargetExpr()5554 rchandle<exprnode> getTargetExpr() const { return theTargetExpr; } getReplaceExpr()5555 rchandle<exprnode> getReplaceExpr() const { return theReplaceExpr; } 5556 5557 public: 5558 void accept(parsenode_visitor&) const; 5559 }; 5560 5561 5562 /******************************************************************************* 5563 5564 ********************************************************************************/ 5565 // [245] RenameExpr 5566 // ---------------- 5567 class RenameExpr : public exprnode 5568 /*______________________________________________________________________ 5569 | 5570 | ::= DO_RENAME ExprSingle AS ExprSingle 5571 |_______________________________________________________________________*/ 5572 { 5573 protected: 5574 rchandle<exprnode> theTargetExpr; 5575 rchandle<exprnode> theNameExpr; 5576 5577 public: 5578 RenameExpr( 5579 const QueryLoc&, 5580 rchandle<exprnode> aTargetExpr, 5581 rchandle<exprnode> aName); 5582 5583 5584 public: getTargetExpr()5585 rchandle<exprnode> getTargetExpr() const { return theTargetExpr; } getNameExpr()5586 rchandle<exprnode> getNameExpr() const { return theNameExpr; } 5587 5588 public: 5589 void accept(parsenode_visitor&) const; 5590 }; 5591 5592 5593 5594 // [246] SourceExpr 5595 // ---------------- 5596 // folded 5597 5598 // [247] TargetExpr 5599 // ---------------- 5600 // folded 5601 5602 // [248] NewNameExpr 5603 // ----------------- 5604 // folded into [245] RenameExpr 5605 5606 5607 /******************************************************************************* 5608 TransformExpr := "copy" "$" CopyVarList "modify" ExprSingle "return" ExprSingle 5609 5610 CopyVarList := VarBinding | CopyVarList "," "$" VarBinding 5611 5612 VarBinding := VarName ":=" ExprSingle 5613 ********************************************************************************/ 5614 class TransformExpr : public exprnode 5615 { 5616 protected: 5617 rchandle<CopyVarList> var_list; 5618 rchandle<exprnode> theModifyExpr; 5619 rchandle<exprnode> theReturnExpr; 5620 5621 public: 5622 TransformExpr( 5623 const QueryLoc& loc, 5624 rchandle<CopyVarList> var_list, 5625 rchandle<exprnode> modifyExpr, 5626 rchandle<exprnode> returnExpr); 5627 5628 get_var_list()5629 rchandle<CopyVarList> get_var_list() const { return var_list; } get_modify_expr()5630 rchandle<exprnode> get_modify_expr() const { return theModifyExpr; } get_return_expr()5631 rchandle<exprnode> get_return_expr() const { return theReturnExpr; } 5632 5633 void accept(parsenode_visitor&) const; 5634 }; 5635 5636 5637 /******************************************************************************* 5638 5639 ********************************************************************************/ 5640 class CopyVarList : public exprnode 5641 { 5642 protected: 5643 std::vector<rchandle<VarBinding> > var_bindings; 5644 5645 public: 5646 CopyVarList(const QueryLoc& loc); 5647 push_back(rchandle<VarBinding> binding)5648 void push_back(rchandle<VarBinding> binding) 5649 { 5650 var_bindings.push_back(binding); 5651 } 5652 5653 rchandle<VarBinding> operator[](int i) const 5654 { 5655 return var_bindings[i]; 5656 } 5657 size()5658 size_t size () const { return var_bindings.size (); } 5659 5660 void accept(parsenode_visitor&) const; 5661 }; 5662 5663 5664 /******************************************************************************* 5665 5666 ********************************************************************************/ 5667 class VarBinding : public exprnode 5668 { 5669 protected: 5670 rchandle<QName> var_name; 5671 rchandle<exprnode> expr; 5672 5673 public: 5674 VarBinding( 5675 const QueryLoc& loc, 5676 rchandle<QName> varname, 5677 rchandle<exprnode> expr); 5678 get_varname()5679 const QName* get_varname() const { return var_name.getp(); } 5680 get_expr()5681 rchandle<exprnode> get_expr() const { return expr; } 5682 5683 void accept(parsenode_visitor&) const; 5684 }; 5685 5686 5687 /* 5688 * LiteralFunctionItem := QName "#" IntegerLiteral 5689 */ 5690 class LiteralFunctionItem: public exprnode 5691 { 5692 private: 5693 rchandle<QName> theQName; 5694 Integer* theArity; 5695 5696 public: 5697 ~LiteralFunctionItem(); 5698 LiteralFunctionItem(const QueryLoc & loc_,rchandle<QName> aQName,Integer * aArity)5699 LiteralFunctionItem(const QueryLoc& loc_, rchandle<QName> aQName, Integer* aArity): 5700 exprnode(loc_), theQName(aQName), theArity(aArity){} 5701 getQName()5702 rchandle<QName> getQName() const { return theQName; } getArity()5703 const Integer& getArity() const { return *theArity; } 5704 5705 void accept(parsenode_visitor&) const; 5706 }; 5707 5708 /* 5709 * InlineFunction := "function" "(" ParamList? ")" ("as" SequenceType)? EnclosedExpr 5710 */ 5711 class InlineFunction: public exprnode 5712 { 5713 private: 5714 rchandle<ParamList> theParamList; 5715 rchandle<SequenceType> theReturnType; 5716 rchandle<exprnode> theEnclosedExpr; 5717 5718 public: InlineFunction(const QueryLoc & loc_,rchandle<ParamList> aParamList,rchandle<SequenceType> aReturnType,rchandle<exprnode> aEnclosedExpr)5719 InlineFunction( 5720 const QueryLoc& loc_, 5721 rchandle<ParamList> aParamList, 5722 rchandle<SequenceType> aReturnType, 5723 rchandle<exprnode> aEnclosedExpr) 5724 : 5725 exprnode(loc_), 5726 theParamList(aParamList), 5727 theReturnType(aReturnType), 5728 theEnclosedExpr(aEnclosedExpr) 5729 {} 5730 getParamList()5731 rchandle<ParamList> getParamList() const { return theParamList; } getReturnType()5732 rchandle<SequenceType> getReturnType() const { return theReturnType; } getEnclosedExpr()5733 rchandle<exprnode> getEnclosedExpr() const { return theEnclosedExpr; } 5734 5735 void accept(parsenode_visitor&) const; 5736 }; 5737 5738 5739 /* 5740 * AnyFunctionTest := "function" "(" "*" ")" 5741 */ 5742 class AnyFunctionTest: public parsenode 5743 { 5744 public: AnyFunctionTest(const QueryLoc & loc_)5745 AnyFunctionTest(const QueryLoc& loc_): parsenode(loc_){} 5746 void accept(parsenode_visitor&) const; 5747 }; 5748 5749 5750 /* 5751 * TypeList := "(" (SequenceType ("," SequenceType)*)? ")" 5752 */ 5753 class TypeList: public parsenode 5754 { 5755 protected: 5756 std::vector<rchandle<SequenceType> > theTypes; 5757 5758 public: TypeList(const QueryLoc & loc_)5759 TypeList(const QueryLoc& loc_): parsenode(loc_){} 5760 push_back(rchandle<SequenceType> aType)5761 void push_back(rchandle<SequenceType> aType) { theTypes.push_back(aType); } 5762 5763 rchandle<SequenceType> operator[](int i) const { return theTypes[i]; } 5764 size()5765 ulong size() const { return (ulong)theTypes.size (); } 5766 5767 void accept(parsenode_visitor&) const; 5768 }; 5769 5770 /** 5771 * TypedFunctionTest := "function" "(" TypeList? ")" "as" SequenceType 5772 */ 5773 class TypedFunctionTest : public parsenode 5774 { 5775 protected: 5776 rchandle<TypeList> theArgTypes; 5777 rchandle<SequenceType> theReturnType; 5778 5779 public: TypedFunctionTest(const QueryLoc & loc_,rchandle<SequenceType> aReturnType)5780 TypedFunctionTest( 5781 const QueryLoc& loc_, 5782 rchandle<SequenceType> aReturnType) 5783 : parsenode(loc_), 5784 theArgTypes(0), 5785 theReturnType(aReturnType) {} 5786 TypedFunctionTest(const QueryLoc & loc_,rchandle<TypeList> aTypeList,rchandle<SequenceType> aReturnType)5787 TypedFunctionTest( 5788 const QueryLoc& loc_, 5789 rchandle<TypeList> aTypeList, 5790 rchandle<SequenceType> aReturnType) 5791 : parsenode(loc_), 5792 theArgTypes(aTypeList), 5793 theReturnType(aReturnType) {} 5794 getArgumentTypes()5795 const rchandle<TypeList>& getArgumentTypes() const { return theArgTypes; } getReturnType()5796 const rchandle<SequenceType>& getReturnType() const { return theReturnType; } 5797 5798 void accept(parsenode_visitor&) const; 5799 }; 5800 5801 5802 /** 5803 * DynamicFunctionInvocation := FilterExpr LPAR ArgList RPAR 5804 */ 5805 class DynamicFunctionInvocation: public exprnode 5806 { 5807 private: 5808 rchandle<exprnode> thePrimaryExpr; 5809 rchandle<ArgList> theArgList; 5810 5811 public: DynamicFunctionInvocation(const QueryLoc & loc_,rchandle<exprnode> aPrimaryExpr)5812 DynamicFunctionInvocation( 5813 const QueryLoc& loc_, 5814 rchandle<exprnode> aPrimaryExpr 5815 ): exprnode(loc_), thePrimaryExpr(aPrimaryExpr), theArgList(0){} 5816 DynamicFunctionInvocation(const QueryLoc & loc_,rchandle<exprnode> aPrimaryExpr,rchandle<ArgList> aArgList)5817 DynamicFunctionInvocation( 5818 const QueryLoc& loc_, 5819 rchandle<exprnode> aPrimaryExpr, 5820 rchandle<ArgList> aArgList 5821 ): exprnode(loc_), thePrimaryExpr(aPrimaryExpr), theArgList(aArgList){} 5822 getPrimaryExpr()5823 rchandle<exprnode> getPrimaryExpr() const { return thePrimaryExpr; } getArgList()5824 rchandle<ArgList> getArgList() const { return theArgList; } 5825 5826 void accept(parsenode_visitor&) const; 5827 }; 5828 5829 5830 /////////////////////////////////////////////////////////////////////////////// 5831 // // 5832 // Full-text productions // 5833 // // 5834 /////////////////////////////////////////////////////////////////////////////// 5835 5836 5837 class FTAnd : public parsenode { 5838 public: 5839 FTAnd( 5840 QueryLoc const&, 5841 parsenode const*, 5842 parsenode const* 5843 ); 5844 ~FTAnd(); 5845 get_left()5846 parsenode const* get_left() const { return left_; } get_right()5847 parsenode const* get_right() const { return right_; } 5848 5849 void accept( parsenode_visitor& ) const; 5850 5851 private: 5852 parsenode const *const left_; 5853 parsenode const *const right_; 5854 }; 5855 5856 5857 class FTAnyallOption : public parsenode { 5858 public: 5859 FTAnyallOption( 5860 QueryLoc const&, 5861 ft_anyall_mode::type 5862 ); 5863 get_option()5864 ft_anyall_mode::type get_option() const { return option_; } 5865 5866 void accept( parsenode_visitor& ) const; 5867 5868 private: 5869 ft_anyall_mode::type const option_; 5870 }; 5871 5872 5873 class FTBigUnit : public parsenode { 5874 public: 5875 FTBigUnit( 5876 QueryLoc const&, 5877 ft_big_unit::type 5878 ); 5879 get_unit()5880 ft_big_unit::type get_unit() const { return unit_; } 5881 5882 void accept( parsenode_visitor& ) const; 5883 5884 private: 5885 ft_big_unit::type const unit_; 5886 }; 5887 5888 5889 class FTIgnoreOption : public parsenode { 5890 public: 5891 FTIgnoreOption( 5892 QueryLoc const&, 5893 exprnode const* 5894 ); 5895 ~FTIgnoreOption(); 5896 get_union()5897 exprnode const* get_union() const { return expr_; } 5898 5899 void accept( parsenode_visitor& ) const; 5900 5901 private: 5902 exprnode const *const expr_; 5903 }; 5904 5905 5906 class FTMatchOptions : public parsenode { 5907 public: 5908 typedef std::list<FTMatchOption const*> match_option_list_t; 5909 5910 FTMatchOptions( QueryLoc const& ); 5911 ~FTMatchOptions(); 5912 get_match_options()5913 match_option_list_t const& get_match_options() const { 5914 return match_options_; 5915 } 5916 push_back(FTMatchOption const * mo)5917 void push_back( FTMatchOption const *mo ) { 5918 match_options_.push_back( mo ); 5919 } 5920 5921 void accept( parsenode_visitor& ) const; 5922 5923 protected: 5924 match_option_list_t match_options_; 5925 }; 5926 5927 5928 class FTMildNot : public parsenode { 5929 public: 5930 FTMildNot( 5931 QueryLoc const&, 5932 parsenode const*, 5933 parsenode const* 5934 ); 5935 ~FTMildNot(); 5936 get_left()5937 parsenode const* get_left() const { return left_; } get_right()5938 parsenode const* get_right() const { return right_; } 5939 5940 void accept( parsenode_visitor& ) const; 5941 5942 private: 5943 parsenode const *const left_; 5944 parsenode const *const right_; 5945 }; 5946 5947 5948 class FTOptionDecl : public parsenode { 5949 public: 5950 FTOptionDecl( 5951 QueryLoc const&, 5952 FTMatchOptions const* 5953 ); 5954 ~FTOptionDecl(); 5955 get_match_options()5956 FTMatchOptions const* get_match_options() const { return match_options_; } 5957 5958 void accept( parsenode_visitor& ) const; 5959 5960 private: 5961 FTMatchOptions const *const match_options_; 5962 }; 5963 5964 5965 class FTOr : public parsenode { 5966 public: 5967 FTOr( 5968 QueryLoc const&, 5969 parsenode const*, 5970 parsenode const* 5971 ); 5972 ~FTOr(); 5973 get_left()5974 parsenode const* get_left() const { return left_; } get_right()5975 parsenode const* get_right() const { return right_; } 5976 5977 void accept( parsenode_visitor& ) const; 5978 5979 private: 5980 parsenode const *const left_; 5981 parsenode const *const right_; 5982 }; 5983 5984 5985 class FTPrimaryWithOptions : public parsenode { 5986 public: 5987 FTPrimaryWithOptions( 5988 QueryLoc const&, 5989 FTPrimary const*, 5990 FTMatchOptions const*, 5991 FTWeight const* 5992 ); 5993 ~FTPrimaryWithOptions(); 5994 get_primary()5995 FTPrimary const* get_primary() const { return primary_; } get_match_options()5996 FTMatchOptions const* get_match_options() const { return match_options_; } get_weight()5997 FTWeight const* get_weight() const { return weight_; } 5998 5999 void accept( parsenode_visitor& ) const; 6000 6001 private: 6002 FTPrimary const *const primary_; 6003 FTMatchOptions const *const match_options_; 6004 FTWeight const *const weight_; 6005 }; 6006 6007 6008 class FTRange : public parsenode { 6009 public: 6010 FTRange( 6011 QueryLoc const&, 6012 ft_range_mode::type, 6013 exprnode const*, 6014 exprnode const* = NULL 6015 ); 6016 ~FTRange(); 6017 get_expr1()6018 exprnode const* get_expr1() const { return expr1_; } get_expr2()6019 exprnode const* get_expr2() const { return expr2_; } get_mode()6020 ft_range_mode::type get_mode() const { return mode_; } 6021 6022 void accept( parsenode_visitor& ) const; 6023 6024 private: 6025 ft_range_mode::type mode_; 6026 exprnode const *const expr1_; 6027 exprnode const *const expr2_; 6028 }; 6029 6030 6031 class FTTimes : public parsenode { 6032 public: 6033 FTTimes( 6034 QueryLoc const&, 6035 FTRange const* 6036 ); 6037 ~FTTimes(); 6038 get_range()6039 FTRange const* get_range() const { return range_; } 6040 6041 void accept( parsenode_visitor& ) const; 6042 6043 private: 6044 FTRange const *const range_; 6045 }; 6046 6047 6048 class FTUnaryNot : public parsenode { 6049 public: 6050 FTUnaryNot( 6051 QueryLoc const&, 6052 FTPrimaryWithOptions const* 6053 ); 6054 ~FTUnaryNot(); 6055 get_primary_with_options()6056 FTPrimaryWithOptions const* get_primary_with_options() const 6057 { return primary_with_options_; } 6058 6059 void accept( parsenode_visitor& ) const; 6060 6061 private: 6062 FTPrimaryWithOptions const *const primary_with_options_; 6063 }; 6064 6065 6066 class FTUnit : public parsenode { 6067 public: 6068 FTUnit( QueryLoc const&, ft_unit::type ); 6069 get_unit()6070 ft_unit::type get_unit() const { return unit_; } 6071 6072 void accept( parsenode_visitor& ) const; 6073 6074 private: 6075 ft_unit::type const unit_; 6076 }; 6077 6078 6079 class FTWeight : public parsenode { 6080 public: 6081 FTWeight( QueryLoc const&, exprnode* ); 6082 get_expr()6083 rchandle<exprnode> get_expr() const { return expr_; } 6084 6085 void accept( parsenode_visitor& ) const; 6086 6087 private: 6088 rchandle<exprnode> expr_; 6089 }; 6090 6091 6092 class FTWords : public parsenode { 6093 public: 6094 FTWords( 6095 QueryLoc const&, 6096 FTWordsValue const*, 6097 FTAnyallOption const* 6098 ); 6099 ~FTWords(); 6100 get_words_value()6101 FTWordsValue const* get_words_value() const { return words_value_; } get_any_all_option()6102 FTAnyallOption const* get_any_all_option() const { return any_all_option_; } 6103 6104 void accept( parsenode_visitor& ) const; 6105 6106 private: 6107 FTWordsValue const *const words_value_; 6108 FTAnyallOption const *const any_all_option_; 6109 }; 6110 6111 6112 class FTWordsValue : public parsenode { 6113 public: 6114 FTWordsValue( 6115 QueryLoc const&, 6116 StringLiteral*, 6117 exprnode* 6118 ); 6119 get_literal()6120 rchandle<StringLiteral> get_literal() const { return literal_; } get_expr()6121 rchandle<exprnode> get_expr() const { return expr_; } 6122 6123 void accept( parsenode_visitor& ) const; 6124 6125 private: 6126 rchandle<StringLiteral> literal_; 6127 rchandle<exprnode> expr_; 6128 }; 6129 6130 6131 ////////// FTPrimary & derived classes //////////////////////////////////////// 6132 6133 class FTPrimary : public parsenode { 6134 protected: FTPrimary(QueryLoc const & loc)6135 FTPrimary( QueryLoc const &loc ) : parsenode( loc ) { } 6136 }; 6137 6138 6139 class FTSelection : public FTPrimary { 6140 public: 6141 typedef std::list<FTPosFilter*> pos_filter_list_t; 6142 6143 FTSelection( 6144 QueryLoc const&, 6145 parsenode const*, 6146 pos_filter_list_t* 6147 ); 6148 ~FTSelection(); 6149 get_ftor()6150 parsenode const* get_ftor() const { return ftor_; } 6151 get_pos_filter_list()6152 pos_filter_list_t const& get_pos_filter_list() const { 6153 return pos_filter_list_; 6154 } 6155 6156 void accept( parsenode_visitor& ) const; 6157 6158 private: 6159 parsenode const *const ftor_; 6160 pos_filter_list_t pos_filter_list_; 6161 }; 6162 6163 6164 class FTExtensionSelection : public FTPrimary { 6165 public: 6166 FTExtensionSelection( 6167 QueryLoc const&, 6168 rchandle<PragmaList> const&, 6169 FTSelection const* 6170 ); 6171 ~FTExtensionSelection(); 6172 get_pragma_list()6173 rchandle<PragmaList> const& get_pragma_list() const { return pragmas_; } get_selectionI()6174 FTSelection const* get_selectionI() const { return ftselection_; } 6175 6176 void accept( parsenode_visitor& ) const; 6177 6178 private: 6179 rchandle<PragmaList> pragmas_; 6180 FTSelection const *const ftselection_; 6181 }; 6182 6183 6184 class FTWordsTimes : public FTPrimary { 6185 public: 6186 FTWordsTimes( 6187 QueryLoc const&, 6188 FTWords const*, 6189 FTTimes const* 6190 ); 6191 ~FTWordsTimes(); 6192 get_words()6193 FTWords const* get_words() const { return words_; } get_times()6194 FTTimes const* get_times() const { return times_; } 6195 6196 void accept( parsenode_visitor& ) const; 6197 6198 protected: 6199 FTWords const *words_; 6200 FTTimes const *times_; 6201 }; 6202 6203 6204 ////////// FTMatchOption & derived classes //////////////////////////////////// 6205 6206 class FTMatchOption : public parsenode { 6207 protected: 6208 FTMatchOption( const QueryLoc& ); 6209 }; 6210 6211 6212 class FTCaseOption : public FTMatchOption { 6213 public: 6214 FTCaseOption( 6215 QueryLoc const&, 6216 ft_case_mode::type = ft_case_mode::DEFAULT 6217 ); 6218 get_mode()6219 ft_case_mode::type get_mode() const { return mode_; } 6220 6221 void accept( parsenode_visitor& ) const; 6222 6223 private: 6224 ft_case_mode::type const mode_; 6225 }; 6226 6227 6228 class FTDiacriticsOption : public FTMatchOption { 6229 public: 6230 FTDiacriticsOption( 6231 QueryLoc const&, 6232 ft_diacritics_mode::type = ft_diacritics_mode::DEFAULT 6233 ); 6234 get_mode()6235 ft_diacritics_mode::type get_mode() const { return mode_; } 6236 6237 void accept( parsenode_visitor& ) const; 6238 6239 private: 6240 ft_diacritics_mode::type const mode_; 6241 }; 6242 6243 6244 class FTExtensionOption : public FTMatchOption { 6245 public: 6246 FTExtensionOption( 6247 QueryLoc const&, 6248 QName*, 6249 zstring const &value 6250 ); 6251 get_qname()6252 rchandle<QName> get_qname() const { return qname_; } get_val()6253 zstring const& get_val() const { return value_; } 6254 6255 void accept( parsenode_visitor& ) const; 6256 6257 private: 6258 rchandle<QName> qname_; 6259 zstring const value_; 6260 }; 6261 6262 6263 class FTLanguageOption : public FTMatchOption { 6264 public: 6265 FTLanguageOption( 6266 QueryLoc const&, 6267 zstring const &language 6268 ); 6269 get_language()6270 zstring const& get_language() const { return language_; } 6271 6272 void accept( parsenode_visitor& ) const; 6273 6274 private: 6275 zstring const language_; 6276 }; 6277 6278 6279 class FTStemOption : public FTMatchOption { 6280 public: 6281 FTStemOption( 6282 QueryLoc const&, 6283 ft_stem_mode::type = ft_stem_mode::DEFAULT 6284 ); 6285 get_mode()6286 ft_stem_mode::type get_mode() const { return mode_; } 6287 6288 void accept( parsenode_visitor& ) const; 6289 6290 private: 6291 ft_stem_mode::type const mode_; 6292 }; 6293 6294 6295 class FTThesaurusOption : public FTMatchOption { 6296 public: 6297 typedef std::list<FTThesaurusID const*> thesaurus_id_list_t; 6298 6299 FTThesaurusOption( 6300 QueryLoc const&, 6301 thesaurus_id_list_t*, 6302 bool includes_default, 6303 bool no_thesaurus = false 6304 ); 6305 ~FTThesaurusOption(); 6306 get_thesaurus_id_list()6307 thesaurus_id_list_t const& get_thesaurus_id_list() const 6308 { return thesaurus_id_list_; } 6309 includes_default()6310 bool includes_default() const { return includes_default_; } no_thesaurus()6311 bool no_thesaurus() const { return no_thesaurus_; } 6312 6313 void accept( parsenode_visitor& ) const; 6314 6315 private: 6316 thesaurus_id_list_t thesaurus_id_list_; 6317 bool const includes_default_; 6318 bool const no_thesaurus_; 6319 }; 6320 6321 6322 class FTThesaurusID : public parsenode { 6323 public: 6324 FTThesaurusID( 6325 QueryLoc const&, 6326 zstring const &uri, 6327 zstring const &relationship, 6328 FTRange const* = NULL 6329 ); 6330 ~FTThesaurusID(); 6331 get_uri()6332 zstring const& get_uri() const { return uri_; } get_relationship()6333 zstring const& get_relationship() const { return relationship_; } get_levels()6334 FTRange const* get_levels() const { return levels_; } 6335 6336 void accept( parsenode_visitor& ) const; 6337 6338 private: 6339 zstring const uri_; 6340 zstring const relationship_; 6341 FTRange const *const levels_; 6342 }; 6343 6344 6345 class FTStopWordOption : public FTMatchOption { 6346 public: 6347 typedef std::list<FTStopWordsInclExcl const*> incl_excl_list_t; 6348 6349 FTStopWordOption( 6350 QueryLoc const&, 6351 FTStopWords const*, 6352 incl_excl_list_t*, 6353 ft_stop_words_mode::type = ft_stop_words_mode::DEFAULT 6354 ); 6355 ~FTStopWordOption(); 6356 get_incl_excl_list()6357 incl_excl_list_t const& get_incl_excl_list() const 6358 { return incl_excl_list_; } 6359 get_mode()6360 ft_stop_words_mode::type get_mode() const { return mode_; } get_stop_words()6361 FTStopWords const* get_stop_words() const { return stop_words_; } 6362 6363 void accept( parsenode_visitor& ) const; 6364 6365 private: 6366 FTStopWords const *const stop_words_; 6367 incl_excl_list_t incl_excl_list_; 6368 ft_stop_words_mode::type const mode_; 6369 }; 6370 6371 6372 class FTStopWords : public parsenode { 6373 public: 6374 typedef std::list<zstring> list_t; 6375 6376 FTStopWords( 6377 QueryLoc const&, 6378 zstring const &uri, 6379 list_t* 6380 ); 6381 get_uri()6382 zstring const& get_uri() const { return uri_; } get_stop_words()6383 list_t const& get_stop_words() const { return stop_words_; } 6384 6385 void accept( parsenode_visitor& ) const; 6386 6387 private: 6388 zstring const uri_; 6389 list_t stop_words_; 6390 }; 6391 6392 6393 class FTStopWordsInclExcl : public parsenode { 6394 public: 6395 FTStopWordsInclExcl( 6396 QueryLoc const&, 6397 FTStopWords const*, 6398 ft_stop_words_unex::type 6399 ); 6400 ~FTStopWordsInclExcl(); 6401 get_stop_words()6402 FTStopWords const* get_stop_words() const { return stop_words_; } get_mode()6403 ft_stop_words_unex::type get_mode() const { return mode_; } 6404 6405 void accept( parsenode_visitor& ) const; 6406 6407 private: 6408 FTStopWords const *const stop_words_; 6409 ft_stop_words_unex::type const mode_; 6410 }; 6411 6412 6413 class FTWildCardOption : public FTMatchOption { 6414 public: 6415 FTWildCardOption( 6416 QueryLoc const&, 6417 ft_wild_card_mode::type = ft_wild_card_mode::DEFAULT 6418 ); 6419 get_mode()6420 ft_wild_card_mode::type get_mode() const { return mode_; } 6421 6422 void accept( parsenode_visitor& ) const; 6423 6424 private: 6425 ft_wild_card_mode::type const mode_; 6426 }; 6427 6428 ////////// FTPosFilter & derived classes ////////////////////////////////////// 6429 6430 class FTPosFilter : public parsenode 6431 { 6432 protected: FTPosFilter(QueryLoc const & loc)6433 FTPosFilter( QueryLoc const &loc ) : parsenode( loc ) { } 6434 }; 6435 6436 6437 class FTContent : public FTPosFilter 6438 { 6439 public: 6440 FTContent( 6441 QueryLoc const&, 6442 ft_content_mode::type 6443 ); 6444 get_mode()6445 ft_content_mode::type get_mode() const { return mode_; } 6446 6447 void accept( parsenode_visitor& ) const; 6448 6449 private: 6450 ft_content_mode::type const mode_; 6451 }; 6452 6453 6454 class FTDistance : public FTPosFilter 6455 { 6456 public: 6457 FTDistance( 6458 QueryLoc const&, 6459 FTRange const *distance, 6460 FTUnit const* 6461 ); 6462 ~FTDistance(); 6463 get_distance()6464 FTRange const* get_distance() const { return distance_; } get_unit()6465 FTUnit const* get_unit() const { return unit_; } 6466 6467 void accept( parsenode_visitor& ) const; 6468 6469 private: 6470 FTRange const *const distance_; 6471 FTUnit const *const unit_; 6472 }; 6473 6474 6475 class FTOrder : public FTPosFilter 6476 { 6477 public: 6478 FTOrder( QueryLoc const& ); 6479 6480 void accept( parsenode_visitor& ) const; 6481 }; 6482 6483 6484 class FTScope : public FTPosFilter 6485 { 6486 public: 6487 FTScope( 6488 QueryLoc const&, 6489 ft_scope::type, 6490 FTBigUnit const* 6491 ); 6492 ~FTScope(); 6493 get_scope()6494 ft_scope::type get_scope() const { return scope_; } get_big_unit()6495 FTBigUnit const* get_big_unit() const { return big_unit_; } 6496 6497 void accept( parsenode_visitor& ) const; 6498 6499 private: 6500 ft_scope::type const scope_; 6501 FTBigUnit const *const big_unit_; 6502 }; 6503 6504 6505 class FTWindow : public FTPosFilter 6506 { 6507 public: 6508 FTWindow( 6509 QueryLoc const&, 6510 AdditiveExpr const *window, 6511 FTUnit const *unit 6512 ); 6513 ~FTWindow(); 6514 get_unit()6515 FTUnit const* get_unit() const { return unit_; } get_window()6516 AdditiveExpr const* get_window() const { return window_; } 6517 6518 void accept( parsenode_visitor& ) const; 6519 6520 private: 6521 AdditiveExpr const *const window_; 6522 FTUnit const *const unit_; 6523 }; 6524 6525 6526 /////////////////////////////////////////////////////////////////////////////// 6527 // // 6528 // JSON productions // 6529 // // 6530 /////////////////////////////////////////////////////////////////////////////// 6531 6532 6533 class JSONArrayConstructor : public exprnode 6534 { 6535 private: 6536 const exprnode* expr_; 6537 6538 public: 6539 JSONArrayConstructor(const QueryLoc&, const exprnode*); 6540 6541 ~JSONArrayConstructor(); 6542 get_expr()6543 const exprnode* get_expr() const { return expr_; } 6544 6545 void accept(parsenode_visitor&) const; 6546 }; 6547 6548 6549 class JSONObjectConstructor : public exprnode 6550 { 6551 private: 6552 const exprnode* expr_; 6553 bool theAccumulate; 6554 6555 public: 6556 JSONObjectConstructor( 6557 const QueryLoc& loc, 6558 const exprnode* input, 6559 bool accumulate); 6560 6561 ~JSONObjectConstructor(); 6562 get_expr()6563 const exprnode* get_expr() const { return expr_; } 6564 get_accumulate()6565 bool get_accumulate() const { return theAccumulate; } 6566 6567 void accept(parsenode_visitor&) const; 6568 }; 6569 6570 6571 class JSONDirectObjectConstructor : public exprnode 6572 { 6573 private: 6574 const JSONPairList * thePairs; 6575 6576 public: 6577 JSONDirectObjectConstructor(const QueryLoc& loc, const JSONPairList* pairs); 6578 6579 ~JSONDirectObjectConstructor(); 6580 6581 csize numPairs() const; 6582 6583 void accept(parsenode_visitor&) const; 6584 }; 6585 6586 6587 class JSONPairList : public parsenode 6588 { 6589 protected: 6590 std::vector<rchandle<JSONPairConstructor> > thePairs; 6591 6592 public: JSONPairList(const QueryLoc & loc)6593 JSONPairList(const QueryLoc& loc) : parsenode(loc) { }; 6594 push_back(JSONPairConstructor * pair)6595 void push_back(JSONPairConstructor* pair) { thePairs.push_back(pair); } 6596 6597 const JSONPairConstructor* operator[] (csize i) const { return thePairs[i]; } 6598 size()6599 csize size() const { return thePairs.size(); } 6600 6601 void accept(parsenode_visitor&) const; 6602 }; 6603 6604 6605 class JSONPairConstructor : public parsenode 6606 { 6607 private: 6608 const exprnode * expr1_; 6609 const exprnode * expr2_; 6610 6611 public: 6612 JSONPairConstructor(const QueryLoc&, const exprnode*, const exprnode*); 6613 6614 ~JSONPairConstructor(); 6615 get_expr1()6616 const exprnode* get_expr1() const { return expr1_; } get_expr2()6617 const exprnode* get_expr2() const { return expr2_; } 6618 6619 void accept( parsenode_visitor& ) const; 6620 }; 6621 6622 6623 /******************************************************************************* 6624 6625 ********************************************************************************/ 6626 class JSON_Test : public parsenode 6627 { 6628 private: 6629 store::StoreConsts::JSONItemKind jt_; 6630 6631 public: 6632 JSON_Test( 6633 const QueryLoc& loc, 6634 store::StoreConsts::JSONItemKind jt); 6635 get_kind()6636 store::StoreConsts::JSONItemKind get_kind() const { return jt_; } 6637 6638 void accept(parsenode_visitor&) const; 6639 }; 6640 6641 6642 /******************************************************************************* 6643 6644 ********************************************************************************/ 6645 class JSONObjectInsertExpr : public exprnode 6646 { 6647 protected: 6648 rchandle<exprnode> theContentExpr; 6649 rchandle<exprnode> theTargetExpr; 6650 6651 public: 6652 JSONObjectInsertExpr( 6653 const QueryLoc& loc, 6654 const rchandle<exprnode>& contentExpr, 6655 const rchandle<exprnode>& targetExpr); 6656 6657 void accept(parsenode_visitor&) const; 6658 }; 6659 6660 6661 /******************************************************************************* 6662 6663 ********************************************************************************/ 6664 class JSONArrayInsertExpr : public exprnode 6665 { 6666 protected: 6667 rchandle<exprnode> theTargetExpr; 6668 rchandle<exprnode> thePositionExpr; 6669 rchandle<exprnode> theValueExpr; 6670 6671 public: 6672 JSONArrayInsertExpr( 6673 const QueryLoc& loc, 6674 const rchandle<exprnode>& valueExpr, 6675 const rchandle<exprnode>& targetExpr, 6676 const rchandle<exprnode>& posExpr); 6677 6678 void accept(parsenode_visitor&) const; 6679 }; 6680 6681 6682 /******************************************************************************* 6683 6684 ********************************************************************************/ 6685 class JSONArrayAppendExpr : public exprnode 6686 { 6687 protected: 6688 rchandle<exprnode> theTargetExpr; 6689 rchandle<exprnode> theValueExpr; 6690 6691 public: 6692 JSONArrayAppendExpr( 6693 const QueryLoc& loc, 6694 const rchandle<exprnode>& targetExpr, 6695 const rchandle<exprnode>& valueExpr); 6696 6697 void accept(parsenode_visitor&) const; 6698 }; 6699 6700 6701 /******************************************************************************* 6702 6703 ********************************************************************************/ 6704 class JSONDeleteExpr : public exprnode 6705 { 6706 protected: 6707 rchandle<exprnode> theTargetExpr; 6708 rchandle<exprnode> theSelectorExpr; 6709 6710 public: 6711 JSONDeleteExpr( 6712 const QueryLoc& loc, 6713 const rchandle<exprnode>& targetExpr, 6714 const rchandle<exprnode>& selectorExpr); 6715 6716 void accept(parsenode_visitor&) const; 6717 }; 6718 6719 6720 /******************************************************************************* 6721 6722 ********************************************************************************/ 6723 class JSONReplaceExpr : public exprnode 6724 { 6725 protected: 6726 rchandle<exprnode> theTargetExpr; 6727 rchandle<exprnode> theSelectorExpr; 6728 rchandle<exprnode> theValueExpr; 6729 6730 public: 6731 JSONReplaceExpr( 6732 const QueryLoc& loc, 6733 const rchandle<exprnode>& targetExpr, 6734 const rchandle<exprnode>& nameExpr, 6735 const rchandle<exprnode>& newNameExpr); 6736 6737 void accept(parsenode_visitor&) const; 6738 }; 6739 6740 6741 /******************************************************************************* 6742 6743 ********************************************************************************/ 6744 class JSONRenameExpr : public exprnode 6745 { 6746 protected: 6747 rchandle<exprnode> theTargetExpr; 6748 rchandle<exprnode> theNameExpr; 6749 rchandle<exprnode> theNewNameExpr; 6750 6751 public: 6752 JSONRenameExpr( 6753 const QueryLoc& loc, 6754 const rchandle<exprnode>& targetExpr, 6755 const rchandle<exprnode>& nameExpr, 6756 const rchandle<exprnode>& newNameExpr); 6757 6758 void accept(parsenode_visitor&) const; 6759 }; 6760 6761 6762 /////////////////////////////////////////////////////////////////////////////// 6763 6764 } // namespace zorba 6765 #endif /* ZORBA_PARSENODES_H */ 6766 6767 /* 6768 * Local variables: 6769 * mode: c++ 6770 * End: 6771 */ 6772 /* vim:set et sw=2 ts=2: */ 6773