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_COMPILER_API_H 18 #define ZORBA_COMPILER_API_H 19 20 #include <memory> 21 #include "zorbatypes/schema_types.h" 22 23 #include "common/shared_types.h" 24 #include <zorba/api_shared_types.h> 25 26 namespace zorba { 27 28 29 class XQueryCompiler 30 { 31 public: 32 33 CompilerCB * theCompilerCB; 34 35 public: 36 XQueryCompiler(CompilerCB* aCompilerCB); 37 38 virtual ~XQueryCompiler(); 39 40 void parseOnly(std::istream& aXQuery, const zstring& aFileName); 41 42 void xqdoc( 43 std::istream& aXQuery, 44 const zstring& aFileName, 45 store::Item_t& aResult, 46 const store::Item_t& aDateTime, 47 uint32_t aOptions); 48 49 parsenode_t parse(std::istream& aXQuery, const zstring& aFileName); 50 51 PlanIter_t compile( 52 std::istream& aXQuery, 53 const zstring& aFileName, 54 ulong& nextDynamicVarId); 55 56 PlanIter_t compile( 57 const parsenode_t& ast, 58 bool applyPUL, 59 ulong& nextDynamicVarId, 60 audit::ScopedRecord& aAuditRecord); 61 62 protected: 63 expr* normalize(parsenode_t ast); 64 65 expr* optimize(expr* expr); 66 67 private: 68 parsenode_t createMainModule( 69 parsenode_t libModule, 70 std::istream& xquery, 71 const zstring& fileName); 72 }; 73 74 75 class XQueryCompilerSubsystem 76 { 77 friend class GlobalEnvironment; 78 79 public: 80 XQueryCompilerSubsystem(); 81 82 virtual ~XQueryCompilerSubsystem(); 83 84 virtual Rewriter* getDefaultOptimizingRewriter() = 0; 85 86 private: 87 static std::auto_ptr<XQueryCompilerSubsystem> create(); 88 }; 89 90 91 } /* namespace zorba */ 92 #endif /* ZORBA_COMPILER_API_H */ 93 94 /* 95 * Local variables: 96 * mode: c++ 97 * End: 98 */ 99 /* vim:set et sw=2 ts=2: */ 100