Skip to content

Commit

Permalink
FSM.Pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
Pastor committed Dec 23, 2024
1 parent 18b6b51 commit 5b233fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.ArrayList;
import java.util.List;

@SuppressWarnings("PMD.SimplifyBooleanReturnss")
@EqualsAndHashCode(of = "index")
public abstract class State {
final Manager manager;
Expand Down Expand Up @@ -61,7 +62,7 @@ public boolean match(Input input) {
}
return true;
}
return input.hasNext();
return false;
}

@Override
Expand Down Expand Up @@ -249,7 +250,6 @@ public boolean match(Input input) {
} else if (next != null && next.accept(copy)) {
return next.match(input);
}
return input.hasNext();
}
return false;
}
Expand Down Expand Up @@ -341,17 +341,16 @@ public boolean match(Input input) {
boolean matched = state.match(copy);
if (matched) {
Input prev = copy;
while (matched) {
boolean next = true;
while (next) {
prev = copy.copy();
matched = state.match(copy);
next = state.match(copy);
}
copy = prev;
if (next != null && next.accept(copy)) {
return next.match(copy);
if (this.next != null && this.next.accept(copy)) {
return this.next.match(copy);
}
}
if (next != null && next.accept(copy)) {
return next.match(copy);
return true;
}
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ protected static Stream<Arguments> patternMatching() {
);
}

@Disabled
@ParameterizedTest
@MethodSource("patternMatching")
void match(boolean isMatch, String input, String pattern) {
Expand Down

0 comments on commit 5b233fa

Please sign in to comment.