-
Notifications
You must be signed in to change notification settings - Fork 3
/
nfa.h
60 lines (38 loc) · 1.64 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Created by omar_swidan on 23/03/20.
//
#ifndef LEXGEN_NFA_H
#define LEXGEN_NFA_H
using namespace std;
#include <iostream>
#include<stack>
#include <string>
#include <unordered_set>
#include "nfa_state.h"
class NFA {
public:
NFA();
NFAState *regex_to_nfa(std::unordered_set<std::string> input_table, std::vector<RegularExpression> regex);
unordered_set<string> get_input_table();
private:
NFAState *concat(NFAState *first_nfa_state, NFAState *second_nfa_state,
unordered_map<NFAState *, NFAState *> *start_to_acceptance_map
, bool final_finish_state);
NFAState *or_combiner(NFAState *first_nfa_state, NFAState *second_nfa_state,
unordered_map<NFAState *, NFAState *> *start_to_acceptance_map
, bool final_finish_state);
NFAState *
kleene_and_plus(NFAState *nfa_state, unordered_map<NFAState *, NFAState *> *start_to_acceptance_map
, bool kleene,
bool final_finish_state);
NFAState *
construct_one_transition_state(string transition, unordered_map<NFAState *, NFAState *> *start_to_acceptance_map,
bool final_finish_state);
NFAState *postfix_to_NFA(string postfix, unordered_set<string> input_table, string regex_name,int priority);
string resolve_backslash(string transition);
unordered_set<string> resolve_input_table(unordered_set<string> input_table);
NFAState *acceptance_state_generator(bool final_finish_state);
bool isOperator(char character);
void set_input_table(unordered_set<string> input_table);
unordered_set<string> input_table;
};
#endif //LEXGEN_NFA_H