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

jaskell.expression.parser.A Maven / Gradle / Ivy

package jaskell.expression.parser;

import jaskell.expression.Add;
import jaskell.expression.Expression;
import jaskell.parsec.ParsecException;
import jaskell.parsec.common.SkipWhitespaces;
import jaskell.parsec.common.Parsec;
import jaskell.parsec.common.State;

import java.io.EOFException;

import static jaskell.parsec.common.Txt.ch;
import static jaskell.parsec.common.Txt.skipWhiteSpaces;

/**
 * TODO
 *
 * @author mars
 * @version 1.0.0
 * @since 2020/06/04 10:56
 */
public class A implements Parsec {
  private final SkipWhitespaces skips = skipWhiteSpaces();
  private final Parsec op = skips.then(ch('+')).then(skips);
  private final Expression prev;

  public A(Expression prev) {
    this.prev = prev;
  }

  @Override
  public Add parse(State s) throws EOFException, ParsecException {
    Parsec parser = new Parser();
    op.parse(s);
    return new Add(prev, parser.parse(s));
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy