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

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

package org.unlaxer.tinyexpression.parser;

import org.unlaxer.parser.Parser;
import org.unlaxer.parser.combinator.Choice;
import org.unlaxer.parser.combinator.NoneChildCollectingParser;
import org.unlaxer.parser.elementary.NumberParser;
import org.unlaxer.parser.elementary.ParenthesesParser;

import org.unlaxer.tinyexpression.parser.function.CosParser;
import org.unlaxer.tinyexpression.parser.function.SinParser;
import org.unlaxer.tinyexpression.parser.function.SquareRootParser;
import org.unlaxer.tinyexpression.parser.function.TanParser;

public class FactorParser extends NoneChildCollectingParser {
	
	private static final long serialVersionUID = 3521391436954908685L;
	
	Parser parser;
	
	public FactorParser() {
		super();
	}

	@Override
	public void initialize() {
		// ::= |'('')'
		parser = 
			new Choice(
//					new TernaryOperatorParser(expressionParser),
				Parser.get(IfExpressionParser.class),
				Parser.get(NumberParser.class),
				Parser.get(VariableParser.class),
				
				new ParenthesesParser(Parser.get(ExpressionParser.class)),
				Parser.get(SinParser.class),
				Parser.get(CosParser.class),
				Parser.get(TanParser.class),
				Parser.get(SquareRootParser.class)
			);
	}



	@Override
	public Parser createParser() {
		return parser;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy