Skip to content

Commit

Permalink
feat: add EPSILON constant and getter method in NFA class
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony0380 committed Nov 3, 2024
1 parent 4355b65 commit 07dea93
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/src/main/java/computability/calculation/model/NFA.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@

public class NFA extends DFA {


protected static final char EPSILON = '$';

public static final char getEpsilon() {
return EPSILON;
}

@Override
/**
* Check if the given string is accepted by the NFA.
Expand Down Expand Up @@ -51,7 +56,7 @@ public boolean accept(String input, State state) {
public List<State> getNexStates(State state, char symbol) {
List<State> nextStates = new ArrayList<>();
for (Transition t : Transitions) {
if (t.getStart().equals(state) && (t.getSymbol() == symbol || t.getSymbol() == '$')) {
if (t.getStart().equals(state) && (t.getSymbol() == symbol || t.getSymbol() == EPSILON)) {
nextStates.add(t.getEnd());
}
}
Expand Down

0 comments on commit 07dea93

Please sign in to comment.