use of org.activityinfo.model.formula.functions.FormulaFunction in project activityinfo by bedatadriven.
the class FormulaParser method disjunction.
private FormulaNode disjunction() {
FormulaNode left = conjunction();
while (lexer.hasNext() && lexer.peek().isOrOperator()) {
FormulaFunction op = function();
FormulaNode right = conjunction();
left = binaryInfixCall(op, left, right);
}
return left;
}
use of org.activityinfo.model.formula.functions.FormulaFunction in project activityinfo by bedatadriven.
the class FormulaParser method factor.
public FormulaNode factor() {
// <factor> ::= <unary> | <factor> * <unary> | <factor> / <unary>
FormulaNode left = unary();
while (lexer.hasNext() && lexer.peek().isMultiplicativeOperator()) {
FormulaFunction function = function();
FormulaNode right = unary();
left = binaryInfixCall(function, left, right);
}
return left;
}
use of org.activityinfo.model.formula.functions.FormulaFunction in project activityinfo by bedatadriven.
the class FormulaParser method unary.
private FormulaNode unary() {
if (!lexer.hasNext()) {
throw new FormulaSyntaxException("Unexpected end of formula");
}
Token token = lexer.peek();
if (token.getType() == TokenType.OPERATOR) {
if (token.getString().equals("-") || token.getString().equals("+")) {
Token opToken = lexer.next();
FormulaFunction op = function(opToken);
FormulaNode operand = unary();
SourceRange sourceRange = new SourceRange(opToken.getStart(), operand.getSourceRange().getEnd());
return new FunctionCallNode(op, singletonList(operand), sourceRange);
}
}
return unary2();
}
use of org.activityinfo.model.formula.functions.FormulaFunction in project activityinfo by bedatadriven.
the class FormulaParser method unary2.
private FormulaNode unary2() {
if (!lexer.hasNext()) {
throw new FormulaSyntaxException("Unexpected end of formula");
}
Token token = lexer.peek();
if (token.getType() == TokenType.OPERATOR) {
if (token.getString().equals("!")) {
Token opToken = lexer.next();
FormulaFunction op = function(opToken);
FormulaNode operand = primary();
SourceRange sourceRange = new SourceRange(opToken.getStart(), operand.getSourceRange().getEnd());
return new FunctionCallNode(op, singletonList(operand), sourceRange);
}
}
return primary();
}
use of org.activityinfo.model.formula.functions.FormulaFunction in project activityinfo by bedatadriven.
the class FormulaParser method equality.
private FormulaNode equality() {
FormulaNode left = relational();
while (lexer.hasNext() && lexer.peek().isEqualityOperator()) {
FormulaFunction op = function();
FormulaNode right = relational();
left = binaryInfixCall(op, left, right);
}
return left;
}
Aggregations