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

jaskell.parsec.common.Many 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.common;

import jaskell.parsec.ParsecException;

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

/**
 * Created by Mars Liu on 2016-01-03.
 * Many 算子匹配给定算子0到多次.
 */
public class Many
    implements Parsec> {
    private final Parsec parsec;

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

    public Many(Parsec parsec) {
        this.parsec = new Try<>(parsec);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy