Merge branch '5-top-skill-issue-raphael' into 'main'
Resolve "top skill issue raphael" Closes #5 See merge request rawalcher/theorethische-informatik-gruppe-10!5
This commit is contained in:
commit
6c47b25ed2
3 changed files with 128 additions and 83 deletions
148
.idea/workspace.xml
generated
148
.idea/workspace.xml
generated
|
|
@ -4,16 +4,8 @@
|
|||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" name="Changes" comment="changed a bit">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
||||
<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/GRUPPE/NFAImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/ab1/impl/GRUPPE/NFAImpl.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/target/classes/ab1/impl/GRUPPE/NFAImpl.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/ab1/impl/GRUPPE/NFAImpl.class" afterDir="false" />
|
||||
</list>
|
||||
<list default="true" id="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" name="Changes" comment="concat GEHT" />
|
||||
<list id="39d4ccb3-eae9-4ed4-996a-5a13f44678fa" name="Changes by carol" comment="" />
|
||||
<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" />
|
||||
|
|
@ -22,7 +14,7 @@
|
|||
<component name="Git.Settings">
|
||||
<option name="RECENT_BRANCH_BY_REPOSITORY">
|
||||
<map>
|
||||
<entry key="$PROJECT_DIR$" value="2-playing-around" />
|
||||
<entry key="$PROJECT_DIR$" value="main" />
|
||||
</map>
|
||||
</option>
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
|
|
@ -43,49 +35,6 @@
|
|||
"second": "2afc8825-f511-4d8a-8cc1-901875567c84"
|
||||
}
|
||||
}</component>
|
||||
<component name="LineStatusTrackerManager">
|
||||
<file path="$PROJECT_DIR$/src/main/java/ab1/impl/GRUPPE/NFAImpl.java">
|
||||
<ranges>
|
||||
<range start1="16" end1="17" start2="16" end2="16" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="37" end1="37" start2="36" end2="42" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="52" end1="52" start2="57" end2="61" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="64" end1="65" start2="73" end2="76" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="69" end1="70" start2="80" end2="81" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="87" end1="88" start2="98" end2="99" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="95" end1="95" start2="106" end2="112" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="96" end1="97" start2="113" end2="114" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="104" end1="106" start2="121" end2="122" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="107" end1="109" start2="123" end2="124" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="110" end1="110" start2="125" end2="126" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="111" end1="111" start2="127" end2="129" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="112" end1="112" start2="130" end2="139" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="113" end1="117" start2="140" end2="147" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="118" end1="127" start2="148" end2="158" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="128" end1="130" start2="159" end2="161" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="131" end1="131" start2="162" end2="163" changelist="2bf04d9d-9125-4ed6-9018-847e14e9822c" />
|
||||
<range start1="132" end1="133" start2="164" end2="170" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="135" end1="136" start2="172" end2="179" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="137" end1="139" start2="180" end2="184" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="140" end1="142" start2="185" end2="190" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="260" end1="262" start2="308" end2="310" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="263" end1="264" start2="311" end2="312" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="265" end1="265" start2="313" end2="315" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="266" end1="268" start2="316" end2="317" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="269" end1="269" start2="318" end2="322" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="270" end1="271" start2="323" end2="331" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="272" end1="273" start2="332" end2="348" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="301" end1="301" start2="376" end2="378" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="303" end1="317" start2="380" end2="387" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="319" end1="326" start2="389" end2="390" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="328" end1="329" start2="392" end2="393" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="344" end1="345" start2="408" end2="409" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="374" end1="376" start2="438" end2="440" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="380" end1="382" start2="444" end2="444" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="424" end1="425" start2="486" end2="487" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
<range start1="428" end1="431" start2="490" end2="493" changelist="f5e08808-a5af-4c89-a1ee-21b3bcb9ae3e" />
|
||||
</ranges>
|
||||
</file>
|
||||
</component>
|
||||
<component name="MarkdownSettingsMigration">
|
||||
<option name="stateVersion" value="1" />
|
||||
</component>
|
||||
|
|
@ -103,7 +52,7 @@
|
|||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"WebServerToolWindowFactoryState": "false",
|
||||
"full.screen.before.presentation.mode": "false",
|
||||
"git-widget-placeholder": "main",
|
||||
"git-widget-placeholder": "5-top-skill-issue-raphael",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
|
|
@ -113,11 +62,11 @@
|
|||
"project.structure.last.edited": "Project",
|
||||
"project.structure.proportion": "0.0",
|
||||
"project.structure.side.proportion": "0.0",
|
||||
"settings.editor.selected.configurable": "preferences.pluginManager",
|
||||
"settings.editor.selected.configurable": "preferences.lookFeel",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
}
|
||||
}]]></component>
|
||||
<component name="RunManager" selected="JUnit.ComplexTests.complement1Test">
|
||||
<component name="RunManager" selected="JUnit.ab1 in ETI_Abgabe">
|
||||
<configuration name="ComplexTests.complement1Test" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
|
||||
<module name="ETI_Abgabe" />
|
||||
<extension name="coverage">
|
||||
|
|
@ -135,6 +84,23 @@
|
|||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<configuration name="ComplexTests.plus1Test" 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.ComplexTests" />
|
||||
<option name="METHOD_NAME" value="plus1Test" />
|
||||
<option name="TEST_OBJECT" value="method" />
|
||||
<dir value="$PROJECT_DIR$/src/test/java/ab1" />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<configuration name="ComplexTests.union1Test" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
|
||||
<module name="ETI_Abgabe" />
|
||||
<extension name="coverage">
|
||||
|
|
@ -186,11 +152,11 @@
|
|||
</configuration>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="JUnit.ComplexTests.complement1Test" />
|
||||
<item itemvalue="JUnit.ab1 in ETI_Abgabe" />
|
||||
<item itemvalue="JUnit.ComplexTests.plus1Test" />
|
||||
<item itemvalue="JUnit.ComplexTests.complement1Test" />
|
||||
<item itemvalue="JUnit.ComplexTests.union1Test" />
|
||||
<item itemvalue="JUnit.ab1.tests in ETI_Abgabe" />
|
||||
<item itemvalue="JUnit.ab1.tests in ETI_Abgabe" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
|
|
@ -212,6 +178,7 @@
|
|||
<workItem from="1704700821945" duration="5461000" />
|
||||
<workItem from="1704712375384" duration="4940000" />
|
||||
<workItem from="1704717343016" duration="2934000" />
|
||||
<workItem from="1704750167689" duration="2263000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="changed a bit">
|
||||
<option name="closed" value="true" />
|
||||
|
|
@ -221,7 +188,55 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1704734947115</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="2" />
|
||||
<task id="LOCAL-00002" summary="fucking hell">
|
||||
<option name="closed" value="true" />
|
||||
<created>1704749802065</created>
|
||||
<option name="number" value="00002" />
|
||||
<option name="presentableId" value="LOCAL-00002" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1704749802065</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00003" summary="Changes by danie">
|
||||
<option name="closed" value="true" />
|
||||
<created>1704749806556</created>
|
||||
<option name="number" value="00003" />
|
||||
<option name="presentableId" value="LOCAL-00003" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1704749806556</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00004" summary="fucking hell">
|
||||
<option name="closed" value="true" />
|
||||
<created>1704749811525</created>
|
||||
<option name="number" value="00004" />
|
||||
<option name="presentableId" value="LOCAL-00004" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1704749811525</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00005" summary="fucking hell">
|
||||
<option name="closed" value="true" />
|
||||
<created>1704750289780</created>
|
||||
<option name="number" value="00005" />
|
||||
<option name="presentableId" value="LOCAL-00005" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1704750289780</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00006" summary="concat GEHT">
|
||||
<option name="closed" value="true" />
|
||||
<created>1704752332678</created>
|
||||
<option name="number" value="00006" />
|
||||
<option name="presentableId" value="LOCAL-00006" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1704752332678</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00007" summary="concat GEHT">
|
||||
<option name="closed" value="true" />
|
||||
<created>1704752420737</created>
|
||||
<option name="number" value="00007" />
|
||||
<option name="presentableId" value="LOCAL-00007" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1704752420737</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="8" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
|
|
@ -230,26 +245,19 @@
|
|||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="progress of 7/1" />
|
||||
<MESSAGE value="changed a bit" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="changed a bit" />
|
||||
<MESSAGE value="Changes by danie" />
|
||||
<MESSAGE value="fucking hell" />
|
||||
<MESSAGE value="concat GEHT" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="concat GEHT" />
|
||||
</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="10" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="java-line">
|
||||
<url>file://$PROJECT_DIR$/src/test/java/ab1/tests/ComplexTests.java</url>
|
||||
<line>15</line>
|
||||
<option name="timeStamp" value="12" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="java-line">
|
||||
<url>file://$PROJECT_DIR$/src/main/java/ab1/impl/GRUPPE/NFAImpl.java</url>
|
||||
<line>347</line>
|
||||
<option name="timeStamp" value="21" />
|
||||
</line-breakpoint>
|
||||
</breakpoints>
|
||||
</breakpoint-manager>
|
||||
<watches-manager>
|
||||
|
|
|
|||
|
|
@ -3,16 +3,15 @@ package ab1.impl.GRUPPE;
|
|||
import ab1.FinalizedStateException;
|
||||
import ab1.NFA;
|
||||
import ab1.Transition;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class NFAImpl implements NFA {
|
||||
private Set<String> states;
|
||||
private Set<Transition> transitions;
|
||||
private final Set<String> states;
|
||||
private final Set<Transition> transitions;
|
||||
|
||||
private String initialState;
|
||||
private Set<String> acceptingStates;
|
||||
private final String initialState;
|
||||
private final Set<String> acceptingStates;
|
||||
|
||||
private Set<Character> alphabet;
|
||||
|
||||
|
|
@ -25,6 +24,10 @@ public class NFAImpl implements NFA {
|
|||
this.transitions = new HashSet<>();
|
||||
this.acceptingStates = new HashSet<>();
|
||||
this.alphabet = new HashSet<>();
|
||||
Set<Character> completeAlphabet = new HashSet<>();
|
||||
for (char ch = 'a'; ch <= 'z'; ch++) {
|
||||
completeAlphabet.add(ch);
|
||||
}
|
||||
this.isFinalized = false;
|
||||
|
||||
}
|
||||
|
|
@ -34,11 +37,13 @@ public class NFAImpl implements NFA {
|
|||
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
|
||||
public Collection<Transition> getTransitions() {
|
||||
|
|
@ -211,28 +216,55 @@ public class NFAImpl implements NFA {
|
|||
return intersectionNFA;
|
||||
}
|
||||
|
||||
// #TODO
|
||||
@Override
|
||||
public NFA concatenation(NFA other) throws FinalizedStateException {
|
||||
if (!this.isFinalized || !other.isFinalized()) {
|
||||
throw new FinalizedStateException();
|
||||
}
|
||||
|
||||
NFAImpl concatenationNFA = new NFAImpl(this.initialState);
|
||||
|
||||
// Add states from 'this'
|
||||
concatenationNFA.states.addAll(this.states);
|
||||
concatenationNFA.states.addAll(other.getStates());
|
||||
|
||||
// Add states from 'other', with renaming if necessary
|
||||
Map<String, String> renamedStates = new HashMap<>();
|
||||
for (String state : other.getStates()) {
|
||||
String newState = changeIfNecessary(state, concatenationNFA.states);
|
||||
renamedStates.put(state, newState); // Old state name -> New state name
|
||||
concatenationNFA.states.add(newState);
|
||||
}
|
||||
|
||||
// Add transitions from 'this'
|
||||
concatenationNFA.transitions.addAll(this.transitions);
|
||||
concatenationNFA.transitions.addAll(other.getTransitions());
|
||||
|
||||
for (String accceptingState : this.acceptingStates) {
|
||||
Transition epsilon = new Transition(accceptingState, null, other.getInitialState());
|
||||
// Add transitions from 'other', updating state names
|
||||
for (Transition transition : other.getTransitions()) {
|
||||
String newFromState = renamedStates.getOrDefault(transition.fromState(), transition.fromState());
|
||||
String newToState = renamedStates.getOrDefault(transition.toState(), transition.toState());
|
||||
Transition newTransition = new Transition(newFromState, transition.readSymbol(), newToState);
|
||||
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());
|
||||
for (String acceptingState : this.acceptingStates) {
|
||||
Transition epsilon = new Transition(acceptingState, null, newOtherInitialState);
|
||||
concatenationNFA.transitions.add(epsilon);
|
||||
}
|
||||
|
||||
// Set accepting states of the concatenated NFA to be the accepting states of 'other'
|
||||
concatenationNFA.acceptingStates.clear();
|
||||
for (String acceptingState : other.getAcceptingStates()) {
|
||||
concatenationNFA.acceptingStates.add(renamedStates.getOrDefault(acceptingState, acceptingState));
|
||||
}
|
||||
|
||||
concatenationNFA.finalizeAutomaton();
|
||||
|
||||
return concatenationNFA;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public NFA kleeneStar() throws FinalizedStateException {
|
||||
if (!this.isFinalized) {
|
||||
|
|
@ -256,6 +288,7 @@ public class NFAImpl implements NFA {
|
|||
nfa.transitions.add(loopBackTransition);
|
||||
}
|
||||
|
||||
nfa.finalizeAutomaton();
|
||||
|
||||
return nfa;
|
||||
}
|
||||
|
|
@ -293,6 +326,8 @@ public class NFAImpl implements NFA {
|
|||
}
|
||||
*/
|
||||
|
||||
nfa.finalizeAutomaton();
|
||||
|
||||
return nfa;
|
||||
}
|
||||
|
||||
|
|
@ -314,15 +349,15 @@ public class NFAImpl implements NFA {
|
|||
// state -> accepting
|
||||
// accepting -> state
|
||||
|
||||
Set<String> newAcceptingstate = new HashSet<>();
|
||||
Set<String> newAcceptingState = new HashSet<>();
|
||||
|
||||
for (String state : fakeNFA.getStates()) {
|
||||
if (!fakeNFA.getAcceptingStates().contains(state)) {
|
||||
newAcceptingstate.add(state);
|
||||
newAcceptingState.add(state);
|
||||
}
|
||||
}
|
||||
fakeNFA.acceptingStates.clear();
|
||||
fakeNFA.addAllAcceptingStates(newAcceptingstate);
|
||||
fakeNFA.addAllAcceptingStates(newAcceptingState);
|
||||
|
||||
Set<Character> originalAlphabet = new HashSet<>(fakeNFA.alphabet);
|
||||
|
||||
|
|
@ -388,6 +423,8 @@ public class NFAImpl implements NFA {
|
|||
currentStates = epsilonClosure(currentStates, this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return isAcceptingState(currentStates, this);
|
||||
}
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Reference in a new issue