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

jaskell.expression.parser.Param 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.expression.parser;

import static jaskell.parsec.common.Combinator.attempt;
import static jaskell.parsec.common.Combinator.choice;
import static jaskell.parsec.common.Combinator.many;
import static jaskell.parsec.common.Txt.digit;
import static jaskell.parsec.common.Txt.joining;
import static jaskell.parsec.common.Txt.letter;

import jaskell.expression.Expression;
import jaskell.expression.Parameter;
import jaskell.parsec.ParsecException;
import jaskell.parsec.common.Parsec;
import jaskell.parsec.common.State;

import java.io.EOFException;

/**
 * TODO
 *
 * @author mars
 * @version 1.0.0
 * @since 2020/06/10 17:54
 */
public class Param implements Parsec {
  private final Parsec head = letter();

  private final Parsec tail = many(choice(attempt(head), digit())).bind(joining());

  private final Parsec parser = s -> head.parse(s) + tail.parse(s);

  @Override
  public Expression parse(State s) throws EOFException, ParsecException {
    return new Parameter(parser.parse(s));
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy