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

org.unlaxer.tinyexpression.parser.AbstractBooleanExpressionParser Maven / Gradle / Ivy

There is a newer version: 1.4.6
Show newest version
package org.unlaxer.tinyexpression.parser;

import org.unlaxer.parser.Parser;
import org.unlaxer.parser.Parsers;
import org.unlaxer.parser.combinator.Choice;
import org.unlaxer.parser.combinator.WhiteSpaceDelimitedChain;
import org.unlaxer.parser.combinator.ZeroOrMore;
import org.unlaxer.parser.elementary.WordParser;
import org.unlaxer.tinyexpression.parser.javalang.JavaStyleDelimitedLazyChain;

public abstract class AbstractBooleanExpressionParser extends JavaStyleDelimitedLazyChain implements BooleanExpression , VariableTypeSelectable{

	private static final long serialVersionUID = 1362501275934237988L;

	public AbstractBooleanExpressionParser() {
		super();
	}



  @Override
  public org.unlaxer.parser.Parsers getLazyParsers(boolean withNakedVariable) {
    
    Class booleanExpressionParserClazz = 
        withNakedVariable ? BooleanFactorParser.class : StrictTypedBooleanFactorParser.class;
    
    //  ::= [('=='|'!='|'&'|'|'|'^')]*
    return
      new Parsers(
          Parser.get(booleanExpressionParserClazz),
          new ZeroOrMore(
            new WhiteSpaceDelimitedChain(
              new Choice(
                Parser.get(()->new EqualEqualParser()),
                Parser.get(()->new NotEqualParser()),
                Parser.get(()->new AndParser()),
                Parser.get(()->new OrParser()),
                Parser.get(()->new XorParser())
              ),
              Parser.get(booleanExpressionParserClazz)
            )
          )
        );
  }
  
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy