jaskell.parsec.common.Ahead 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;
/**
* Created by Mars Liu on 16/9/15.
* Ahead look forward state and try to match parser.
* Ahead return the parser data or fail and rollback state whatever
*/
public class Ahead
implements Parsec {
Parsec parser;
@Override
public T parse(State s) throws EOFException, ParsecException {
Integer tran = s.begin();
try {
return parser.parse(s);
} finally {
s.rollback(tran);
}
}
public Ahead(Parsec parser){
this.parser = parser;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy