-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnfa.h
44 lines (43 loc) · 1.16 KB
/
nfa.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
#ifndef NFAH
#define NFAH
#include<set>
#include<string>
#include"lexer.h"
#include"global.h"
#include<map>
using namespace std;
class NFA{
public:
Category type=EMPTY;
set<char> st;
char edge;
NFA* link1=nullptr;
NFA* link2=nullptr;
static int counter;
int id_num;
NFA();
void display();
string showEdgeInfo(Category cat,char edge);
};
class NFABuilder{
public:
Lexer lex;
pair<NFA*,NFA*> nfa_pair;
NFABuilder(string pat="");
NFA* build();
void term(pair<NFA*,NFA*>& npair);
bool nfa_sigchar(pair<NFA*,NFA*>& npair);
bool nfa_any_char(pair<NFA*,NFA*>& npair);
bool nfa_char_set(pair<NFA*,NFA*>& npair);
bool factor_conn(pair<NFA*,NFA*>& npair);
bool isconn(Token tk);
bool factor(pair<NFA*,NFA*>& npair);
void dash(set<char>& st);
bool closure(pair<NFA*,NFA*>& pair);
bool plus_closure(pair<NFA*,NFA*>& pair);
bool option_closure(pair<NFA*,NFA*>& pair);
bool expr(pair<NFA*,NFA*>& pair);
bool group(pair<NFA*,NFA*>& pair);
};
void move(set<NFA*>& st,char ch);
#endif