list instead of set (for new transition)
This commit is contained in:
parent
b2f6932eae
commit
8e62fa914b
8 changed files with 25 additions and 168 deletions
|
|
@ -2,6 +2,7 @@ package ab1.impl.GRUPPE;
|
|||
|
||||
import ab1.FinalizedStateException;
|
||||
import ab1.NFA;
|
||||
import ab1.NFAFactory;
|
||||
import ab1.Transition;
|
||||
import lombok.Getter;
|
||||
|
||||
|
|
@ -240,7 +241,7 @@ public class NFAImpl implements NFA {
|
|||
*/
|
||||
|
||||
// all states of the DFA
|
||||
Set<Set<String>> dfaStates = new HashSet<>();
|
||||
List<Set<String>> dfaStates = new ArrayList<>();
|
||||
// all transitions of the DFA
|
||||
Set<Transition> dfaTransitions = new HashSet<>();
|
||||
|
||||
|
|
@ -284,11 +285,16 @@ public class NFAImpl implements NFA {
|
|||
if (!dfaStates.contains(newState)) {
|
||||
queue.add(newState);
|
||||
dfaStates.add(newState);
|
||||
// build new Transition
|
||||
}
|
||||
// build new Transition
|
||||
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
|
||||
//dfaTransitions.add(new Transition(currentState, letter, newState));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
for(Character letter : possibleLetters){
|
||||
Set<String> newState = new HashSet<>();
|
||||
|
|
@ -381,4 +387,19 @@ public class NFAImpl implements NFA {
|
|||
}
|
||||
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();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue