jaskell.parsec.common.NoneOf 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 static java.util.stream.Collectors.joining;
import jaskell.parsec.ParsecException;
import java.io.EOFException;
import java.util.Set;
/**
* Created by Mars Liu on 2016-01-03.
* NoneOf 即 none of ,它期待得到的信息项与给定的任何项都不匹配,否则返回错误.
*/
public class NoneOf implements
Parsec {
private final Set items;
@Override
public E parse(State s) throws EOFException, ParsecException {
E re = s.next();
if(items.contains(re)) {
String message = String.format("expect a item none of [%s] but got %s",
this.items.stream().map(E::toString).collect(joining()), re);
throw s.trap(message);
}
return re;
}
public NoneOf(Set items){
this.items = items;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy