00001 //-*- Mode: C++; c-basic-offset: 8; -*- 00002 #if !defined(__QUERYPARSER_H_) 00003 #define __QUERYPARSER_H_ 00004 00005 #include <list> 00006 #include "QueryNode.h" 00007 #include "yyQParser.h" 00008 00009 //#include "yyQLexer.h" 00010 #undef yyFlexLexer 00011 #define yyFlexLexer yyqLexer 00012 #include "FlexLexer.h" 00013 00014 00022 class CQueryParser : public yyqLexer 00023 { 00024 public: 00025 // current node index to set CQueryTokenNode::m_NodeIndex 00026 int m_CurrentNodeIndex; 00027 00029 string m_HitTypeStr; 00031 int m_TextAreaNo; 00033 vector<CDDCFilterWithBounds> m_Filters; 00035 size_t m_ContextSentencesCount; 00037 CQueryNode* m_pQueryTree; 00039 const CConcHolder* m_pHolder; 00041 list<string> m_Labels; 00043 vector<const CQueryNode*> m_CurrSequenceObj; 00045 vector<string> m_CurrDistances; 00046 // if true, DDC shows file names, instead of bibliographical information for this query (CConcIndexator::m_bOutputBibliographyOfHits is default value for outputting bibliography 00047 bool m_bEnableBibliographyForThisQuery; 00048 // if true, DDC initializes CHit::m_DebugRank 00049 bool m_bDebugRank; 00050 00052 BigramDirectionEnum m_BigramsUse; 00053 00054 00055 public: 00057 CQueryParser(const CConcHolder* pHolder); 00058 00060 virtual ~CQueryParser(); 00061 00063 void CleanParser(); 00064 00066 bool ParseQueryOperators (const string& OperatorName, const string& Arguments, CDDCFilterWithBounds& Filter); 00068 bool ParseSortAndFilterOperators(string& QueryStr); 00069 00072 //int yylex(); 00073 00075 //virtual int yywrap() { return 1; }; 00076 00078 int yyqlex (void* valp); 00079 00080 inline const char* yytext(void) const { return YYText(); }; 00081 inline int yyleng(void) const { return YYLeng(); }; 00082 00084 void DeleteTree(); 00085 00087 bool ParseQuery(const char* query_src); 00089 bool Evaluate(); 00090 // return current node index to set CQueryTokenNode::m_NodeIndex 00091 int GetNewNodeIndex(); 00092 // return m_CurrentNodeIndex 00093 size_t GetNodeIndicesCount() const; 00094 }; 00095 00096 #endif