Attempt fix equals
This commit is contained in:
@@ -1,6 +0,0 @@
|
|||||||
DFA
|
|
||||||
B0
|
|
||||||
E1
|
|
||||||
0>a>1
|
|
||||||
1>a>2
|
|
||||||
2>a>2
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
DFA
|
|
||||||
B0
|
|
||||||
E1
|
|
||||||
0>b>1
|
|
||||||
1>b>2
|
|
||||||
2>b>2
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
NDFA
|
|
||||||
Bq1
|
|
||||||
Eq6
|
|
||||||
q1>ε>q2
|
|
||||||
q2>ε>q3
|
|
||||||
q3>ε>q4
|
|
||||||
q4>ε>q5
|
|
||||||
q5>a>q6
|
|
||||||
@@ -117,20 +117,26 @@ public class Automata <T extends Comparable> extends Importable {
|
|||||||
if(!(obj instanceof Automata))
|
if(!(obj instanceof Automata))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(this.type != ((Automata<T>)obj).type)
|
Automata<T> other = (Automata<T>) obj;
|
||||||
return false;
|
|
||||||
|
|
||||||
DFA<String> dfa1;
|
DFA<String> dfa1;
|
||||||
DFA<String> dfa2;
|
DFA<String> dfa2;
|
||||||
|
|
||||||
if(this.type == Type.NDFA)
|
if(this.type == Type.NDFA)
|
||||||
{
|
{
|
||||||
dfa1 = ((NDFA<T>)this).toDFA().minimaliseerHopcroft();
|
dfa1 = ((NDFA<String>)this).toDFA().minimaliseerHopcroft();
|
||||||
dfa2 = ((NDFA<T>) obj).toDFA().minimaliseerHopcroft();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dfa1 = ((DFA<String>)this).minimaliseerHopcroft();
|
dfa1 = ((DFA<String>)this).minimaliseerHopcroft();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(other.type == Type.NDFA)
|
||||||
|
{
|
||||||
|
dfa2 = ((NDFA<String>) obj).toDFA().minimaliseerHopcroft();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
dfa2 = ((DFA<String>) obj).minimaliseerHopcroft();
|
dfa2 = ((DFA<String>) obj).minimaliseerHopcroft();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,6 +100,26 @@ public class DFA<T extends Comparable> extends Automata<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DFA<T> ontkenning() {
|
public DFA<T> ontkenning() {
|
||||||
|
|
||||||
|
DFA<T> result = new DFA<T>();
|
||||||
|
|
||||||
|
for(Transition<T> t : this.transistions)
|
||||||
|
{
|
||||||
|
result.addTransition(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(T s : this.eindStates)
|
||||||
|
{
|
||||||
|
result.defineAsStartState(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(T s : this.beginStates)
|
||||||
|
{
|
||||||
|
result.defineAsEndState(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
/*
|
||||||
DFA<T> returnDFA = new DFA<T>();
|
DFA<T> returnDFA = new DFA<T>();
|
||||||
|
|
||||||
SortedSet<T> newEndStates = new TreeSet<>();
|
SortedSet<T> newEndStates = new TreeSet<>();
|
||||||
@@ -122,7 +142,7 @@ public class DFA<T extends Comparable> extends Automata<T> {
|
|||||||
returnDFA.addTransition(transistion);
|
returnDFA.addTransition(transistion);
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnDFA;
|
return returnDFA;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public DFA<String> en(DFA<T> other)
|
public DFA<String> en(DFA<T> other)
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ public class Graph {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
MutableGraph g = Parser.read(Graph.generateImageString(a));
|
MutableGraph g = Parser.read(Graph.generateImageString(a));
|
||||||
Graphviz.fromGraph(g).width(Math.max(a.states.size() * 150, 750)).render(Format.PNG).toFile(f);
|
Graphviz.fromGraph(g).width(Math.min(15000, Math.max(a.states.size() * 150, 750))).render(Format.PNG).toFile(f);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -321,9 +321,75 @@ public class InputPanel extends JPanel {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
JButton equalsButton = new JButton("equals");
|
||||||
|
equalsButton.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
|
BackgroundWorker.instance().addWorker(new BackgroundWorker.Worker() {
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
StatusPanel.Instance().setStatus("Parsing files", 10);
|
||||||
|
|
||||||
|
String file1 = (String)f1Combo.getSelectedItem();
|
||||||
|
String name1 = file1.replaceAll(".dot", "");
|
||||||
|
String file2 = (String)f2Combo.getSelectedItem();
|
||||||
|
String name2 = file2.replaceAll(".dot", "");
|
||||||
|
|
||||||
|
Importable p1 = FileParser.read(file1);
|
||||||
|
Importable p2 = FileParser.read(file1);
|
||||||
|
|
||||||
|
Automata<String> aut = null;
|
||||||
|
|
||||||
|
if(p1.type == Importable.Type.NDFA )
|
||||||
|
{
|
||||||
|
aut = (NDFA<String>)p1;
|
||||||
|
}
|
||||||
|
if(p1.type == Importable.Type.DFA)
|
||||||
|
{
|
||||||
|
aut = (DFA<String>)p1;
|
||||||
|
}
|
||||||
|
if(p1.type == Importable.Type.REGEX)
|
||||||
|
{
|
||||||
|
StatusPanel.Instance().setStatus("Converting REGEX to NDFA", 30);
|
||||||
|
RegExp regex = (RegExp) p1;
|
||||||
|
aut = (NDFA<String>)ThompsonConverter.convert(regex);
|
||||||
|
}
|
||||||
|
|
||||||
|
Automata<String> aut2 = null;
|
||||||
|
|
||||||
|
if(p2.type == Importable.Type.NDFA)
|
||||||
|
{
|
||||||
|
aut2 = (NDFA<String>)p2;
|
||||||
|
}
|
||||||
|
if(p2.type == Importable.Type.DFA)
|
||||||
|
{
|
||||||
|
aut2 = (DFA<String>)p2;
|
||||||
|
}
|
||||||
|
if(p2.type == Importable.Type.REGEX)
|
||||||
|
{
|
||||||
|
StatusPanel.Instance().setStatus("Converting REGEX to NDFA", 50);
|
||||||
|
RegExp regex2 = (RegExp) p2;
|
||||||
|
aut2 = (NDFA<String>)ThompsonConverter.convert(regex2);
|
||||||
|
}
|
||||||
|
|
||||||
|
StatusPanel.Instance().setStatus("Executing equals operation", 80);
|
||||||
|
|
||||||
|
boolean equals = aut.equals(aut2);
|
||||||
|
|
||||||
|
new TextPanel(name1 + " equals " + name2, (equals?"They are equal":"They are not equal"));
|
||||||
|
|
||||||
|
StatusPanel.Instance().setStatus("Done", 100);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
advPanel.add(f1Combo);
|
advPanel.add(f1Combo);
|
||||||
advPanel.add(Box.createRigidArea(new Dimension(10, 0)));
|
advPanel.add(Box.createRigidArea(new Dimension(10, 0)));
|
||||||
|
|
||||||
|
advPanel.add(equalsButton);
|
||||||
|
advPanel.add(Box.createRigidArea(new Dimension(10, 0)));
|
||||||
advPanel.add(andButton);
|
advPanel.add(andButton);
|
||||||
advPanel.add(Box.createRigidArea(new Dimension(10, 0)));
|
advPanel.add(Box.createRigidArea(new Dimension(10, 0)));
|
||||||
advPanel.add(orButton);
|
advPanel.add(orButton);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.imegumii.ui;
|
package com.imegumii.ui;
|
||||||
|
|
||||||
import com.imegumii.*;
|
import com.imegumii.*;
|
||||||
import com.sun.tools.internal.ws.wsdl.document.Import;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.border.Border;
|
import javax.swing.border.Border;
|
||||||
|
|||||||
Reference in New Issue
Block a user