-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompiler.h
More file actions
59 lines (53 loc) · 1.76 KB
/
Copy pathcompiler.h
File metadata and controls
59 lines (53 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once
#include "tokenstream.h"
#include "../isr/isrHandler.h"
#include "../isr/isr.h"
#include "stopwords.h"
class QueryParser
{
public:
//constructors
QueryParser(char* s, char type) : tokenStream(s), handler(), type(type) {
handler.SetIndexReadHandlerPtr(&readHandler);
};
QueryParser(string& s, char type): tokenStream(s), handler(), type(type) {
handler.SetIndexReadHandlerPtr(&readHandler);
};
int SetIndexReadHandler(string& pathname) {
int ret = readHandler.ReadIndex(pathname.c_str());
handler.SetIndexReadHandlerPtr(&readHandler);
return ret;
}
int SetIndexReadHandler(const char* pathname) {
int ret = readHandler.ReadIndex(pathname);
handler.SetIndexReadHandlerPtr(&readHandler);
return ret;
}
IndexReadHandler& getIndexReadHandler() { return readHandler; }
ISRHandler& getISRHandler() { return handler; }
ISR* compile( ) ;
// Getter for flattenedWords
vector<ISRWord*> & getFlattenedWords() { return flattenedWords; }
vector<ISRWord*>& getFlattenedTitles() { return flattenedTitles; }
private:
TokenStream tokenStream;
ISRHandler handler;
IndexReadHandler readHandler;
vector<ISRWord*> flattenedWords;
vector<ISRWord*> flattenedTitles;
vector<ISR*> included;
vector<ISR*> excluded;
char type;
//compiles the query into an ISRContainer
//returns nullptr if there is an error, writes error to cerr
//please call the close method on the returned pointer when done
//constraints start at OrC and prase recursively down
//will parse until NOT or EOF is hit
ISR* OrC( );
ISR* AndC( );
ISR* BaseC( );
ISR* ParenC( );
ISR* QuoteC( );
ISR* wordC( );
bool IsBaseTerm( );
};