complement works now
This commit is contained in:
parent
6c47b25ed2
commit
0d47de5c44
3 changed files with 46 additions and 22 deletions
38
.idea/workspace.xml
generated
38
.idea/workspace.xml
generated
|
|
@ -46,26 +46,26 @@
|
||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent"><![CDATA[{
|
<component name="PropertiesComponent">{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"WebServerToolWindowFactoryState": "false",
|
"WebServerToolWindowFactoryState": "false",
|
||||||
"full.screen.before.presentation.mode": "false",
|
"full.screen.before.presentation.mode": "false",
|
||||||
"git-widget-placeholder": "5-top-skill-issue-raphael",
|
"git-widget-placeholder": "5-top-skill-issue-raphael",
|
||||||
"ignore.virus.scanning.warn.message": "true",
|
"ignore.virus.scanning.warn.message": "true",
|
||||||
"node.js.detected.package.eslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.detected.package.tslint": "true",
|
"node.js.detected.package.tslint": "true",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
"node.js.selected.package.tslint": "(autodetect)",
|
"node.js.selected.package.tslint": "(autodetect)",
|
||||||
"nodejs_package_manager_path": "npm",
|
"nodejs_package_manager_path": "npm",
|
||||||
"project.structure.last.edited": "Project",
|
"project.structure.last.edited": "Project",
|
||||||
"project.structure.proportion": "0.0",
|
"project.structure.proportion": "0.0",
|
||||||
"project.structure.side.proportion": "0.0",
|
"project.structure.side.proportion": "0.0",
|
||||||
"settings.editor.selected.configurable": "preferences.lookFeel",
|
"settings.editor.selected.configurable": "preferences.lookFeel",
|
||||||
"vue.rearranger.settings.migration": "true"
|
"vue.rearranger.settings.migration": "true"
|
||||||
}
|
}
|
||||||
}]]></component>
|
}</component>
|
||||||
<component name="RunManager" selected="JUnit.ab1 in ETI_Abgabe">
|
<component name="RunManager" selected="JUnit.ab1 in ETI_Abgabe">
|
||||||
<configuration name="ComplexTests.complement1Test" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
|
<configuration name="ComplexTests.complement1Test" type="JUnit" factoryName="JUnit" temporary="true" nameIsGenerated="true">
|
||||||
<module name="ETI_Abgabe" />
|
<module name="ETI_Abgabe" />
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ public class NFAImpl implements NFA {
|
||||||
|
|
||||||
private Set<Character> alphabet;
|
private Set<Character> alphabet;
|
||||||
|
|
||||||
|
private Set<Character> completeAlphabet;
|
||||||
private boolean isFinalized;
|
private boolean isFinalized;
|
||||||
|
|
||||||
public NFAImpl(String startState) {
|
public NFAImpl(String startState) {
|
||||||
|
|
@ -24,9 +25,9 @@ public class NFAImpl implements NFA {
|
||||||
this.transitions = new HashSet<>();
|
this.transitions = new HashSet<>();
|
||||||
this.acceptingStates = new HashSet<>();
|
this.acceptingStates = new HashSet<>();
|
||||||
this.alphabet = new HashSet<>();
|
this.alphabet = new HashSet<>();
|
||||||
Set<Character> completeAlphabet = new HashSet<>();
|
this.completeAlphabet = new HashSet<>();
|
||||||
for (char ch = 'a'; ch <= 'z'; ch++) {
|
for(int i='a';i<='z';i++){
|
||||||
completeAlphabet.add(ch);
|
completeAlphabet.add((char)i);
|
||||||
}
|
}
|
||||||
this.isFinalized = false;
|
this.isFinalized = false;
|
||||||
|
|
||||||
|
|
@ -344,6 +345,8 @@ public class NFAImpl implements NFA {
|
||||||
nfa.addAllTransitions(this.transitions);
|
nfa.addAllTransitions(this.transitions);
|
||||||
nfa.addAllAcceptingStates(this.acceptingStates);
|
nfa.addAllAcceptingStates(this.acceptingStates);
|
||||||
|
|
||||||
|
nfaAddTrap(nfa);
|
||||||
|
|
||||||
NFAImpl fakeNFA = convertNFAtoDFA(nfa);
|
NFAImpl fakeNFA = convertNFAtoDFA(nfa);
|
||||||
|
|
||||||
// state -> accepting
|
// state -> accepting
|
||||||
|
|
@ -533,4 +536,25 @@ public class NFAImpl implements NFA {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void nfaAddTrap(NFAImpl input){
|
||||||
|
String trap = changeIfNecessary("TRAP", input.getStates());
|
||||||
|
input.states.add(trap);
|
||||||
|
Set<Transition> newTransitions = new HashSet<>();
|
||||||
|
for(String state : input.getStates()){
|
||||||
|
for(char letter : completeAlphabet){
|
||||||
|
boolean hasTransition = false;
|
||||||
|
for(Transition transition : input.getTransitions()){
|
||||||
|
if(transition.fromState().equals(state)&&transition.readSymbol().equals(letter)){
|
||||||
|
hasTransition = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!hasTransition){
|
||||||
|
newTransitions.add(new Transition(state, letter, trap));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
input.addAllTransitions(newTransitions); //input.transitions.addAll(newTransitions);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
Reference in a new issue