org.unlaxer.tinyexpression.parser.AbstractBooleanExpressionParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tinyExpression Show documentation
Show all versions of tinyExpression Show documentation
TinyExpression implemented with Unlaxer
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 extends Parser> 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)
)
)
);
}
}