Search in sources :

Example 1 with OperatorCallExpr

use of com.google.refine.grel.ast.OperatorCallExpr in project OpenRefine by OpenRefine.

the class Parser method parseSubExpression.

/**
     *  <sub-expression> := <term>
     *                    | <sub-expression> [ "+" "-" ] <term>
     */
protected Evaluable parseSubExpression() throws ParsingException {
    Evaluable sub = parseTerm();
    while (_token != null && _token.type == TokenType.Operator && "+-".indexOf(_token.text) >= 0) {
        String op = _token.text;
        next(true);
        Evaluable sub2 = parseTerm();
        sub = new OperatorCallExpr(new Evaluable[] { sub, sub2 }, op);
    }
    return sub;
}
Also used : OperatorCallExpr(com.google.refine.grel.ast.OperatorCallExpr) Evaluable(com.google.refine.expr.Evaluable)

Example 2 with OperatorCallExpr

use of com.google.refine.grel.ast.OperatorCallExpr in project OpenRefine by OpenRefine.

the class Parser method parseExpression.

/**
     *  <expression> := <sub-expression>
     *                | <expression> [ "<" "<=" ">" ">=" "==" "!=" ] <sub-expression>
     */
protected Evaluable parseExpression() throws ParsingException {
    Evaluable sub = parseSubExpression();
    while (_token != null && _token.type == TokenType.Operator && ">=<==!=".indexOf(_token.text) >= 0) {
        String op = _token.text;
        next(true);
        Evaluable sub2 = parseSubExpression();
        sub = new OperatorCallExpr(new Evaluable[] { sub, sub2 }, op);
    }
    return sub;
}
Also used : OperatorCallExpr(com.google.refine.grel.ast.OperatorCallExpr) Evaluable(com.google.refine.expr.Evaluable)

Example 3 with OperatorCallExpr

use of com.google.refine.grel.ast.OperatorCallExpr in project OpenRefine by OpenRefine.

the class Parser method parseTerm.

/**
     *  <term> := <factor>
     *          | <term> [ "*" "/" "%" ] <factor>
     */
protected Evaluable parseTerm() throws ParsingException {
    Evaluable factor = parseFactor();
    while (_token != null && _token.type == TokenType.Operator && "*/%".indexOf(_token.text) >= 0) {
        String op = _token.text;
        next(true);
        Evaluable factor2 = parseFactor();
        factor = new OperatorCallExpr(new Evaluable[] { factor, factor2 }, op);
    }
    return factor;
}
Also used : OperatorCallExpr(com.google.refine.grel.ast.OperatorCallExpr) Evaluable(com.google.refine.expr.Evaluable)

Aggregations

Evaluable (com.google.refine.expr.Evaluable)3 OperatorCallExpr (com.google.refine.grel.ast.OperatorCallExpr)3