fixed bug
This commit is contained in:
parent
007f135c9e
commit
0c0dd043ec
1 changed files with 15 additions and 8 deletions
|
|
@ -98,8 +98,6 @@ public class NFAImpl implements NFA {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
// #TODO
|
||||
@Override
|
||||
public NFA kleeneStar() throws FinalizedStateException {
|
||||
if (!this.isFinalized) {
|
||||
|
|
@ -112,20 +110,22 @@ public class NFAImpl implements NFA {
|
|||
nfa.states.addAll(this.states);
|
||||
nfa.transitions.addAll(this.transitions);
|
||||
|
||||
// adding the initial state as accepting state because we have to accept the empty string
|
||||
nfa.acceptingStates.add(this.initialState);
|
||||
|
||||
// for each accepting state
|
||||
for (String acceptingState : this.acceptingStates) {
|
||||
Transition loopBackTransition =
|
||||
// creating an epsilon transition (null) for each accepting state
|
||||
new Transition(acceptingState, null, this.initialState);
|
||||
if (!nfa.transitions.contains(loopBackTransition)) {
|
||||
nfa.transitions.add(loopBackTransition);
|
||||
}
|
||||
|
||||
// adding the initial state as accepting state because we have to accept the empty string
|
||||
nfa.acceptingStates.add(this.initialState);
|
||||
}
|
||||
|
||||
return nfa;
|
||||
}
|
||||
|
||||
// #TODO
|
||||
@Override
|
||||
public NFA plusOperator() throws FinalizedStateException {
|
||||
if (!this.isFinalized) {
|
||||
|
|
@ -144,8 +144,10 @@ public class NFAImpl implements NFA {
|
|||
Transition loopBackTransition =
|
||||
// creating an epsilon transition (null) for each accepting state
|
||||
new Transition(acceptingState, null, this.initialState);
|
||||
if (!nfa.transitions.contains(loopBackTransition)) {
|
||||
nfa.transitions.add(loopBackTransition);
|
||||
}
|
||||
}
|
||||
|
||||
return nfa;
|
||||
}
|
||||
|
|
@ -156,6 +158,11 @@ public class NFAImpl implements NFA {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void turnNFAIntoDFA(NFAImpl nfa) {
|
||||
// #TODO
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isFinalized() {
|
||||
return isFinalized;
|
||||
|
|
|
|||
Reference in a new issue