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

jaskell.parsec.Decimal 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-08.
 * Decimal 尝试将后续的信息解析为 Decimal ,直到第一个无效信息为止.如果获取的信息不足以组成一个有效的浮点数,抛出异常.
 */
public class Decimal implements Parsec {

  private final Parsec sign = new Ch<>('-');
  private final UDecimal decimal = new UDecimal<>();

  @Override

  public String parse(State s)
      throws EOFException, ParsecException {
    if (sign.exec(s).isOk()) {
      return "-" + decimal.parse(s);
    } else {
      return decimal.parse(s);
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy