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

org.unlaxer.tinyexpression.parser.function.RandomParser Maven / Gradle / Ivy

The newest version!
package org.unlaxer.tinyexpression.parser.function;

import org.unlaxer.parser.Parser;
import org.unlaxer.parser.SuggestableParser;
import org.unlaxer.parser.ascii.LeftParenthesisParser;
import org.unlaxer.parser.ascii.RightParenthesisParser;
import org.unlaxer.parser.combinator.NoneChildCollectingParser;
import org.unlaxer.parser.combinator.WhiteSpaceDelimitedChain;
import org.unlaxer.tinyexpression.parser.NumberExpression;

public class RandomParser extends NoneChildCollectingParser implements NumberExpression{

	private static final long serialVersionUID = 7928239004297872018L;

	public RandomParser() {
		super();
	}
	
	public static class RandomFuctionNameParser extends SuggestableParser{

		private static final long serialVersionUID = 638526069284639995L;

		public RandomFuctionNameParser() {
			super(true, "random");
		}
		
		@Override
		public String getSuggestString(String matchedString) {
			return "(".concat(matchedString).concat(")");
		}
	}

	@Override
	public Parser createParser() {
	  return 
      new WhiteSpaceDelimitedChain(
        Parser.get(RandomFuctionNameParser.class),
        Parser.get(LeftParenthesisParser.class),
        Parser.get(RightParenthesisParser.class)
      );

	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy