jaskell.parsec.common.Is Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jaskell-java8 Show documentation
Show all versions of jaskell-java8 Show documentation
This is a utils library for java 8 project.
It include parsec combinators and sql generators library.
package jaskell.parsec.common;
import jaskell.parsec.ParsecException;
import java.io.EOFException;
import java.util.function.Predicate;
/**
* TODO
*
* @author mars
* @version 1.0.0
* @since 2020/07/23 14:58
*/
public class Is implements Parsec {
private final Predicate predicate;
public Is(Predicate predicate) {
this.predicate = predicate;
}
@Override
public E parse(State s) throws EOFException, ParsecException {
E item = s.next();
if(predicate.test(item)){
return item;
} else {
throw s.trap(String.format("expect anything pass the predicate check but %s", item));
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy