jaskell.parsec.SepBy1 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;
import java.io.EOFException;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Mars Liu on 2016-01-03.
* SepBy 尝试匹配由给定规则分隔开的1到多次重复匹配.
*/
public class SepBy1
implements Parsec, Status, Tran> {
private final Parsec by;
private final Parsec p;
@Override
public List parse(State s)
throws EOFException, ParsecException {
List re = new ArrayList<>();
re.add(this.p.parse(s));
Parsec parser = new Try<>(p);
try {
while (true) {
this.by.parse(s);
re.add(parser.parse(s));
}
} catch (EOFException|ParsecException e) {
return re;
}
}
public SepBy1(Parsec p, Parsec by) {
this.by = new Try<>(by);
this.p = p;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy