Added graphing
This commit is contained in:
@@ -0,0 +1,33 @@
|
|||||||
|
package com.imegumii;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by kenny on 18-5-2017.
|
||||||
|
*/
|
||||||
|
public class Graph {
|
||||||
|
|
||||||
|
public static String generateGraphString(Automata<String> a)
|
||||||
|
{
|
||||||
|
String text = "digraph finite_state_machine {\nrankdir=LR;\nsize=\"8,5\";\nnode [shape = doublecircle];";
|
||||||
|
|
||||||
|
for(String s : a.eindStates){
|
||||||
|
text += s + " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
text += ";\nnode [shape = circle];\n";
|
||||||
|
|
||||||
|
for(Transition<String> t : a.transistions)
|
||||||
|
{
|
||||||
|
String s = "";
|
||||||
|
if(t.symbol == Transition.EPSILON)
|
||||||
|
s = "$";
|
||||||
|
else
|
||||||
|
s = t.symbol + "";
|
||||||
|
|
||||||
|
text += t.vanState + " -> " + t.naarState + " [ label = \"" + s + "\"];\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
text += "}";
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -105,13 +105,16 @@ public class Main {
|
|||||||
RegExp expr3 = new RegExp("c");
|
RegExp expr3 = new RegExp("c");
|
||||||
RegExp expr4 = new RegExp("d");
|
RegExp expr4 = new RegExp("d");
|
||||||
|
|
||||||
RegExp expr5 = expr1.ster();
|
RegExp expr5 = expr1.of(expr2);
|
||||||
RegExp expr6 = expr3.plus();
|
RegExp expr6 = expr3.of(expr4);
|
||||||
|
|
||||||
RegExp expr7 = expr5.punt(expr6);
|
RegExp expr7 = expr5.punt(expr6);
|
||||||
|
|
||||||
NDFA<String> test = ThompsonConverter.Convert(expr7);
|
RegExp expr8 = expr7.ster();
|
||||||
test.printTransitions();
|
|
||||||
|
NDFA<String> test = ThompsonConverter.Convert(expr8);
|
||||||
|
|
||||||
|
System.out.println(Graph.generateGraphString(test));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Practicum4() {
|
public static void Practicum4() {
|
||||||
@@ -146,7 +149,7 @@ public class Main {
|
|||||||
// testreg.testLanguage();
|
// testreg.testLanguage();
|
||||||
|
|
||||||
|
|
||||||
System.out.println("Zo moet het dus, nu onze beurt.");
|
// System.out.println("Zo moet het dus, nu onze beurt.");
|
||||||
|
|
||||||
// Practicum1();
|
// Practicum1();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user