hope this works...
This commit is contained in:
parent
ac579644f5
commit
8a6ea12b68
8 changed files with 262 additions and 77 deletions
1
.idea/compiler.xml
generated
1
.idea/compiler.xml
generated
|
|
@ -2,6 +2,7 @@
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="CompilerConfiguration">
|
<component name="CompilerConfiguration">
|
||||||
<annotationProcessing>
|
<annotationProcessing>
|
||||||
|
<profile default="true" name="Default" enabled="true" />
|
||||||
<profile name="Maven default annotation processors profile" enabled="true">
|
<profile name="Maven default annotation processors profile" enabled="true">
|
||||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
|
|
|
||||||
9
.idea/jarRepositories.xml
generated
9
.idea/jarRepositories.xml
generated
|
|
@ -3,8 +3,13 @@
|
||||||
<component name="RemoteRepositoriesConfiguration">
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="central" />
|
<option name="id" value="central" />
|
||||||
<option name="name" value="Central Repository" />
|
<option name="name" value="libs-release" />
|
||||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
<option name="url" value="${env.ARTIFACTORY_URL}/maven" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="snapshots" />
|
||||||
|
<option name="name" value="libs-snapshot" />
|
||||||
|
<option name="url" value="${env.ARTIFACTORY_URL}/maven" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="central" />
|
<option name="id" value="central" />
|
||||||
|
|
|
||||||
4
.idea/misc.xml
generated
4
.idea/misc.xml
generated
|
|
@ -8,5 +8,7 @@
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" default="true" project-jdk-name="openjdk-19" project-jdk-type="JavaSDK" />
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="openjdk-21" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
</project>
|
</project>
|
||||||
22
.idea/shelf/Uncommitted_changes_before_Update_at_08_01_2024_12_06_[Changes]/shelved.patch
generated
Normal file
22
.idea/shelf/Uncommitted_changes_before_Update_at_08_01_2024_12_06_[Changes]/shelved.patch
generated
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
Index: .idea/jarRepositories.xml
|
||||||
|
IDEA additional info:
|
||||||
|
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
|
||||||
|
<+><?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<project version=\"4\">\r\n <component name=\"RemoteRepositoriesConfiguration\">\r\n <remote-repository>\r\n <option name=\"id\" value=\"central\" />\r\n <option name=\"name\" value=\"libs-release\" />\r\n <option name=\"url\" value=\"${env.ARTIFACTORY_URL}/maven\" />\r\n </remote-repository>\r\n <remote-repository>\r\n <option name=\"id\" value=\"snapshots\" />\r\n <option name=\"name\" value=\"libs-snapshot\" />\r\n <option name=\"url\" value=\"${env.ARTIFACTORY_URL}/maven\" />\r\n </remote-repository>\r\n <remote-repository>\r\n <option name=\"id\" value=\"central\" />\r\n <option name=\"name\" value=\"Maven Central repository\" />\r\n <option name=\"url\" value=\"https://repo1.maven.org/maven2\" />\r\n </remote-repository>\r\n <remote-repository>\r\n <option name=\"id\" value=\"jboss.community\" />\r\n <option name=\"name\" value=\"JBoss Community repository\" />\r\n <option name=\"url\" value=\"https://repository.jboss.org/nexus/content/repositories/public/\" />\r\n </remote-repository>\r\n </component>\r\n</project>
|
||||||
|
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||||||
|
<+>UTF-8
|
||||||
|
===================================================================
|
||||||
|
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
|
||||||
|
--- a/.idea/jarRepositories.xml (revision b2f6932eae27588a4b5ad8e1bb1f83f2a533182a)
|
||||||
|
+++ b/.idea/jarRepositories.xml (date 1704711982177)
|
||||||
|
@@ -7,6 +7,11 @@
|
||||||
|
<option name="url" value="${env.ARTIFACTORY_URL}/maven" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
+ <option name="id" value="central" />
|
||||||
|
+ <option name="name" value="Central Repository" />
|
||||||
|
+ <option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||||
|
+ </remote-repository>
|
||||||
|
+ <remote-repository>
|
||||||
|
<option name="id" value="snapshots" />
|
||||||
|
<option name="name" value="libs-snapshot" />
|
||||||
|
<option name="url" value="${env.ARTIFACTORY_URL}/maven" />
|
||||||
4
.idea/shelf/Uncommitted_changes_before_Update_at_08_01_2024_12_06__Changes_.xml
generated
Normal file
4
.idea/shelf/Uncommitted_changes_before_Update_at_08_01_2024_12_06__Changes_.xml
generated
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
<changelist name="Uncommitted_changes_before_Update_at_08_01_2024_12_06_[Changes]" date="1704712018273" recycled="true" deleted="true">
|
||||||
|
<option name="PATH" value="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_08_01_2024_12_06_[Changes]/shelved.patch" />
|
||||||
|
<option name="DESCRIPTION" value="Uncommitted changes before Update at 08/01/2024 12:06 [Changes]" />
|
||||||
|
</changelist>
|
||||||
165
.idea/workspace.xml
generated
Normal file
165
.idea/workspace.xml
generated
Normal file
|
|
@ -0,0 +1,165 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="AutoImportSettings">
|
||||||
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
|
</component>
|
||||||
|
<component name="ChangeListManager">
|
||||||
|
<list default="true" id="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" name="Changes" comment="">
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/compiler.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/compiler.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/jarRepositories.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/jarRepositories.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" 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" />
|
||||||
|
</list>
|
||||||
|
<list id="2bf04d9d-9125-4ed6-9018-847e14e9822c" name="Changes by danie" comment="">
|
||||||
|
<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" />
|
||||||
|
</list>
|
||||||
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
|
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||||
|
</component>
|
||||||
|
<component name="Git.Settings">
|
||||||
|
<option name="RECENT_BRANCH_BY_REPOSITORY">
|
||||||
|
<map>
|
||||||
|
<entry key="$PROJECT_DIR$" value="main" />
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
|
</component>
|
||||||
|
<component name="GitLabMergeRequestFiltersHistory">{
|
||||||
|
"lastFilter": {
|
||||||
|
"state": "OPENED",
|
||||||
|
"assignee": {
|
||||||
|
"type": "org.jetbrains.plugins.gitlab.mergerequest.ui.filters.GitLabMergeRequestsFiltersValue.MergeRequestsMemberFilterValue.MergeRequestsAssigneeFilterValue",
|
||||||
|
"username": "rawalcher",
|
||||||
|
"fullname": "rawalcher"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}</component>
|
||||||
|
<component name="GitLabMergeRequestsSettings">{
|
||||||
|
"selectedUrlAndAccountId": {
|
||||||
|
"first": "https://git-ainf.aau.at/rawalcher/theorethische-informatik-gruppe-10.git",
|
||||||
|
"second": "e0c4ebfe-e254-4a34-93d3-a6ee2cb18f94"
|
||||||
|
}
|
||||||
|
}</component>
|
||||||
|
<component name="LineStatusTrackerManager">
|
||||||
|
<file path="$PROJECT_DIR$/src/main/java/ab1/impl/GRUPPE/NFAImpl.java">
|
||||||
|
<ranges>
|
||||||
|
<range start1="9" end1="9" start2="9" end2="10" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||||
|
<range start1="37" end1="37" start2="38" end2="39" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||||
|
<range start1="56" end1="61" start2="58" end2="68" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||||
|
<range start1="62" end1="62" start2="69" end2="78" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||||
|
<range start1="67" end1="71" start2="83" end2="86" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||||
|
<range start1="72" end1="72" start2="87" end2="96" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||||
|
<range start1="76" end1="77" start2="100" end2="101" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||||
|
<range start1="94" end1="95" start2="118" end2="119" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||||
|
<range start1="111" end1="112" start2="135" end2="136" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||||
|
<range start1="122" end1="123" start2="146" end2="147" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||||
|
<range start1="187" end1="188" start2="211" end2="212" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||||
|
<range start1="230" end1="231" start2="254" end2="255" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||||
|
<range start1="242" end1="242" start2="266" end2="267" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||||
|
<range start1="254" end1="273" start2="279" end2="282" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||||
|
<range start1="278" end1="279" start2="287" end2="288" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||||
|
<range start1="287" end1="288" start2="296" end2="300" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||||
|
<range start1="290" end1="291" start2="302" end2="303" changelist="2bf04d9d-9125-4ed6-9018-847e14e9822c" />
|
||||||
|
<range start1="292" end1="293" start2="304" end2="305" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||||
|
<range start1="297" end1="310" start2="309" end2="313" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||||
|
<range start1="312" end1="313" start2="315" end2="317" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||||
|
<range start1="314" end1="317" start2="318" end2="321" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||||
|
<range start1="377" end1="388" start2="381" end2="388" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||||
|
<range start1="389" end1="389" start2="389" end2="393" changelist="2bf04d9d-9125-4ed6-9018-847e14e9822c" />
|
||||||
|
<range start1="390" end1="404" start2="394" end2="394" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||||
|
</ranges>
|
||||||
|
</file>
|
||||||
|
</component>
|
||||||
|
<component name="MarkdownSettingsMigration">
|
||||||
|
<option name="stateVersion" value="1" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectColorInfo">{
|
||||||
|
"associatedIndex": 2
|
||||||
|
}</component>
|
||||||
|
<component name="ProjectId" id="2afDcX9p9UZiDe6ife9RGZcJjKQ" />
|
||||||
|
<component name="ProjectViewState">
|
||||||
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
|
<option name="showLibraryContents" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PropertiesComponent">{
|
||||||
|
"keyToString": {
|
||||||
|
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||||
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
|
"WebServerToolWindowFactoryState": "false",
|
||||||
|
"git-widget-placeholder": "main",
|
||||||
|
"ignore.virus.scanning.warn.message": "true",
|
||||||
|
"node.js.detected.package.eslint": "true",
|
||||||
|
"node.js.detected.package.tslint": "true",
|
||||||
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
|
"node.js.selected.package.tslint": "(autodetect)",
|
||||||
|
"nodejs_package_manager_path": "npm",
|
||||||
|
"project.structure.last.edited": "Project",
|
||||||
|
"project.structure.proportion": "0.0",
|
||||||
|
"project.structure.side.proportion": "0.0",
|
||||||
|
"settings.editor.selected.configurable": "preferences.pluginManager",
|
||||||
|
"vue.rearranger.settings.migration": "true"
|
||||||
|
}
|
||||||
|
}</component>
|
||||||
|
<component name="RunManager">
|
||||||
|
<configuration name="ab1.tests in ETI_Abgabe" 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="TEST_OBJECT" value="package" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="Make" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
<configuration default="true" type="JetRunConfigurationType">
|
||||||
|
<method v="2">
|
||||||
|
<option name="Make" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
<configuration default="true" type="KotlinStandaloneScriptRunConfigurationType">
|
||||||
|
<option name="filePath" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="Make" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
<recent_temporary>
|
||||||
|
<list>
|
||||||
|
<item itemvalue="JUnit.ab1.tests in ETI_Abgabe" />
|
||||||
|
</list>
|
||||||
|
</recent_temporary>
|
||||||
|
</component>
|
||||||
|
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||||
|
<component name="TaskManager">
|
||||||
|
<task active="true" id="Default" summary="Default task">
|
||||||
|
<changelist id="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" name="Changes" comment="" />
|
||||||
|
<created>1704700820495</created>
|
||||||
|
<option name="number" value="Default" />
|
||||||
|
<option name="presentableId" value="Default" />
|
||||||
|
<updated>1704700820495</updated>
|
||||||
|
<workItem from="1704700821945" duration="5461000" />
|
||||||
|
<workItem from="1704712375384" duration="4940000" />
|
||||||
|
<workItem from="1704717343016" duration="2934000" />
|
||||||
|
</task>
|
||||||
|
<servers />
|
||||||
|
</component>
|
||||||
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
|
<option name="version" value="3" />
|
||||||
|
</component>
|
||||||
|
<component name="XDebuggerManager">
|
||||||
|
<breakpoint-manager>
|
||||||
|
<breakpoints>
|
||||||
|
<line-breakpoint enabled="true" type="java-line">
|
||||||
|
<url>file://$PROJECT_DIR$/src/test/java/ab1/tests/ComplexTests.java</url>
|
||||||
|
<line>171</line>
|
||||||
|
<option name="timeStamp" value="1" />
|
||||||
|
</line-breakpoint>
|
||||||
|
</breakpoints>
|
||||||
|
</breakpoint-manager>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
|
|
@ -7,6 +7,7 @@ import ab1.Transition;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class NFAImpl implements NFA {
|
public class NFAImpl implements NFA {
|
||||||
private Set<String> states;
|
private Set<String> states;
|
||||||
|
|
@ -35,6 +36,7 @@ public class NFAImpl implements NFA {
|
||||||
public Set<String> getStates() {
|
public Set<String> getStates() {
|
||||||
return this.states;
|
return this.states;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Transition> getTransitions() {
|
public Collection<Transition> getTransitions() {
|
||||||
return this.transitions;
|
return this.transitions;
|
||||||
|
|
@ -54,27 +56,49 @@ public class NFAImpl implements NFA {
|
||||||
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();
|
||||||
} else if (!this.transitions.contains(transition)) {
|
}
|
||||||
|
if (!states.contains(transition.fromState())) {
|
||||||
|
this.states.add(transition.fromState());
|
||||||
|
}
|
||||||
|
if (!states.contains(transition.toState())) {
|
||||||
|
this.states.add(transition.toState());
|
||||||
|
}
|
||||||
// add symbol to alphabet. If it is already in the alphabet, nothing happens
|
// add symbol to alphabet. If it is already in the alphabet, nothing happens
|
||||||
this.alphabet.add(transition.readSymbol());
|
this.alphabet.add(transition.readSymbol());
|
||||||
this.transitions.add(transition);
|
this.transitions.add(transition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addAllTransition(Set<Transition> transitions) throws FinalizedStateException {
|
||||||
|
if(this.isFinalized){
|
||||||
|
throw new FinalizedStateException();
|
||||||
|
}
|
||||||
|
for (Transition transition : transitions) {
|
||||||
|
this.addTransition(transition);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@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();
|
||||||
} else if (!this.states.contains(state)) {
|
}
|
||||||
this.states.add(state);
|
this.states.add(state);
|
||||||
this.acceptingStates.add(state);
|
this.acceptingStates.add(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addAllAcceptingStates(Set<String> states) throws FinalizedStateException {
|
||||||
|
if(this.isFinalized){
|
||||||
|
throw new FinalizedStateException();
|
||||||
|
}
|
||||||
|
for (String state : states) {
|
||||||
|
this.addAcceptingState(state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// #TODO
|
// #TODO
|
||||||
@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();
|
||||||
}
|
}
|
||||||
NFAImpl unionNFA = new NFAImpl(this.initialState);
|
NFAImpl unionNFA = new NFAImpl(this.initialState);
|
||||||
|
|
@ -92,7 +116,7 @@ public class NFAImpl implements NFA {
|
||||||
// #TODO
|
// #TODO
|
||||||
@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()) {
|
||||||
throw new FinalizedStateException();
|
throw new FinalizedStateException();
|
||||||
}
|
}
|
||||||
NFAImpl intersectionNFA = new NFAImpl(this.initialState);
|
NFAImpl intersectionNFA = new NFAImpl(this.initialState);
|
||||||
|
|
@ -109,7 +133,7 @@ public class NFAImpl implements NFA {
|
||||||
// #TODO
|
// #TODO
|
||||||
@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()) {
|
||||||
throw new FinalizedStateException();
|
throw new FinalizedStateException();
|
||||||
}
|
}
|
||||||
NFAImpl concatenationNFA = new NFAImpl(this.initialState);
|
NFAImpl concatenationNFA = new NFAImpl(this.initialState);
|
||||||
|
|
@ -120,7 +144,7 @@ public class NFAImpl implements NFA {
|
||||||
concatenationNFA.transitions.addAll(this.transitions);
|
concatenationNFA.transitions.addAll(this.transitions);
|
||||||
concatenationNFA.transitions.addAll(other.getTransitions());
|
concatenationNFA.transitions.addAll(other.getTransitions());
|
||||||
|
|
||||||
for(String accceptingState : this.acceptingStates){
|
for (String accceptingState : this.acceptingStates) {
|
||||||
Transition epsilon = new Transition(accceptingState, null, other.getInitialState());
|
Transition epsilon = new Transition(accceptingState, null, other.getInitialState());
|
||||||
concatenationNFA.transitions.add(epsilon);
|
concatenationNFA.transitions.add(epsilon);
|
||||||
}
|
}
|
||||||
|
|
@ -185,7 +209,7 @@ public class NFAImpl implements NFA {
|
||||||
// #TODO
|
// #TODO
|
||||||
@Override
|
@Override
|
||||||
public NFA complement() throws FinalizedStateException {
|
public NFA complement() throws FinalizedStateException {
|
||||||
if(!this.isFinalized){
|
if (!this.isFinalized) {
|
||||||
throw new FinalizedStateException();
|
throw new FinalizedStateException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -228,7 +252,7 @@ public class NFAImpl implements NFA {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NFA convertNFAtoDFA (NFAImpl input){
|
public NFA convertNFAtoDFA(NFAImpl input) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
What do we need to do?
|
What do we need to do?
|
||||||
|
|
@ -240,6 +264,7 @@ public class NFAImpl implements NFA {
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
Set<String> dfaAcceptingStates = new HashSet<>();
|
||||||
// all states of the DFA
|
// all states of the DFA
|
||||||
List<Set<String>> dfaStates = new ArrayList<>();
|
List<Set<String>> dfaStates = new ArrayList<>();
|
||||||
// all transitions of the DFA
|
// all transitions of the DFA
|
||||||
|
|
@ -252,31 +277,15 @@ public class NFAImpl implements NFA {
|
||||||
// getting the epsilon closure of the start state
|
// 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)){
|
||||||
// find all letters in transitions
|
dfaAcceptingStates.add(getIndexOfSet(startState, dfaStates));
|
||||||
// obsolete, added alphabet to NFA which stores all read symbols
|
|
||||||
/*
|
|
||||||
Set<Character> possibleLetters = new HashSet<>();
|
|
||||||
Set<Transition> possibleTransitions = new HashSet<>();
|
|
||||||
for(Transition transition : input.transitions){
|
|
||||||
for(String state : states) {
|
|
||||||
if (state.equals(transition.fromState())){
|
|
||||||
|
|
||||||
if(transition.readSymbol() != null){
|
|
||||||
possibleLetters.add(transition.readSymbol());
|
|
||||||
possibleTransitions.add(transition);
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// do the above with each DFA state
|
// 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
|
// iterate each Letter
|
||||||
while (!queue.isEmpty()){
|
while (!queue.isEmpty()) {
|
||||||
Set<String> currentState = queue.poll();
|
Set<String> currentState = queue.poll();
|
||||||
// for each possible Letter
|
// for each possible Letter
|
||||||
for (char letter : input.getAlphabet()) {
|
for (char letter : input.getAlphabet()) {
|
||||||
|
|
@ -285,36 +294,31 @@ public class NFAImpl implements NFA {
|
||||||
if (!dfaStates.contains(newState)) {
|
if (!dfaStates.contains(newState)) {
|
||||||
queue.add(newState);
|
queue.add(newState);
|
||||||
dfaStates.add(newState);
|
dfaStates.add(newState);
|
||||||
// build new Transition
|
if (isAcceptingState(newState, input)) {
|
||||||
|
dfaAcceptingStates.add(getIndexOfSet(newState, dfaStates));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// build new Transition
|
// build new Transition
|
||||||
dfaTransitions.add(new Transition(Integer.toString(dfaStates.indexOf(currentState)), letter, Integer.toString(dfaStates.indexOf(newState))));
|
dfaTransitions.add(new Transition(Integer.toString(dfaStates.indexOf(currentState)), letter, Integer.toString(dfaStates.indexOf(newState))));
|
||||||
|
|
||||||
// we gotta change this to only a string is given
|
// we got to change this to only a string is given
|
||||||
//dfaTransitions.add(new Transition(currentState, letter, newState));
|
//dfaTransitions.add(new Transition(currentState, letter, newState));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
NFAImpl newDFA = new NFAImpl("0");
|
||||||
for(Character letter : possibleLetters){
|
|
||||||
Set<String> newState = new HashSet<>();
|
for(int i=1;i<dfaStates.size();i++){
|
||||||
for(Transition trans : possibleTransitions){
|
newDFA.states.add(""+i);
|
||||||
if(trans.readSymbol().equals(letter)){
|
|
||||||
// is every transition fromState = state from states? Hoffentlich ja :')
|
|
||||||
newState.add(trans.toState());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//deal with newState + new Transitions
|
|
||||||
if(DFA_states.contains(newState)){
|
|
||||||
Transition newtrans = new Transition(DFA_states.get(index), letter, DFA_states.get(DFA_states.indexOf(newState)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
newDFA.addAllTransition(dfaTransitions);
|
||||||
|
newDFA.addAllAcceptingStates(dfaAcceptingStates);
|
||||||
|
|
||||||
// what we gonna do now?
|
newDFA.finalizeAutomaton();
|
||||||
return null;
|
|
||||||
// return new DFA(dfaStates, dfaTransitions, startState, determineAcceptingStates(dfaStates, input));
|
return newDFA;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> epsilonClosure(Set<String> states, NFA nfa) {
|
private Set<String> epsilonClosure(Set<String> states, NFA nfa) {
|
||||||
|
|
@ -375,31 +379,13 @@ public class NFAImpl implements NFA {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<Set<String>> determineAcceptingStates(Set<Set<String>> dfaStates, NFA nfa) {
|
private boolean isAcceptingState(Set<String> states, NFA input) {
|
||||||
Set<Set<String>> acceptingStates = new HashSet<>();
|
for (String accState : input.getAcceptingStates()) {
|
||||||
for (Set<String> dfaState : dfaStates) {
|
if (states.contains(accState)) {
|
||||||
for (String nfaState : dfaState) {
|
return true;
|
||||||
if (nfa.getAcceptingStates().contains(nfaState)) {
|
|
||||||
acceptingStates.add(dfaState);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return false;
|
||||||
return acceptingStates;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void test(){
|
|
||||||
final NFAFactory factory = new NFAFactoryImpl();
|
|
||||||
var instance = factory.buildNFA("START");
|
|
||||||
instance.addTransition(
|
|
||||||
Transition.builder()
|
|
||||||
.fromState("START")
|
|
||||||
.readSymbol('a')
|
|
||||||
.toState("ACCEPT")
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
instance.addAcceptingState("ACCEPT");
|
|
||||||
instance.finalizeAutomaton();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
Reference in a new issue