org.unlaxer.tinyexpression.parser.NumberCaseFactorParser 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.Token;
import org.unlaxer.TokenPredicators;
import org.unlaxer.parser.Parser;
import org.unlaxer.parser.Parsers;
import org.unlaxer.parser.combinator.Choice;
import org.unlaxer.parser.elementary.WordParser;
import org.unlaxer.tinyexpression.parser.javalang.JavaStyleDelimitedLazyChain;
import org.unlaxer.util.annotation.TokenExtractor;
public class NumberCaseFactorParser extends JavaStyleDelimitedLazyChain{
private static final long serialVersionUID = -475039384168549876L;
public NumberCaseFactorParser() {
super();
addTag(ExpressionTags.matchCaseFactor.tag());
}
@Override
public org.unlaxer.parser.Parsers getLazyParsers() {
return
new Parsers(
Parser.get(BooleanExpressionParser.class),//0
new WordParser("->"),
new Choice(
Parser.newInstance(StrictTypedNumberExpressionParser.class),
Parser.get(NumberExpressionParser.class)
).addTag(NumberMatchExpressionParser.choiceTag)
);
}
@TokenExtractor
public static Token getBooleanExpression(Token thisParserParsed) {
return thisParserParsed.getChildWithParser(BooleanExpressionParser.class); //0
}
@TokenExtractor
public static Token getExpression(Token thisParserParsed) {
return thisParserParsed.getChild(
TokenPredicators.parserImplements(NumberExpression.class, VariableParser.class));
}
}