-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
82 lines (58 loc) · 1.77 KB
/
Copy pathmain.cpp
File metadata and controls
82 lines (58 loc) · 1.77 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <iostream>
#include "postfix.h"
#include "TreeNode.h"
#include "NFAgenerator.h"
#include "Simulation.h"
#include "Nfa2Dfa.h"
#include "tree2Dfa.h"
#include "writeTxt.h"
using namespace std;
int main(){
string sentence;
string sentence2;
string postfix;
string text;
string language;
cout <<"Escribir cadena ";
getline(cin, sentence2);
sentence = fix(sentence2);
cout << "Output =" << infix2Postfix(sentence) << "\n";
for(int i =0; i<sentence.size(); i++) {
if (isOperand(sentence[i])) {
if (language.find(sentence[i]) == string::npos) {
language += sentence[i];
}
}
}
cout <<"lenguaje contiene cadenas de " << language<< endl;
postfix = infix2Postfix(sentence);
stack < TreeNode * > t=postfix2Tree(postfix);
int tnum =0;
int *num = &tnum;
Automata *nfa = nfaGen(t.top(), num);
nfaWriter(nfa,language);
AutomataDfa *dfa = Nfa2Dfa(nfa,language);
dfaWriter(dfa,language);
cout <<"Escribir cadena a verificar ";
getline(cin, text);
if (nfaSimulation(text,nfa)==true){
cout << "El resultado con nfa es: si se acepta la cadena" << endl;
}
else if(nfaSimulation(text,nfa)==false) {
cout << "El resultado con nfa es: no se acepta la cadena" << endl;
}
cout <<"Escribir cadena a verificar ";
getline(cin, text);
if (dfaSimulation(text,dfa)==true){
cout << "El resultado con dfa es: si se acepta la cadena" << endl;
}
else if(dfaSimulation(text,dfa)==false) {
cout << "El resultado con dfa es: no se acepta la cadena" << endl;
}
nullable(t.top());
firstPos(t.top());
lastPos(t.top());
followPos(t.top());
// tree2Dfa2(t.top(),language);
return 0;
}