-
Notifications
You must be signed in to change notification settings - Fork 1
/
matcher.h
52 lines (42 loc) · 1.26 KB
/
matcher.h
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
#include <list>
#include "./statements.h"
#include "./pattern.h"
// This struct is used as sub-parser
// by the MatcherDeclaration
struct Hook {
pMatch::arrayClass expr;
calculator cond;
BlockStatement body;
void compile(const char* code, const char** rest, TokenMap parent_scope);
Iterator* getIterator(std::string text, TokenMap = &TokenMap::empty) const;
public:
Hook() {}
Hook(const char* code, const char** rest = 0,
TokenMap parent_scope = &TokenMap::empty) {
compile(code, rest, parent_scope);
}
};
// Its equivalent to the class `banco`
struct MatcherDeclaration : public Statement {
std::string name;
TokenList hooks;
private:
void _compile(const char* code, const char** rest, TokenMap parent_scope);
returnState _exec(TokenMap scope) const;
public:
MatcherDeclaration() {}
MatcherDeclaration(const char* code, const char** rest = 0,
TokenMap parent_scope = &TokenMap::empty) {
_compile(code, rest, parent_scope);
}
virtual Statement* clone() const {
return new MatcherDeclaration(*this);
}
};
struct Matcher : public pMatch::matcher {
TokenList hooks;
Matcher() {}
Matcher(TokenList hooks) : hooks(hooks) {}
bool match(std::string input, size_t pos);
std::string str() { return ""; }
};