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