Merge remote-tracking branch 'origin/main'
# Conflicts: # .idea/workspace.xml # src/test/java/ab1/tests/GRUPPE/MyTests.java
This commit is contained in:
commit
aed2d4170d
15 changed files with 452 additions and 218 deletions
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
|
|
@ -7,7 +7,6 @@
|
||||||
<option value="$PROJECT_DIR$/pom.xml" />
|
<option value="$PROJECT_DIR$/pom.xml" />
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
<option name="workspaceImportForciblyTurnedOn" value="true" />
|
|
||||||
</component>
|
</component>
|
||||||
<component name="PWA">
|
<component name="PWA">
|
||||||
<option name="wasEnabledAtLeastOnce" value="true" />
|
<option name="wasEnabledAtLeastOnce" value="true" />
|
||||||
|
|
|
||||||
124
.idea/uiDesigner.xml
generated
Normal file
124
.idea/uiDesigner.xml
generated
Normal file
|
|
@ -0,0 +1,124 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Palette2">
|
||||||
|
<group name="Swing">
|
||||||
|
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Button" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="RadioButton" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="CheckBox" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Label" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||||
|
<preferred-size width="-1" height="20" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
</group>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
128
.idea/workspace.xml
generated
128
.idea/workspace.xml
generated
|
|
@ -4,10 +4,8 @@
|
||||||
<option name="autoReloadType" value="SELECTIVE" />
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" name="Changes" comment="just some fancy shit added">
|
<list default="true" id="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" name="Changes" comment="documentation. cleanup. your turn daniel">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main/java/ab1/impl/gruppe10_aigensberger_dworski_walcher/NFAImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/ab1/impl/gruppe10_aigensberger_dworski_walcher/NFAImpl.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/java/ab1/impl/GRUPPE/NFAImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/ab1/impl/GRUPPE/NFAImpl.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/test/java/ab1/tests/myTests.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/test/java/ab1/tests/myTests.java" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<list id="39d4ccb3-eae9-4ed4-996a-5a13f44678fa" name="Changes by carol" comment="" />
|
<list id="39d4ccb3-eae9-4ed4-996a-5a13f44678fa" name="Changes by carol" comment="" />
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
|
|
@ -64,12 +62,10 @@
|
||||||
"JUnit.ComplexTests.finite2Test.executor": "Debug",
|
"JUnit.ComplexTests.finite2Test.executor": "Debug",
|
||||||
"JUnit.ComplexTests.intersection1Test.executor": "Run",
|
"JUnit.ComplexTests.intersection1Test.executor": "Run",
|
||||||
"JUnit.ComplexTests.intersection2Test.executor": "Run",
|
"JUnit.ComplexTests.intersection2Test.executor": "Run",
|
||||||
"JUnit.myTests.executor": "Run",
|
|
||||||
"JUnit.myTests.intersection1Test.executor": "Run",
|
"JUnit.myTests.intersection1Test.executor": "Run",
|
||||||
"JUnit.myTests.myTest_1.executor": "Run",
|
|
||||||
"JUnit.myTests.myTest_2.executor": "Run",
|
|
||||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
|
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||||
"WebServerToolWindowFactoryState": "false",
|
"WebServerToolWindowFactoryState": "false",
|
||||||
"full.screen.before.presentation.mode": "false",
|
"full.screen.before.presentation.mode": "false",
|
||||||
"git-widget-placeholder": "main",
|
"git-widget-placeholder": "main",
|
||||||
|
|
@ -86,12 +82,12 @@
|
||||||
"vue.rearranger.settings.migration": "true"
|
"vue.rearranger.settings.migration": "true"
|
||||||
}
|
}
|
||||||
}]]></component>
|
}]]></component>
|
||||||
<component name="RunManager" selected="JUnit.myTests">
|
<component name="RunManager" selected="JUnit.tests in ETI_Abgabe">
|
||||||
<configuration name="ComplexTests" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
|
<configuration name="ComplexTests" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
|
||||||
<module name="ETI_Abgabe" />
|
<module name="ETI_Abgabe" />
|
||||||
<extension name="coverage">
|
<extension name="coverage">
|
||||||
<pattern>
|
<pattern>
|
||||||
<option name="PATTERN" value="ab1.tests.*" />
|
<option name="PATTERN" value="ab1.tests.GRUPPE.*" />
|
||||||
<option name="ENABLED" value="true" />
|
<option name="ENABLED" value="true" />
|
||||||
</pattern>
|
</pattern>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
@ -102,11 +98,27 @@
|
||||||
<option name="Make" enabled="true" />
|
<option name="Make" enabled="true" />
|
||||||
</method>
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
<configuration name="ComplexTests.finite1Test" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
|
||||||
|
<module name="ETI_Abgabe" />
|
||||||
|
<extension name="coverage">
|
||||||
|
<pattern>
|
||||||
|
<option name="PATTERN" value="ab1.tests.GRUPPE.*" />
|
||||||
|
<option name="ENABLED" value="true" />
|
||||||
|
</pattern>
|
||||||
|
</extension>
|
||||||
|
<option name="PACKAGE_NAME" value="ab1.tests" />
|
||||||
|
<option name="MAIN_CLASS_NAME" value="ab1.tests.ComplexTests" />
|
||||||
|
<option name="METHOD_NAME" value="finite1Test" />
|
||||||
|
<option name="TEST_OBJECT" value="method" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="Make" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
<configuration name="ComplexTests.finite2Test" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
|
<configuration name="ComplexTests.finite2Test" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
|
||||||
<module name="ETI_Abgabe" />
|
<module name="ETI_Abgabe" />
|
||||||
<extension name="coverage">
|
<extension name="coverage">
|
||||||
<pattern>
|
<pattern>
|
||||||
<option name="PATTERN" value="ab1.tests.*" />
|
<option name="PATTERN" value="ab1.tests.GRUPPE.*" />
|
||||||
<option name="ENABLED" value="true" />
|
<option name="ENABLED" value="true" />
|
||||||
</pattern>
|
</pattern>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
@ -118,49 +130,26 @@
|
||||||
<option name="Make" enabled="true" />
|
<option name="Make" enabled="true" />
|
||||||
</method>
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
<configuration name="myTests" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
|
<configuration name="ComplexTests.intersection2Test" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
|
||||||
<module name="ETI_Abgabe" />
|
<module name="ETI_Abgabe" />
|
||||||
<extension name="coverage">
|
<extension name="coverage">
|
||||||
<pattern>
|
<pattern>
|
||||||
<option name="PATTERN" value="ab1.tests.*" />
|
<option name="PATTERN" value="ab1.tests.GRUPPE.*" />
|
||||||
<option name="ENABLED" value="true" />
|
<option name="ENABLED" value="true" />
|
||||||
</pattern>
|
</pattern>
|
||||||
</extension>
|
</extension>
|
||||||
<option name="PACKAGE_NAME" value="ab1.tests" />
|
<option name="PACKAGE_NAME" value="ab1.tests" />
|
||||||
<option name="MAIN_CLASS_NAME" value="ab1.tests.myTests" />
|
<option name="MAIN_CLASS_NAME" value="ab1.tests.ComplexTests" />
|
||||||
<option name="TEST_OBJECT" value="class" />
|
<option name="METHOD_NAME" value="intersection2Test" />
|
||||||
<method v="2">
|
|
||||||
<option name="Make" enabled="true" />
|
|
||||||
</method>
|
|
||||||
</configuration>
|
|
||||||
<configuration name="myTests.myTest_1" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
|
|
||||||
<module name="ETI_Abgabe" />
|
|
||||||
<extension name="coverage">
|
|
||||||
<pattern>
|
|
||||||
<option name="PATTERN" value="ab1.tests.*" />
|
|
||||||
<option name="ENABLED" value="true" />
|
|
||||||
</pattern>
|
|
||||||
</extension>
|
|
||||||
<option name="PACKAGE_NAME" value="ab1.tests" />
|
|
||||||
<option name="MAIN_CLASS_NAME" value="ab1.tests.myTests" />
|
|
||||||
<option name="METHOD_NAME" value="myTest_1" />
|
|
||||||
<option name="TEST_OBJECT" value="method" />
|
<option name="TEST_OBJECT" value="method" />
|
||||||
<method v="2">
|
<method v="2">
|
||||||
<option name="Make" enabled="true" />
|
<option name="Make" enabled="true" />
|
||||||
</method>
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
<configuration name="myTests.myTest_2" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
|
<configuration name="tests in ETI_Abgabe" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
|
||||||
<module name="ETI_Abgabe" />
|
<module name="ETI_Abgabe" />
|
||||||
<extension name="coverage">
|
<option name="TEST_OBJECT" value="directory" />
|
||||||
<pattern>
|
<dir value="$PROJECT_DIR$/src/test/java/ab1/tests" />
|
||||||
<option name="PATTERN" value="ab1.tests.*" />
|
|
||||||
<option name="ENABLED" value="true" />
|
|
||||||
</pattern>
|
|
||||||
</extension>
|
|
||||||
<option name="PACKAGE_NAME" value="ab1.tests" />
|
|
||||||
<option name="MAIN_CLASS_NAME" value="ab1.tests.myTests" />
|
|
||||||
<option name="METHOD_NAME" value="myTest_2" />
|
|
||||||
<option name="TEST_OBJECT" value="method" />
|
|
||||||
<method v="2">
|
<method v="2">
|
||||||
<option name="Make" enabled="true" />
|
<option name="Make" enabled="true" />
|
||||||
</method>
|
</method>
|
||||||
|
|
@ -178,11 +167,11 @@
|
||||||
</configuration>
|
</configuration>
|
||||||
<recent_temporary>
|
<recent_temporary>
|
||||||
<list>
|
<list>
|
||||||
<item itemvalue="JUnit.myTests" />
|
<item itemvalue="JUnit.tests in ETI_Abgabe" />
|
||||||
<item itemvalue="JUnit.myTests.myTest_2" />
|
|
||||||
<item itemvalue="JUnit.ComplexTests" />
|
<item itemvalue="JUnit.ComplexTests" />
|
||||||
<item itemvalue="JUnit.myTests.myTest_1" />
|
|
||||||
<item itemvalue="JUnit.ComplexTests.finite2Test" />
|
<item itemvalue="JUnit.ComplexTests.finite2Test" />
|
||||||
|
<item itemvalue="JUnit.ComplexTests.finite1Test" />
|
||||||
|
<item itemvalue="JUnit.ComplexTests.intersection2Test" />
|
||||||
</list>
|
</list>
|
||||||
</recent_temporary>
|
</recent_temporary>
|
||||||
</component>
|
</component>
|
||||||
|
|
@ -278,23 +267,39 @@
|
||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1704888180655</updated>
|
<updated>1704888180655</updated>
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00010" summary="guess what works now, fker:)">
|
<task id="LOCAL-00010" summary=".">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
<created>1704896842030</created>
|
<created>1704914901826</created>
|
||||||
<option name="number" value="00010" />
|
<option name="number" value="00010" />
|
||||||
<option name="presentableId" value="LOCAL-00010" />
|
<option name="presentableId" value="LOCAL-00010" />
|
||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1704896842030</updated>
|
<updated>1704914901826</updated>
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00011" summary="just some fancy shit added">
|
<task id="LOCAL-00011" summary=".">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
<created>1704898189901</created>
|
<created>1704914909876</created>
|
||||||
<option name="number" value="00011" />
|
<option name="number" value="00011" />
|
||||||
<option name="presentableId" value="LOCAL-00011" />
|
<option name="presentableId" value="LOCAL-00011" />
|
||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1704898189902</updated>
|
<updated>1704914909876</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="12" />
|
<task id="LOCAL-00012" summary="documentation. cleanup. your turn daniel">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1704915995807</created>
|
||||||
|
<option name="number" value="00012" />
|
||||||
|
<option name="presentableId" value="LOCAL-00012" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1704915995807</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00013" summary="documentation. cleanup. your turn daniel">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1704916397835</created>
|
||||||
|
<option name="number" value="00013" />
|
||||||
|
<option name="presentableId" value="LOCAL-00013" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1704916397835</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="14" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
|
|
@ -319,27 +324,28 @@
|
||||||
<MESSAGE value="concat GEHT" />
|
<MESSAGE value="concat GEHT" />
|
||||||
<MESSAGE value="changed nfaAddTrap, bei dem Fall, dass Transition.readSymbol() einen nullwert zurückgibt. (Thx ChatGBT) -> intersectionTests funktionieren" />
|
<MESSAGE value="changed nfaAddTrap, bei dem Fall, dass Transition.readSymbol() einen nullwert zurückgibt. (Thx ChatGBT) -> intersectionTests funktionieren" />
|
||||||
<MESSAGE value="isFinite methode recursiv..." />
|
<MESSAGE value="isFinite methode recursiv..." />
|
||||||
<MESSAGE value="guess what works now, fker:)" />
|
<MESSAGE value="." />
|
||||||
<MESSAGE value="just some fancy shit added" />
|
<MESSAGE value="documentation. cleanup. your turn daniel" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="just some fancy shit added" />
|
<option name="LAST_COMMIT_MESSAGE" value="documentation. cleanup. your turn daniel" />
|
||||||
</component>
|
</component>
|
||||||
<component name="XDebuggerManager">
|
<component name="XDebuggerManager">
|
||||||
<breakpoint-manager>
|
<breakpoint-manager>
|
||||||
<breakpoints>
|
<breakpoints>
|
||||||
<line-breakpoint enabled="true" type="java-line">
|
<line-breakpoint enabled="true" type="java-line">
|
||||||
<url>file://$PROJECT_DIR$/src/main/java/ab1/impl/GRUPPE/NFAImpl.java</url>
|
<url>file://$PROJECT_DIR$/src/main/java/ab1/impl/gruppe10_aigensberger_dworski_walcher/NFAImpl.java</url>
|
||||||
<line>343</line>
|
<line>324</line>
|
||||||
<option name="timeStamp" value="44" />
|
<option name="timeStamp" value="44" />
|
||||||
</line-breakpoint>
|
</line-breakpoint>
|
||||||
<line-breakpoint enabled="true" type="java-line">
|
<line-breakpoint enabled="true" type="java-line">
|
||||||
<url>file://$PROJECT_DIR$/src/main/java/ab1/impl/GRUPPE/NFAImpl.java</url>
|
<url>file://$PROJECT_DIR$/src/main/java/ab1/impl/gruppe10_aigensberger_dworski_walcher/NFAImpl.java</url>
|
||||||
<line>355</line>
|
<line>336</line>
|
||||||
<option name="timeStamp" value="53" />
|
<option name="timeStamp" value="53" />
|
||||||
</line-breakpoint>
|
</line-breakpoint>
|
||||||
<breakpoint enabled="true" type="java-exception">
|
<line-breakpoint enabled="true" type="java-line">
|
||||||
<properties class="ab1.FinalizedStateException" package="ab1" />
|
<url>file://$PROJECT_DIR$/src/test/java/ab1/tests/ComplexTests.java</url>
|
||||||
<option name="timeStamp" value="62" />
|
<line>141</line>
|
||||||
</breakpoint>
|
<option name="timeStamp" value="59" />
|
||||||
|
</line-breakpoint>
|
||||||
</breakpoints>
|
</breakpoints>
|
||||||
</breakpoint-manager>
|
</breakpoint-manager>
|
||||||
<watches-manager>
|
<watches-manager>
|
||||||
|
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
package ab1.impl.GRUPPE;
|
|
||||||
|
|
||||||
public class Tuple {
|
|
||||||
private Character element_1;
|
|
||||||
|
|
||||||
public Character getElement_1() {
|
|
||||||
return element_1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setElement_1(Character element_1) {
|
|
||||||
this.element_1 = element_1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getElement_2() {
|
|
||||||
return element_2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setElement_2(String element_2) {
|
|
||||||
this.element_2 = element_2;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String element_2;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Tuple(Character firstElement, String secondElement){
|
|
||||||
this.element_1=firstElement;
|
|
||||||
this.element_2=secondElement;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,11 +1,17 @@
|
||||||
package ab1.impl.GRUPPE;
|
package ab1.impl.gruppe10_aigensberger_dworski_walcher;
|
||||||
|
|
||||||
import ab1.NFA;
|
import ab1.NFA;
|
||||||
import ab1.NFAFactory;
|
import ab1.NFAFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of NFAFactory
|
||||||
|
*/
|
||||||
public class NFAFactoryImpl implements NFAFactory {
|
public class NFAFactoryImpl implements NFAFactory {
|
||||||
@Override
|
@Override
|
||||||
public NFA buildNFA(String startState) {
|
public NFA buildNFA(String startState) {
|
||||||
|
if (startState == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return new NFAImpl(startState);
|
return new NFAImpl(startState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,12 +1,16 @@
|
||||||
package ab1.impl.GRUPPE;
|
package ab1.impl.gruppe10_aigensberger_dworski_walcher;
|
||||||
|
|
||||||
import ab1.FinalizedStateException;
|
import ab1.FinalizedStateException;
|
||||||
import ab1.NFA;
|
import ab1.NFA;
|
||||||
import ab1.Transition;
|
import ab1.Transition;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of the NFA interface.
|
||||||
|
*/
|
||||||
public class NFAImpl implements NFA {
|
public class NFAImpl implements NFA {
|
||||||
private final Set<String> states;
|
private final Set<String> states;
|
||||||
private final Set<Transition> transitions;
|
private final Set<Transition> transitions;
|
||||||
|
|
@ -14,7 +18,8 @@ public class NFAImpl implements NFA {
|
||||||
private final String initialState;
|
private final String initialState;
|
||||||
private final Set<String> acceptingStates;
|
private final Set<String> acceptingStates;
|
||||||
|
|
||||||
private Set<Character> alphabet;
|
@Getter
|
||||||
|
private final Set<Character> alphabet;
|
||||||
|
|
||||||
private final Set<Character> completeAlphabet;
|
private final Set<Character> completeAlphabet;
|
||||||
private boolean isFinalized;
|
private boolean isFinalized;
|
||||||
|
|
@ -39,14 +44,6 @@ public class NFAImpl implements NFA {
|
||||||
return this.states;
|
return this.states;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public void safeAddStates(Set<String> states, Set<String> toCheck, NFAImpl nfa) {
|
|
||||||
for (String state : states) {
|
|
||||||
nfa.states.add(changeIfNecessary(state, toCheck));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Transition> getTransitions() {
|
public Collection<Transition> getTransitions() {
|
||||||
return this.transitions;
|
return this.transitions;
|
||||||
|
|
@ -62,28 +59,34 @@ public class NFAImpl implements NFA {
|
||||||
return this.initialState;
|
return this.initialState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Character> getAlphabet() {
|
/**
|
||||||
return this.alphabet;
|
* Adds a new transition to the automaton. If the automaton is already finalized, a FinalizedStateException is thrown.
|
||||||
}
|
* @param transition The transition to add
|
||||||
|
* @throws FinalizedStateException If the automaton is already finalized
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addTransition(Transition transition) throws FinalizedStateException {
|
public void addTransition(Transition transition) throws FinalizedStateException {
|
||||||
if (this.isFinalized) {
|
if (this.isFinalized) {
|
||||||
throw new FinalizedStateException();
|
throw new FinalizedStateException();
|
||||||
}
|
}
|
||||||
if (!states.contains(transition.fromState())) {
|
if (transition == null || transition.fromState() == null || transition.toState() == null) {
|
||||||
this.states.add(transition.fromState());
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
if (!states.contains(transition.toState())) {
|
|
||||||
this.states.add(transition.toState());
|
states.add(transition.fromState());
|
||||||
|
states.add(transition.toState());
|
||||||
|
|
||||||
|
if (transition.readSymbol()!=null) {
|
||||||
|
alphabet.add(transition.readSymbol());
|
||||||
}
|
}
|
||||||
// add symbol to alphabet. If it is already in the alphabet, nothing happens
|
transitions.add(transition);
|
||||||
if (transition.readSymbol() != null) {
|
|
||||||
this.alphabet.add(transition.readSymbol());
|
|
||||||
}
|
|
||||||
this.transitions.add(transition);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds all transitions to the automaton. If the automaton is already finalized, a FinalizedStateException is thrown.
|
||||||
|
* @param transitions The Set of transitions to add
|
||||||
|
* @throws FinalizedStateException If the automaton is already finalized
|
||||||
|
*/
|
||||||
public void addAllTransitions(Set<Transition> transitions) throws FinalizedStateException {
|
public void addAllTransitions(Set<Transition> transitions) throws FinalizedStateException {
|
||||||
if (this.isFinalized) {
|
if (this.isFinalized) {
|
||||||
throw new FinalizedStateException();
|
throw new FinalizedStateException();
|
||||||
|
|
@ -93,49 +96,79 @@ public class NFAImpl implements NFA {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a new accepting state to the automaton. If the automaton is already finalized, a FinalizedStateException is thrown.
|
||||||
|
* @param state The state to add as accepting state
|
||||||
|
* @throws FinalizedStateException If the automaton is already finalized
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addAcceptingState(String state) throws FinalizedStateException {
|
public void addAcceptingState(String state) throws FinalizedStateException {
|
||||||
if (this.isFinalized) {
|
if (this.isFinalized) {
|
||||||
throw new FinalizedStateException();
|
throw new FinalizedStateException();
|
||||||
}
|
}
|
||||||
|
if (state == null) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
this.states.add(state);
|
this.states.add(state);
|
||||||
this.acceptingStates.add(state);
|
this.acceptingStates.add(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds all accepting states to the automaton. If the automaton is already finalized, a FinalizedStateException is thrown.
|
||||||
|
* @param states The Set of states to add as accepting states
|
||||||
|
* @throws FinalizedStateException If the automaton is already finalized
|
||||||
|
*/
|
||||||
public void addAllAcceptingStates(Set<String> states) throws FinalizedStateException {
|
public void addAllAcceptingStates(Set<String> states) throws FinalizedStateException {
|
||||||
if (this.isFinalized) {
|
if (this.isFinalized) {
|
||||||
throw new FinalizedStateException();
|
throw new FinalizedStateException();
|
||||||
}
|
}
|
||||||
|
if (states == null) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
for (String state : states) {
|
for (String state : states) {
|
||||||
this.addAcceptingState(state);
|
this.addAcceptingState(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a new state to the automaton. If the automaton is already finalized, a FinalizedStateException is thrown.
|
||||||
|
* If the state already exists, the state is renamed to state1, state11, state111, etc. until a unique name is found.
|
||||||
|
* @param states The Set of states to add
|
||||||
|
* @param toCheck The Set of states to check for duplicates
|
||||||
|
* @param nfa The NFA to add the states to
|
||||||
|
*/
|
||||||
public void safeAddAcceptingStates(Set<String> states, Set<String> toCheck, NFAImpl nfa) {
|
public void safeAddAcceptingStates(Set<String> states, Set<String> toCheck, NFAImpl nfa) {
|
||||||
|
if (this.isFinalized) {
|
||||||
|
throw new FinalizedStateException();
|
||||||
|
}
|
||||||
|
if(states == null || toCheck == null || nfa == null){
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
for (String state : states) {
|
for (String state : states) {
|
||||||
nfa.addAcceptingState(changeIfNecessary(state, toCheck));
|
nfa.addAcceptingState(changeIfNecessary(state, toCheck));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// #TODO
|
/**
|
||||||
// write more testcases
|
* Creates a new NFA that is the union of this NFA and the other NFA. If either of the NFAs is not finalized, a FinalizedStateException is thrown.
|
||||||
|
* @param other The other NFA to union with
|
||||||
|
* @return The union of this NFA and the other NFA
|
||||||
|
* @throws FinalizedStateException If either of the NFAs is not finalized
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public NFA union(NFA other) throws FinalizedStateException {
|
public NFA union(NFA other) throws FinalizedStateException {
|
||||||
if (!this.isFinalized || !other.isFinalized()) {
|
if (!this.isFinalized || !other.isFinalized()) {
|
||||||
throw new FinalizedStateException();
|
throw new FinalizedStateException();
|
||||||
}
|
}
|
||||||
// new initialState with epsilon to initialState of this and other.
|
|
||||||
// Problem: what if states are called the same in this and other + what do we use as initialState?
|
|
||||||
NFAImpl unionNFA = new NFAImpl(this.getInitialState());
|
NFAImpl unionNFA = new NFAImpl(this.getInitialState());
|
||||||
|
|
||||||
unionNFA.states.addAll(this.states);
|
unionNFA.states.addAll(this.states);
|
||||||
|
|
||||||
unionNFA.addAllAcceptingStates(this.acceptingStates);
|
unionNFA.addAllAcceptingStates(this.acceptingStates);
|
||||||
|
|
||||||
Set<String> otherAcceptingStates = new HashSet<>(other.getAcceptingStates());
|
Set<String> otherAcceptingStates = new HashSet<>(other.getAcceptingStates());
|
||||||
unionNFA.safeAddAcceptingStates(this.acceptingStates, otherAcceptingStates, unionNFA);
|
unionNFA.safeAddAcceptingStates(this.acceptingStates, otherAcceptingStates, unionNFA);
|
||||||
|
|
||||||
|
|
||||||
Set<Transition> newTransitions = new HashSet<>();
|
Set<Transition> newTransitions = new HashSet<>();
|
||||||
for (Transition transition : other.getTransitions()) {
|
for (Transition transition : other.getTransitions()) {
|
||||||
Transition newTransition =
|
Transition newTransition =
|
||||||
|
|
@ -152,14 +185,9 @@ public class NFAImpl implements NFA {
|
||||||
unionNFA.acceptingStates.add(state);
|
unionNFA.acceptingStates.add(state);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// a state of other has the same name as one in this.
|
|
||||||
// change name of state and every Transition it is a part of in other
|
|
||||||
String newState = changeIfNecessary(state, unionNFA.states);
|
String newState = changeIfNecessary(state, unionNFA.states);
|
||||||
|
|
||||||
// wieder a neues set
|
|
||||||
Set<Transition> tempTransitions = new HashSet<>();
|
Set<Transition> tempTransitions = new HashSet<>();
|
||||||
|
|
||||||
// check each transition of other if start or to state was state
|
|
||||||
for (Transition transition : newTransitions) {
|
for (Transition transition : newTransitions) {
|
||||||
if (transition.fromState().equals(state)) {
|
if (transition.fromState().equals(state)) {
|
||||||
transition = new Transition(newState, transition.readSymbol(), transition.toState());
|
transition = new Transition(newState, transition.readSymbol(), transition.toState());
|
||||||
|
|
@ -169,16 +197,15 @@ public class NFAImpl implements NFA {
|
||||||
}
|
}
|
||||||
tempTransitions.add(transition);
|
tempTransitions.add(transition);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String accState : other.getAcceptingStates()) {
|
for (String accState : other.getAcceptingStates()) {
|
||||||
if (accState.equals(state)) {
|
if (accState.equals(state)) {
|
||||||
unionNFA.acceptingStates.add(newState);
|
unionNFA.acceptingStates.add(newState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newTransitions = tempTransitions; // Replace the original set with the updated set
|
newTransitions = tempTransitions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// add, alphabet
|
|
||||||
|
|
||||||
Iterator<Transition> iterator = newTransitions.iterator();
|
Iterator<Transition> iterator = newTransitions.iterator();
|
||||||
while (iterator.hasNext()){
|
while (iterator.hasNext()){
|
||||||
Transition transition = iterator.next();
|
Transition transition = iterator.next();
|
||||||
|
|
@ -191,17 +218,18 @@ public class NFAImpl implements NFA {
|
||||||
}
|
}
|
||||||
|
|
||||||
unionNFA.addAllTransitions(newTransitions);
|
unionNFA.addAllTransitions(newTransitions);
|
||||||
|
|
||||||
unionNFA.addAllTransitions(this.transitions);
|
unionNFA.addAllTransitions(this.transitions);
|
||||||
|
|
||||||
unionNFA.finalizeAutomaton();
|
unionNFA.finalizeAutomaton();
|
||||||
|
|
||||||
|
|
||||||
return unionNFA;
|
return unionNFA;
|
||||||
}
|
}
|
||||||
|
|
||||||
// #TODO
|
/**
|
||||||
// needs to work with a DFA not NFA
|
* Creates a new NFA that is the intersection of this NFA and the other NFA. If either of the NFAs is not finalized, a FinalizedStateException is thrown.
|
||||||
|
* @param other The other NFA to intersect with
|
||||||
|
* @return The intersection of this NFA and the other NFA
|
||||||
|
* @throws FinalizedStateException If either of the NFAs is not finalized
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public NFA intersection(NFA other) throws FinalizedStateException {
|
public NFA intersection(NFA other) throws FinalizedStateException {
|
||||||
if (!this.isFinalized || !other.isFinalized()) {
|
if (!this.isFinalized || !other.isFinalized()) {
|
||||||
|
|
@ -213,6 +241,12 @@ public class NFAImpl implements NFA {
|
||||||
return unionNFA.complement();
|
return unionNFA.complement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new NFA that is the concatenation of this NFA and the other NFA. If either of the NFAs is not finalized, a FinalizedStateException is thrown.
|
||||||
|
* @param other The other NFA to concatenate with
|
||||||
|
* @return The concatenation of this NFA and the other NFA
|
||||||
|
* @throws FinalizedStateException If either of the NFAs is not finalized
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public NFA concatenation(NFA other) throws FinalizedStateException {
|
public NFA concatenation(NFA other) throws FinalizedStateException {
|
||||||
if (!this.isFinalized || !other.isFinalized()) {
|
if (!this.isFinalized || !other.isFinalized()) {
|
||||||
|
|
@ -221,10 +255,8 @@ public class NFAImpl implements NFA {
|
||||||
|
|
||||||
NFAImpl concatenationNFA = new NFAImpl(this.initialState);
|
NFAImpl concatenationNFA = new NFAImpl(this.initialState);
|
||||||
|
|
||||||
// Add states from 'this'
|
|
||||||
concatenationNFA.states.addAll(this.states);
|
concatenationNFA.states.addAll(this.states);
|
||||||
|
|
||||||
// Add states from 'other', with renaming if necessary
|
|
||||||
Map<String, String> renamedStates = new HashMap<>();
|
Map<String, String> renamedStates = new HashMap<>();
|
||||||
for (String state : other.getStates()) {
|
for (String state : other.getStates()) {
|
||||||
String newState = changeIfNecessary(state, concatenationNFA.states);
|
String newState = changeIfNecessary(state, concatenationNFA.states);
|
||||||
|
|
@ -232,10 +264,8 @@ public class NFAImpl implements NFA {
|
||||||
concatenationNFA.states.add(newState);
|
concatenationNFA.states.add(newState);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add transitions from 'this'
|
|
||||||
concatenationNFA.transitions.addAll(this.transitions);
|
concatenationNFA.transitions.addAll(this.transitions);
|
||||||
|
|
||||||
// Add transitions from 'other', updating state names
|
|
||||||
for (Transition transition : other.getTransitions()) {
|
for (Transition transition : other.getTransitions()) {
|
||||||
String newFromState = renamedStates.getOrDefault(transition.fromState(), transition.fromState());
|
String newFromState = renamedStates.getOrDefault(transition.fromState(), transition.fromState());
|
||||||
String newToState = renamedStates.getOrDefault(transition.toState(), transition.toState());
|
String newToState = renamedStates.getOrDefault(transition.toState(), transition.toState());
|
||||||
|
|
@ -243,14 +273,12 @@ public class NFAImpl implements NFA {
|
||||||
concatenationNFA.transitions.add(newTransition);
|
concatenationNFA.transitions.add(newTransition);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connect accepting states of 'this' to the initial state of 'other' with epsilon transitions
|
|
||||||
String newOtherInitialState = renamedStates.getOrDefault(other.getInitialState(), other.getInitialState());
|
String newOtherInitialState = renamedStates.getOrDefault(other.getInitialState(), other.getInitialState());
|
||||||
for (String acceptingState : this.acceptingStates) {
|
for (String acceptingState : this.acceptingStates) {
|
||||||
Transition epsilon = new Transition(acceptingState, null, newOtherInitialState);
|
Transition epsilon = new Transition(acceptingState, null, newOtherInitialState);
|
||||||
concatenationNFA.transitions.add(epsilon);
|
concatenationNFA.transitions.add(epsilon);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set accepting states of the concatenated NFA to be the accepting states of 'other'
|
|
||||||
concatenationNFA.acceptingStates.clear();
|
concatenationNFA.acceptingStates.clear();
|
||||||
for (String acceptingState : other.getAcceptingStates()) {
|
for (String acceptingState : other.getAcceptingStates()) {
|
||||||
concatenationNFA.acceptingStates.add(renamedStates.getOrDefault(acceptingState, acceptingState));
|
concatenationNFA.acceptingStates.add(renamedStates.getOrDefault(acceptingState, acceptingState));
|
||||||
|
|
@ -261,7 +289,11 @@ public class NFAImpl implements NFA {
|
||||||
return concatenationNFA;
|
return concatenationNFA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new NFA that is the Kleene star of this NFA. If the NFA is not finalized, a FinalizedStateException is thrown.
|
||||||
|
* @return The Kleene star of this NFA
|
||||||
|
* @throws FinalizedStateException If the NFA is not finalized
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public NFA kleeneStar() throws FinalizedStateException {
|
public NFA kleeneStar() throws FinalizedStateException {
|
||||||
if (!this.isFinalized) {
|
if (!this.isFinalized) {
|
||||||
|
|
@ -270,17 +302,13 @@ public class NFAImpl implements NFA {
|
||||||
|
|
||||||
NFAImpl nfa = new NFAImpl(this.initialState);
|
NFAImpl nfa = new NFAImpl(this.initialState);
|
||||||
|
|
||||||
// copy, but without accepting states
|
|
||||||
nfa.states.addAll(this.states);
|
nfa.states.addAll(this.states);
|
||||||
nfa.addAllTransitions(this.transitions);
|
nfa.addAllTransitions(this.transitions);
|
||||||
|
|
||||||
// adding the initial state as accepting state because we have to accept the empty string
|
|
||||||
nfa.acceptingStates.add(this.initialState);
|
nfa.acceptingStates.add(this.initialState);
|
||||||
|
|
||||||
// for each accepting state
|
|
||||||
for (String acceptingState : this.getAcceptingStates()) {
|
for (String acceptingState : this.getAcceptingStates()) {
|
||||||
Transition loopBackTransition =
|
Transition loopBackTransition =
|
||||||
// creating an epsilon transition (null) for each accepting state
|
|
||||||
new Transition(acceptingState, null, this.initialState);
|
new Transition(acceptingState, null, this.initialState);
|
||||||
nfa.transitions.add(loopBackTransition);
|
nfa.transitions.add(loopBackTransition);
|
||||||
}
|
}
|
||||||
|
|
@ -290,6 +318,11 @@ public class NFAImpl implements NFA {
|
||||||
return nfa;
|
return nfa;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new NFA that is the plus operator of this NFA. If the NFA is not finalized, a FinalizedStateException is thrown.
|
||||||
|
* @return The plus operator of this NFA
|
||||||
|
* @throws FinalizedStateException If the NFA is not finalized
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public NFA plusOperator() throws FinalizedStateException {
|
public NFA plusOperator() throws FinalizedStateException {
|
||||||
if (!this.isFinalized) {
|
if (!this.isFinalized) {
|
||||||
|
|
@ -299,55 +332,41 @@ public class NFAImpl implements NFA {
|
||||||
String newInitialState = "newSTART";
|
String newInitialState = "newSTART";
|
||||||
NFAImpl nfa = new NFAImpl(newInitialState);
|
NFAImpl nfa = new NFAImpl(newInitialState);
|
||||||
|
|
||||||
// simple copy
|
|
||||||
nfa.states.addAll(this.states);
|
nfa.states.addAll(this.states);
|
||||||
nfa.transitions.addAll(this.transitions);
|
nfa.transitions.addAll(this.transitions);
|
||||||
nfa.acceptingStates.addAll(this.acceptingStates);
|
nfa.acceptingStates.addAll(this.acceptingStates);
|
||||||
|
|
||||||
nfa.transitions.add(new Transition(newInitialState, null, this.initialState));
|
nfa.transitions.add(new Transition(newInitialState, null, this.initialState));
|
||||||
|
|
||||||
|
|
||||||
for (String acceptingState : this.acceptingStates) {
|
for (String acceptingState : this.acceptingStates) {
|
||||||
nfa.transitions.add(new Transition(acceptingState, null, newInitialState));
|
nfa.transitions.add(new Transition(acceptingState, null, newInitialState));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// for each accepting state
|
|
||||||
for (String acceptingState : this.acceptingStates) {
|
|
||||||
Transition loopBackTransition =
|
|
||||||
// creating an epsilon transition (null) for each accepting state
|
|
||||||
new Transition(acceptingState, null, this.initialState);
|
|
||||||
if (!nfa.transitions.contains(loopBackTransition)) {
|
|
||||||
nfa.transitions.add(loopBackTransition);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
nfa.finalizeAutomaton();
|
nfa.finalizeAutomaton();
|
||||||
|
|
||||||
return nfa;
|
return nfa;
|
||||||
}
|
}
|
||||||
|
|
||||||
// #TODO
|
/**
|
||||||
|
* Creates a new NFA that is the complement of this NFA. If the NFA is not finalized, a FinalizedStateException is thrown.
|
||||||
|
* @return The complement of this NFA
|
||||||
|
* @throws FinalizedStateException If the NFA is not finalized
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public NFA complement() throws FinalizedStateException {
|
public NFA complement() throws FinalizedStateException {
|
||||||
if (!this.isFinalized) {
|
if (!this.isFinalized) {
|
||||||
throw new FinalizedStateException();
|
throw new FinalizedStateException();
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a copy of this NFA
|
|
||||||
NFAImpl nfa = new NFAImpl(this.initialState);
|
NFAImpl nfa = new NFAImpl(this.initialState);
|
||||||
nfa.states.addAll(this.states);
|
nfa.states.addAll(this.states);
|
||||||
nfa.addAllTransitions(this.transitions);
|
nfa.addAllTransitions(this.transitions);
|
||||||
nfa.addAllAcceptingStates(this.acceptingStates);
|
nfa.addAllAcceptingStates(this.acceptingStates);
|
||||||
|
|
||||||
nfaAddTrap(nfa); //error on last occasion
|
nfaAddTrap(nfa);
|
||||||
|
|
||||||
NFAImpl fakeNFA = convertNFAtoDFA(nfa);
|
NFAImpl fakeNFA = convertNFAtoDFA(nfa);
|
||||||
|
|
||||||
// state -> accepting
|
|
||||||
// accepting -> state
|
|
||||||
|
|
||||||
Set<String> newAcceptingState = new HashSet<>();
|
Set<String> newAcceptingState = new HashSet<>();
|
||||||
|
|
||||||
for (String state : fakeNFA.getStates()) {
|
for (String state : fakeNFA.getStates()) {
|
||||||
|
|
@ -355,38 +374,42 @@ public class NFAImpl implements NFA {
|
||||||
newAcceptingState.add(state);
|
newAcceptingState.add(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fakeNFA.acceptingStates.clear();
|
fakeNFA.acceptingStates.clear();
|
||||||
fakeNFA.addAllAcceptingStates(newAcceptingState);
|
fakeNFA.addAllAcceptingStates(newAcceptingState);
|
||||||
|
|
||||||
fakeNFA.finalizeAutomaton();
|
fakeNFA.finalizeAutomaton();
|
||||||
|
|
||||||
return fakeNFA;
|
return fakeNFA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the automaton is finalized.
|
||||||
|
* @return Whether the automaton is finalized
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isFinalized() {
|
public boolean isFinalized() {
|
||||||
return isFinalized;
|
return isFinalized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finalizes the automaton. After finalization, no further states or transitions can be added.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void finalizeAutomaton() {
|
public void finalizeAutomaton() {
|
||||||
this.isFinalized = true;
|
this.isFinalized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// #TODO
|
/**
|
||||||
|
* Returns whether the automaton is finite. An automaton is finite if it has a finite number of states and no loops, that have a path to an accepting state.
|
||||||
|
* @return Whether the automaton is finite
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isFinite() {
|
public boolean isFinite() {
|
||||||
//transitions={fromState==toState}
|
|
||||||
//states={A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z}
|
|
||||||
//obergrenze = anzahl der states (26)
|
|
||||||
|
|
||||||
//how do we get an infinite language?
|
|
||||||
//we need to have a loop, how can we check:
|
|
||||||
|
|
||||||
List<Tuple> path = new ArrayList<>();
|
List<Tuple> path = new ArrayList<>();
|
||||||
List<Transition> transitions= new ArrayList<>(this.getTransitions());
|
List<Transition> transitions= new ArrayList<>(this.getTransitions());
|
||||||
AtomicInteger finished = new AtomicInteger(0); //0=unfinished, 1=finite, 2 = infinite
|
AtomicInteger finished = new AtomicInteger(0);
|
||||||
List<Character> letters = new ArrayList<>(this.alphabet); // letters is alphabet with epsilon (null)
|
List<Character> letters = new ArrayList<>(this.alphabet);
|
||||||
if(this.alphabet.isEmpty()){
|
if(this.alphabet.isEmpty()){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -394,7 +417,6 @@ public class NFAImpl implements NFA {
|
||||||
letters.add(null);
|
letters.add(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EndTuple hast firstElement = a //doesn´t matter at all aktually
|
|
||||||
path.add(new Tuple('a', this.initialState));
|
path.add(new Tuple('a', this.initialState));
|
||||||
if(fillToEnd(path, transitions, letters, finished)){
|
if(fillToEnd(path, transitions, letters, finished)){
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -409,7 +431,6 @@ public class NFAImpl implements NFA {
|
||||||
}
|
}
|
||||||
System.out.println("ERROR-isFinite method isn´t running right!");
|
System.out.println("ERROR-isFinite method isn´t running right!");
|
||||||
return true;
|
return true;
|
||||||
//return continueOnLastTuple(path, transitions, letters);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void continueOnLastTuple(List<Tuple> path, List<Transition> transitions, List<Character> letters, AtomicInteger finished) {
|
private void continueOnLastTuple(List<Tuple> path, List<Transition> transitions, List<Character> letters, AtomicInteger finished) {
|
||||||
|
|
@ -538,6 +559,7 @@ public class NFAImpl implements NFA {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean stateReachesAcceptingstates(String state){
|
private boolean stateReachesAcceptingstates(String state){
|
||||||
if(this.acceptingStates.contains(state)){
|
if(this.acceptingStates.contains(state)){
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -568,7 +590,12 @@ public class NFAImpl implements NFA {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// #TODO
|
/**
|
||||||
|
* Returns whether the automaton accepts the given word. If the automaton is not finalized, a FinalizedStateException is thrown.
|
||||||
|
* @param word word to check, can be empty
|
||||||
|
* @return Whether the automaton accepts the given word
|
||||||
|
* @throws FinalizedStateException If the automaton is not finalized
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptsWord(String word) throws FinalizedStateException {
|
public boolean acceptsWord(String word) throws FinalizedStateException {
|
||||||
if (!this.isFinalized) {
|
if (!this.isFinalized) {
|
||||||
|
|
@ -582,46 +609,41 @@ public class NFAImpl implements NFA {
|
||||||
currentStates = (epsilonClosure(currentStates, this));
|
currentStates = (epsilonClosure(currentStates, this));
|
||||||
|
|
||||||
for (char letter : wordArray) {
|
for (char letter : wordArray) {
|
||||||
// schritt a
|
|
||||||
currentStates = getStateAfterTransition(currentStates, letter, this);
|
currentStates = getStateAfterTransition(currentStates, letter, this);
|
||||||
// schritt b
|
|
||||||
currentStates = epsilonClosure(currentStates, this);
|
currentStates = epsilonClosure(currentStates, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return isAcceptingState(currentStates, this);
|
return isAcceptingState(currentStates, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts the given NFA to a DFA. If the NFA is not finalized, a FinalizedStateException is thrown.
|
||||||
|
* @param input The NFA to convert
|
||||||
|
* @return The converted DFA
|
||||||
|
*/
|
||||||
public NFAImpl convertNFAtoDFA(NFAImpl input) {
|
public NFAImpl convertNFAtoDFA(NFAImpl input) {
|
||||||
|
|
||||||
// all accepting states of the DFA
|
|
||||||
Set<String> dfaAcceptingStates = new HashSet<>();
|
Set<String> dfaAcceptingStates = new HashSet<>();
|
||||||
// all states of the DFA
|
|
||||||
List<Set<String>> dfaStates = new ArrayList<>();
|
List<Set<String>> dfaStates = new ArrayList<>();
|
||||||
// all transitions of the DFA
|
|
||||||
Set<Transition> dfaTransitions = new HashSet<>();
|
Set<Transition> dfaTransitions = new HashSet<>();
|
||||||
|
|
||||||
// all states of the NFA
|
|
||||||
Set<String> startState = new HashSet<>();
|
Set<String> startState = new HashSet<>();
|
||||||
startState.add(input.getInitialState());
|
startState.add(input.getInitialState());
|
||||||
|
|
||||||
// getting the epsilon closure of the start state
|
|
||||||
startState = epsilonClosure(startState, input);
|
startState = epsilonClosure(startState, input);
|
||||||
dfaStates.add(startState);
|
dfaStates.add(startState);
|
||||||
if (isAcceptingState(startState, input)) {
|
if (isAcceptingState(startState, input)) {
|
||||||
dfaAcceptingStates.add(getIndexOfSet(startState, dfaStates));
|
dfaAcceptingStates.add(getIndexOfSet(startState, dfaStates));
|
||||||
}
|
}
|
||||||
|
|
||||||
// do the above with each DFA state
|
|
||||||
Queue<Set<String>> queue = new LinkedList<>();
|
Queue<Set<String>> queue = new LinkedList<>();
|
||||||
queue.add(startState);
|
queue.add(startState);
|
||||||
// iterate each Letter
|
|
||||||
while (!queue.isEmpty()) {
|
while (!queue.isEmpty()) {
|
||||||
Set<String> currentState = queue.poll();
|
Set<String> currentState = queue.poll();
|
||||||
// for each possible Letter
|
|
||||||
for (char letter : input.getAlphabet()) {
|
for (char letter : input.getAlphabet()) {
|
||||||
// get the new state after the transition
|
|
||||||
Set<String> newState = epsilonClosure(getStateAfterTransition(currentState, letter, input), input);
|
Set<String> newState = epsilonClosure(getStateAfterTransition(currentState, letter, input), input);
|
||||||
if (!dfaStates.contains(newState)) {
|
if (!dfaStates.contains(newState)) {
|
||||||
queue.add(newState);
|
queue.add(newState);
|
||||||
|
|
@ -632,7 +654,6 @@ public class NFAImpl implements NFA {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// build new Transition
|
|
||||||
dfaTransitions.add(new Transition(getIndexOfSet(currentState, dfaStates), letter, getIndexOfSet(newState, dfaStates)));
|
dfaTransitions.add(new Transition(getIndexOfSet(currentState, dfaStates), letter, getIndexOfSet(newState, dfaStates)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -649,6 +670,12 @@ public class NFAImpl implements NFA {
|
||||||
return newDFA;
|
return newDFA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the epsilon closure of the given states.
|
||||||
|
* @param states The states to get the epsilon closure of
|
||||||
|
* @param nfa The NFA to get the epsilon closure from
|
||||||
|
* @return The epsilon closure of the given states
|
||||||
|
*/
|
||||||
private Set<String> epsilonClosure(Set<String> states, NFA nfa) {
|
private Set<String> epsilonClosure(Set<String> states, NFA nfa) {
|
||||||
Set<String> closure = new HashSet<>(states);
|
Set<String> closure = new HashSet<>(states);
|
||||||
Stack<String> stack = new Stack<>();
|
Stack<String> stack = new Stack<>();
|
||||||
|
|
@ -666,6 +693,13 @@ public class NFAImpl implements NFA {
|
||||||
return closure;
|
return closure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the states that are reached by the given states after reading the given symbol.
|
||||||
|
* @param states The states to get the states after reading the symbol of
|
||||||
|
* @param symbol The symbol to read
|
||||||
|
* @param nfa The NFA to get the states from
|
||||||
|
* @return The states that are reached by the given states after reading the given symbol
|
||||||
|
*/
|
||||||
private Set<String> getStateAfterTransition(Set<String> states, char symbol, NFA nfa) {
|
private Set<String> getStateAfterTransition(Set<String> states, char symbol, NFA nfa) {
|
||||||
Set<String> result = new HashSet<>();
|
Set<String> result = new HashSet<>();
|
||||||
for (String state : states) {
|
for (String state : states) {
|
||||||
|
|
@ -678,6 +712,12 @@ public class NFAImpl implements NFA {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the given states contain an accepting state.
|
||||||
|
* @param states The states to check
|
||||||
|
* @param input The NFA to check the states for
|
||||||
|
* @return Whether the given states contain an accepting state
|
||||||
|
*/
|
||||||
private boolean isAcceptingState(Set<String> states, NFA input) {
|
private boolean isAcceptingState(Set<String> states, NFA input) {
|
||||||
for (String accState : input.getAcceptingStates()) {
|
for (String accState : input.getAcceptingStates()) {
|
||||||
if (states.contains(accState)) {
|
if (states.contains(accState)) {
|
||||||
|
|
@ -687,10 +727,22 @@ public class NFAImpl implements NFA {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the index of the given set in the given list.
|
||||||
|
* @param set The set to get the index of
|
||||||
|
* @param dfaStates The list to get the index from
|
||||||
|
* @return The index of the given set in the given list
|
||||||
|
*/
|
||||||
private String getIndexOfSet(Set<String> set, List<Set<String>> dfaStates) {
|
private String getIndexOfSet(Set<String> set, List<Set<String>> dfaStates) {
|
||||||
return Integer.toString(dfaStates.indexOf(set));
|
return Integer.toString(dfaStates.indexOf(set));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the given string with a number appended to it, if the string already exists in the given set.
|
||||||
|
* @param str The string to check
|
||||||
|
* @param toCheck The set to check for duplicates
|
||||||
|
* @return The given string with a number appended to it, if the string already exists in the given set
|
||||||
|
*/
|
||||||
private String changeIfNecessary(String str, Set<String> toCheck) {
|
private String changeIfNecessary(String str, Set<String> toCheck) {
|
||||||
while (toCheck.contains(str)) {
|
while (toCheck.contains(str)) {
|
||||||
str = str + "1";
|
str = str + "1";
|
||||||
|
|
@ -698,6 +750,10 @@ public class NFAImpl implements NFA {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a trap state to the given NFA.
|
||||||
|
* @param input The NFA to add the trap state to
|
||||||
|
*/
|
||||||
private void nfaAddTrap(NFAImpl input){
|
private void nfaAddTrap(NFAImpl input){
|
||||||
String trap = changeIfNecessary("TRAP", input.getStates());
|
String trap = changeIfNecessary("TRAP", input.getStates());
|
||||||
input.states.add(trap);
|
input.states.add(trap);
|
||||||
|
|
@ -718,7 +774,6 @@ public class NFAImpl implements NFA {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
input.addAllTransitions(newTransitions); //input.transitions.addAll(newTransitions);
|
input.addAllTransitions(newTransitions);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
package ab1.impl.gruppe10_aigensberger_dworski_walcher;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class Tuple {
|
||||||
|
private final Character element_1;
|
||||||
|
private final String element_2;
|
||||||
|
|
||||||
|
public Tuple(Character firstElement, String secondElement){
|
||||||
|
this.element_1=firstElement;
|
||||||
|
this.element_2=secondElement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package ab1;
|
package ab1;
|
||||||
|
|
||||||
import ab1.impl.GRUPPE.NFAFactoryImpl;
|
import ab1.impl.gruppe10_aigensberger_dworski_walcher.NFAFactoryImpl;
|
||||||
|
|
||||||
public class NFAProvider {
|
public class NFAProvider {
|
||||||
public static NFAFactory provideFactory() {
|
public static NFAFactory provideFactory() {
|
||||||
|
|
|
||||||
76
src/test/java/ab1/tests/GRUPPE/BetterSimpleTests.java
Normal file
76
src/test/java/ab1/tests/GRUPPE/BetterSimpleTests.java
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
package ab1.tests.GRUPPE;
|
||||||
|
|
||||||
|
import ab1.NFAFactory;
|
||||||
|
import ab1.NFAProvider;
|
||||||
|
import ab1.Transition;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple tests for the NFA implementation.
|
||||||
|
*/
|
||||||
|
public class BetterSimpleTests {
|
||||||
|
private final NFAFactory factory = NFAProvider.provideFactory();
|
||||||
|
@Test
|
||||||
|
public void invalidInputTest() {
|
||||||
|
var instance = factory.buildNFA(null);
|
||||||
|
assertNull(instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void invalidAcceptingState() {
|
||||||
|
var instance = factory.buildNFA("START");
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> instance.addAcceptingState(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void invalidTransition() {
|
||||||
|
var instance = factory.buildNFA("START");
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> instance.addTransition(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void transitionWithoutToState() {
|
||||||
|
var instance = factory.buildNFA("START");
|
||||||
|
Transition transition = ab1.Transition.builder()
|
||||||
|
.readSymbol('a')
|
||||||
|
.fromState("START")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> instance.addTransition(transition));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void transitionWithoutExistingToState() {
|
||||||
|
var instance = factory.buildNFA("START");
|
||||||
|
instance.addTransition(
|
||||||
|
ab1.Transition.builder()
|
||||||
|
.readSymbol('a')
|
||||||
|
.fromState("START")
|
||||||
|
.toState("END")
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
assertEquals(1, instance.getTransitions().size());
|
||||||
|
assertEquals(2, instance.getStates().size());
|
||||||
|
assertEquals(0, instance.getAcceptingStates().size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void notInAlphabet(){
|
||||||
|
var instance = factory.buildNFA("START");
|
||||||
|
instance.addTransition(
|
||||||
|
ab1.Transition.builder()
|
||||||
|
.readSymbol('a')
|
||||||
|
.fromState("START")
|
||||||
|
.toState("END")
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
instance.addAcceptingState("END");
|
||||||
|
instance.finalizeAutomaton();
|
||||||
|
|
||||||
|
assertFalse(instance.acceptsWord("b"));
|
||||||
|
assertTrue(instance.acceptsWord("a"));
|
||||||
|
assertFalse(instance.acceptsWord("ab"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,17 +1,18 @@
|
||||||
package ab1.tests;
|
package ab1.tests.GRUPPE;
|
||||||
|
|
||||||
import ab1.NFA;
|
import ab1.NFA;
|
||||||
import ab1.NFAFactory;
|
import ab1.NFAFactory;
|
||||||
import ab1.NFAProvider;
|
import ab1.NFAProvider;
|
||||||
import ab1.Transition;
|
import ab1.Transition;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class myTests {
|
/**
|
||||||
|
* This is a test class for the NFA implementation.
|
||||||
|
*/
|
||||||
|
public class MyTests {
|
||||||
private final NFAFactory factory = NFAProvider.provideFactory();
|
private final NFAFactory factory = NFAProvider.provideFactory();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -105,23 +106,6 @@ public class myTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private NFA buildCharStarLanguage(char c) {
|
|
||||||
var instance = factory.buildNFA("START");
|
|
||||||
instance.addTransition(
|
|
||||||
Transition.builder()
|
|
||||||
.fromState("START")
|
|
||||||
.readSymbol(c)
|
|
||||||
.toState("START")
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
instance.addAcceptingState("START");
|
|
||||||
instance.finalizeAutomaton();
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
private NFA buildCharLanguage(char c) {
|
private NFA buildCharLanguage(char c) {
|
||||||
var instance = factory.buildNFA("START");
|
var instance = factory.buildNFA("START");
|
||||||
instance.addTransition(
|
instance.addTransition(
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in a new issue