-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautomatas.c
139 lines (90 loc) · 3.95 KB
/
automatas.c
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "alfabeto.h"
#include "estado.h"
#include "afnd.h"
#include "palabra.h"
int main(int argc, char ** argv)
{
AFND * p_afnd_l;
p_afnd_l = AFNDNuevo("afl1",8,2);
AFNDInsertaSimbolo(p_afnd_l,"0");
AFNDInsertaSimbolo(p_afnd_l,"1");
AFNDInsertaEstado(p_afnd_l,"q0",INICIAL);
AFNDInsertaEstado(p_afnd_l,"q1",NORMAL);
AFNDInsertaEstado(p_afnd_l,"q2",NORMAL);
AFNDInsertaEstado(p_afnd_l,"q3",NORMAL);
AFNDInsertaEstado(p_afnd_l,"q4",FINAL);
AFNDInsertaEstado(p_afnd_l,"q5",NORMAL);
AFNDInsertaEstado(p_afnd_l,"q6",NORMAL);
AFNDInsertaEstado(p_afnd_l,"q7",FINAL);
AFNDInsertaTransicion(p_afnd_l, "q1", "1", "q1");
AFNDInsertaTransicion(p_afnd_l, "q2", "0", "q3");
AFNDInsertaTransicion(p_afnd_l, "q3", "0", "q4");
AFNDInsertaTransicion(p_afnd_l, "q5", "1", "q6");
AFNDInsertaTransicion(p_afnd_l, "q6", "1", "q7");
AFNDInsertaTransicion(p_afnd_l, "q7", "0", "q7");
AFNDInsertaTransicion(p_afnd_l, "q7", "1", "q7");
AFNDInsertaLTransicion(p_afnd_l, "q0", "q1");
AFNDInsertaLTransicion(p_afnd_l, "q0", "q5");
AFNDInsertaLTransicion(p_afnd_l, "q1", "q2");
AFNDInsertaLTransicion(p_afnd_l, "q4", "q2");
AFNDCierraLTransicion(p_afnd_l);
//relacionImprime(stdout,p_afnd_l->lambdaTransiciones );
relacionImprime_teorico(stdout,p_afnd_l->lambdaTransiciones );
AFNDImprime(stdout,p_afnd_l);
AFNDInsertaLetra(p_afnd_l,"1");
AFNDInsertaLetra(p_afnd_l,"1");
AFNDInsertaLetra(p_afnd_l,"1");
AFNDInsertaLetra(p_afnd_l,"1");
AFNDInsertaLetra(p_afnd_l,"0");
AFNDInsertaLetra(p_afnd_l,"0");
p_afnd_l = AFNDInicializaEstado(p_afnd_l);
fprintf(stdout,"\n**************** PROCESA CADENA *************\n");
AFNDImprimeCadenaActual(stdout,p_afnd_l);
fprintf(stdout,"\n*********************************************\n");
AFNDProcesaEntrada(stdout,p_afnd_l);
/*********************************************************************************/
p_afnd_l = AFNDInicializaCadenaActual(p_afnd_l);
AFNDInsertaLetra(p_afnd_l,"1");
AFNDInsertaLetra(p_afnd_l,"0");
AFNDInsertaLetra(p_afnd_l,"0");
AFNDInsertaLetra(p_afnd_l,"0");
AFNDInsertaLetra(p_afnd_l,"0");
AFNDInsertaLetra(p_afnd_l,"0");
AFNDInsertaLetra(p_afnd_l,"0");
p_afnd_l = AFNDInicializaEstado(p_afnd_l);
fprintf(stdout,"\n**************** PROCESA CADENA *************\n");
AFNDProcesaEntrada(stdout,p_afnd_l);
fprintf(stdout,"\n*********************************************\n");
/*********************************************************************************/
p_afnd_l = AFNDInicializaCadenaActual(p_afnd_l);
AFNDInsertaLetra(p_afnd_l,"1");
AFNDInsertaLetra(p_afnd_l,"1");
AFNDInsertaLetra(p_afnd_l,"0");
AFNDInsertaLetra(p_afnd_l,"0");
AFNDInsertaLetra(p_afnd_l,"0");
p_afnd_l = AFNDInicializaEstado(p_afnd_l);
fprintf(stdout,"\n**************** PROCESA CADENA *************\n");
AFNDProcesaEntrada(stdout,p_afnd_l);
fprintf(stdout,"\n*********************************************\n");
/*********************************************************************************/
p_afnd_l = AFNDInicializaCadenaActual(p_afnd_l);
AFNDInsertaLetra(p_afnd_l,"0");
AFNDInsertaLetra(p_afnd_l,"1");
AFNDInsertaLetra(p_afnd_l,"0");
AFNDInsertaLetra(p_afnd_l,"1");
AFNDInsertaLetra(p_afnd_l,"0");
AFNDInsertaLetra(p_afnd_l,"1");
AFNDInsertaLetra(p_afnd_l,"0");
AFNDInsertaLetra(p_afnd_l,"1");
p_afnd_l = AFNDInicializaEstado(p_afnd_l);
fprintf(stdout,"\n**************** PROCESA CADENA *************\n");
AFNDProcesaEntrada(stdout,p_afnd_l);
fprintf(stdout,"\n*********************************************\n");
/*********************************************************************************/
AFNDElimina(p_afnd_l);
/********************************************************************************/
return 0;
}