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="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"WebServerToolWindowFactoryState": "false",
|
||||
"full.screen.before.presentation.mode": "false",
|
||||
"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",
|
||||
"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.lookFeel",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"WebServerToolWindowFactoryState": "false",
|
||||
"full.screen.before.presentation.mode": "false",
|
||||
"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",
|
||||
"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.lookFeel",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
}
|
||||
}]]></component>
|
||||
}</component>
|
||||
<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" />
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ public class NFAImpl implements NFA {
|
|||
|
||||
private Set<Character> alphabet;
|
||||
|
||||
private Set<Character> completeAlphabet;
|
||||
private boolean isFinalized;
|
||||
|
||||
public NFAImpl(String startState) {
|
||||
|
|
@ -24,9 +25,9 @@ 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.completeAlphabet = new HashSet<>();
|
||||
for(int i='a';i<='z';i++){
|
||||
completeAlphabet.add((char)i);
|
||||
}
|
||||
this.isFinalized = false;
|
||||
|
||||
|
|
@ -344,6 +345,8 @@ public class NFAImpl implements NFA {
|
|||
nfa.addAllTransitions(this.transitions);
|
||||
nfa.addAllAcceptingStates(this.acceptingStates);
|
||||
|
||||
nfaAddTrap(nfa);
|
||||
|
||||
NFAImpl fakeNFA = convertNFAtoDFA(nfa);
|
||||
|
||||
// state -> accepting
|
||||
|
|
@ -533,4 +536,25 @@ public class NFAImpl implements NFA {
|
|||
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