-
Notifications
You must be signed in to change notification settings - Fork 5
/
JFSM.java
96 lines (78 loc) · 2.5 KB
/
JFSM.java
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
/**
*
* Copyright (C) 2017 Emmanuel DESMONTILS
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of the
* License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
*
*
* E-mail:
*
*
**/
/**
* JFSM.java
*
*
* Created: 2017-08-25
*
* @author Emmanuel Desmontils
* @version 1.0
*/
import java.util.Set;
import java.util.HashSet;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import JFSM.*;
import JFSM.Transducteur.*;
public class JFSM {
public static void main(String argv []) throws JFSMException {
Set<String> A = new HashSet<String>();
A.add("a");A.add("b");A.add("c");
Set<Etat> Q = new HashSet<Etat>();
Q.add(new Etat("1"));Q.add(new Etat("2"));
Q.add(new Etat("3"));Q.add(new Etat("4"));Q.add(new Etat("5"));
Set<Transition> mu = new HashSet<Transition>();
mu.add(new Transition("1","a","2"));
mu.add(new Transition("1","b","4"));
mu.add(new Transition("2","b","3"));
mu.add(new Transition("2","c","4"));
mu.add(new Transition("3","a","2"));
mu.add(new Transition("3","b","4"));
mu.add(new Transition("4","a","5"));
mu.add(new Transition("5","c","5"));
Set<String> F = new HashSet<String>();
F.add("5");
F.add("4");
F.add("1");
Automate afn = new AFD(A, Q, "1", F, mu);
List<String> l = new ArrayList<String>();
l.add("a");l.add("b");l.add("a");l.add("c");
System.out.println(afn);
System.out.println(afn.run(l));
System.out.println(afn.emonder());
System.out.println(afn);
System.out.println("Epsilon Libre ? "+afn.epsilonLibre());
afn.save("test.jff");
Automate afn2 = Automate.load("essai.jff");
System.out.println(afn2.getClass().getName());
System.out.println(afn2);
}
}