All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jaskell.parsec.Many1 Maven / Gradle / Ivy

Go to download

This is a utils library for java 8 project. It include parsec combinators and sql generators library.

There is a newer version: 2.9.2
Show newest version
package jaskell.parsec;

import java.io.EOFException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Mars Liu on 2016-01-03.
 * Many1 匹配给定算子 1 到多次.
 */
public class Many1
    implements Parsec, Status, Tran> {
    private final Parsec parser;

    @Override
    public List parse(State s) throws EOFException, ParsecException {
        List re = new ArrayList<>();
        re.add(this.parser.parse(s));
        Parsec p = new Try<>(parser);
        try{
            while (true){
                re.add(p.parse(s));
            }
        } catch (Exception e){
            return re;
        }
    }

    public Many1(Parsec parsec){
        this.parser = parsec;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy