Fixed ThompsonConverter plus

This commit is contained in:
Yorick Rommers
2017-06-12 13:57:18 +02:00
parent 7bfb0d671d
commit 75ccde3834
4 changed files with 23 additions and 33 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ public class Main {
// System.out.println(reg.naarRegExp(s3).getTaal(10));
// System.out.println(reg.naarRegExp(s7).getTaal(10));
// Test.TestUitOpdrachtBeschrijving();
// Test.Thompson();
new Frame();
}
}
+4 -11
View File
@@ -160,19 +160,12 @@ public class Test {
}
public static void Thompson() {
RegExp expr1 = new RegExp("a");
RegExp expr2 = new RegExp("b");
RegExp expr3 = new RegExp("c");
RegExp expr4 = new RegExp("d");
RegExp expr1 = new RegExp();
expr1 = expr1.naarRegExp("a(abba|baab)*b+");
RegExp expr5 = expr1.of(expr2);
RegExp expr6 = expr3.of(expr4);
NDFA<String> test = ThompsonConverter.convert(expr1);
RegExp expr7 = expr5.punt(expr6);
NDFA<String> test = ThompsonConverter.convert(expr7);
System.out.println(Graph.generateGraphString(test));
Graph.generateImage(test, "thompson");
}
public static void Hopcroft()
-8
View File
@@ -1,8 +0,0 @@
package com.imegumii;
/**
* Created by imegumii on 08/06/2017.
*/
public class TestApplication {
}
+18 -13
View File
@@ -27,14 +27,19 @@ public class ThompsonConverter {
String endLink1 = automata.eindStates.first();
String beginLink1 = automata.beginStates.first();
//Repeat and skip
automata.addTransition(new Transition(endLink1, Transition.EPSILON, beginLink1));
String newstart = getState();
String newEnd = getState();
//Repeat
automata.addTransition(new Transition<String>(newstart, Transition.EPSILON, beginLink1));
automata.addTransition(new Transition<String>(endLink1, Transition.EPSILON, newEnd));
automata.addTransition(new Transition<String>(endLink1, Transition.EPSILON, beginLink1));
automata.clearEindStates();
automata.clearBeginStates();
automata.defineAsStartState(endLink1);
automata.defineAsEndState(beginLink1);
automata.defineAsStartState(newstart);
automata.defineAsEndState(newEnd);
break;
case STER:
@@ -49,10 +54,10 @@ public class ThompsonConverter {
String end2 = getState();
//Repeat and skip
automata.addTransition(new Transition(start2, Transition.EPSILON, end2));
automata.addTransition(new Transition(endLink2, Transition.EPSILON, beginLink2));
automata.addTransition(new Transition(start2, Transition.EPSILON, beginLink2));
automata.addTransition(new Transition(endLink2, Transition.EPSILON, end2));
automata.addTransition(new Transition<String>(start2, Transition.EPSILON, end2));
automata.addTransition(new Transition<String>(endLink2, Transition.EPSILON, beginLink2));
automata.addTransition(new Transition<String>(start2, Transition.EPSILON, beginLink2));
automata.addTransition(new Transition<String>(endLink2, Transition.EPSILON, end2));
automata.clearEindStates();
automata.clearBeginStates();
@@ -78,10 +83,10 @@ public class ThompsonConverter {
String end3 = getState();
//Link both
automata.addTransition(new Transition(start3, Transition.EPSILON, topBegin));
automata.addTransition(new Transition(start3, Transition.EPSILON, bottomBegin));
automata.addTransition(new Transition(topEnd, Transition.EPSILON, end3));
automata.addTransition(new Transition(bottomEnd, Transition.EPSILON, end3));
automata.addTransition(new Transition<String>(start3, Transition.EPSILON, topBegin));
automata.addTransition(new Transition<String>(start3, Transition.EPSILON, bottomBegin));
automata.addTransition(new Transition<String>(topEnd, Transition.EPSILON, end3));
automata.addTransition(new Transition<String>(bottomEnd, Transition.EPSILON, end3));
automata.clearEindStates();
automata.clearBeginStates();
@@ -104,7 +109,7 @@ public class ThompsonConverter {
String newEndLink = automata.eindStates.first();
//Link both
automata.addTransition(new Transition(endLink, Transition.EPSILON, beginLink));
automata.addTransition(new Transition<String>(endLink, Transition.EPSILON, beginLink));
automata.clearEindStates();
automata.clearBeginStates();