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

jaskell.parsec.UDecimal 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-07.
 * UDecimal 尝试将后续信息流解析成一个表示无符号浮点数的字符串,如果匹配失败就抛出异常.
 */
public class UDecimal implements Parsec {
  private final Parsec uint = new UInt<>();
  private final Parsec dot = new Ch<>('.');

  @Override
  public String parse(State s)
      throws EOFException, ParsecException {
    StringBuilder builder = new StringBuilder();
    builder.append(uint.parse(s));
    if (dot.exec(s).isOk()){
      builder.append('.');
      builder.append(uint.parse(s));
    }
    return builder.toString();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy