Skip to content

Commit

Permalink
Fix an overseen compile error
Browse files Browse the repository at this point in the history
  • Loading branch information
BjoernLoetters committed Jan 31, 2025
1 parent 9ac33f0 commit bdb398d
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions core/src/main/java/jjparse/StringParsing.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,20 +199,30 @@ public Description description() {
public Result<String> apply(final Input<Character> input) {
final Input<Character> skipped = skip(input);

final CharSequence sequence;
if (skipped instanceof CharacterInput characterInput) {
sequence = characterInput;
if (skipped instanceof CharacterInput sequence) {
final Matcher matcher = pattern.matcher(sequence);
if (matcher.lookingAt()) {
final String value = matcher.group();
return new Success<String>(value, sequence.subSequence(value.length(), sequence.length()));
} else {
return new Error<String>(Failure.format(skipped, description()), skipped);
}
} else {
sequence = new CharacterSequenceWrapper(input);
final CharacterSequenceWrapper sequence = new CharacterSequenceWrapper(skipped);
final Matcher matcher = pattern.matcher(sequence);
if (matcher.lookingAt()) {
final String value = matcher.group();
Input<Character> rest = skipped;
for (int i = 0; i < value.length(); ++i) {
rest = rest.tail();
}
return new Success<String>(value, rest);
} else {
return new Error<String>(Failure.format(skipped, description()), skipped);
}
}

final Matcher matcher = pattern.matcher(sequence);
if (matcher.lookingAt()) {
final String value = matcher.group();
return new Success<String>(value, sequence.subSequence(value.length(), sequence.length()));
} else {
return new Error<String>(Failure.format(sequence, description()), sequence);
}

}

}
Expand Down

0 comments on commit bdb398d

Please sign in to comment.