-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
56 lines (40 loc) · 1.31 KB
/
main.cpp
File metadata and controls
56 lines (40 loc) · 1.31 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
#include <iostream>
#include "lexer.hpp"
#include "parser.hpp"
#include "eval.hpp"
#include "cnf.hpp"
// TODO: before abort() delete all alocate memory
// TODO: incapsulate - add private and public methods plz
// TODO: kings don't rule forever, my son - add inheritance in parser and lexer
int main () {
char str[256] = {};
if (fgets(str, 255, stdin) == nullptr)
abort();
std::cout << "TEST : " << str << std::endl;
lex_array_t array(str);
if (array.lexems_ == nullptr) return 0;
std::cout << "lexer result: " ;
for (int i = 0; i < array.size_; ++i) {
std::cout << "< " << array.lexems_[i] << " > " ;
}
std::cout << std::endl;
syntax_tree_t result(array);
if (result.root_ == nullptr) return 0;
std::cout << "parser result: " ;
result.show();
std::cout << "eval result: " ;
eval_t whoami(result);
std::cout << "is form TAUT?: " << whoami.is_TAUT() << std::endl;
std::cout << "is form SAT ?: " << whoami.is_SAT () << std::endl;
syntax_tree_t *cnf = whoami.cnf_form(&result);
cnf_t *cnf_2 = new cnf_t ();
create_cnf_(cnf_2, cnf->root_);
printf("cnf_form:\n");
cnf_2->print();
cnf_2->_3form();
printf("3_cnf form: \n");
cnf_2->print();
std::cout << "DPLL RESULT : " << DPLL(*cnf_2) << std::endl;
//std::cout << << std::endl;
return 0;
}