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

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

package org.unlaxer.tinyexpression.parser;

import org.unlaxer.parser.Parser;
import org.unlaxer.parser.ascii.DivisionParser;
import org.unlaxer.parser.combinator.Choice;
import org.unlaxer.parser.combinator.NoneChildCollectingParser;
import org.unlaxer.parser.combinator.WhiteSpaceDelimitedChain;
import org.unlaxer.parser.combinator.ZeroOrMore;
import org.unlaxer.parser.elementary.MultipleParser;

public class TermParser extends NoneChildCollectingParser {
	
	private static final long serialVersionUID = 1430560948407993197L;
	
	public TermParser() {
		super();
	}
	
	Parser parser;
	
	@Override
	public void initialize() {
		// ::= [('*'|'/')]*
		parser = 
			new WhiteSpaceDelimitedChain(
				Parser.get(FactorParser.class),
				new ZeroOrMore(
					new WhiteSpaceDelimitedChain(
						new Choice(
							Parser.get(MultipleParser.class),
							Parser.get(DivisionParser.class)
						),
						Parser.get(FactorParser.class)
					)
				)
			);
	}

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy