Search in sources :

Example 1 with Expr

use of org.csstudio.autocomplete.parser.engine.expr.Expr in project yamcs-studio by yamcs.

the class ExprParser method parseValue.

private void parseValue(ExprToken e) throws ExprException {
    Expr value = null;
    switch(e.type) {
        case Decimal:
            value = new ExprDouble(e.doubleValue);
            break;
        case Integer:
            value = new ExprInteger(e.integerValue);
            break;
        case String:
            value = new ExprString(e.val);
            break;
        case Variable:
            value = new ExprVariable(e.val);
            break;
        case QuotedVariable:
            value = new ExprPV(e.val);
            break;
        default:
            break;
    }
    setValue(value);
}
Also used : ExprDouble(org.csstudio.autocomplete.parser.engine.expr.ExprDouble) Expr(org.csstudio.autocomplete.parser.engine.expr.Expr) ExprString(org.csstudio.autocomplete.parser.engine.expr.ExprString) ExprPV(org.csstudio.autocomplete.parser.engine.expr.ExprPV) ExprInteger(org.csstudio.autocomplete.parser.engine.expr.ExprInteger) ExprVariable(org.csstudio.autocomplete.parser.engine.expr.ExprVariable)

Example 2 with Expr

use of org.csstudio.autocomplete.parser.engine.expr.Expr in project yamcs-studio by yamcs.

the class ExprParser method parseExpression.

private void parseExpression(ExprLexer lexer) throws IOException, ExprException {
    Expr c = current;
    current = null;
    ExprToken e = null;
    while ((e = lexer.next()) != null) {
        if (e.type.equals(ExprTokenType.CloseBracket)) {
            Expr t = current;
            current = c;
            setValue(new ExprExpression(t));
            break;
        } else {
            parseToken(lexer, e);
        }
    }
}
Also used : ExprExpression(org.csstudio.autocomplete.parser.engine.expr.ExprExpression) Expr(org.csstudio.autocomplete.parser.engine.expr.Expr)

Example 3 with Expr

use of org.csstudio.autocomplete.parser.engine.expr.Expr in project yamcs-studio by yamcs.

the class FormulaContentParser method handleFunction.

private void handleFunction(ExprFunction f) {
    if (f.isComplete())
        return;
    currentToken = new FunctionDescriptor();
    currentToken.setValue(f.toString());
    currentToken.setFunctionName(f.getName());
    currentToken.setContentType(ContentType.FormulaFunction);
    currentToken.setOpenBracket(true);
    if (f.size() == 0) {
        currentToken.setCurrentArgIndex(0);
        return;
    }
    currentToken.setCurrentArgIndex(f.size() - 1);
    Expr lastArg = f.getArg(f.size() - 1);
    if (lastArg == null)
        return;
    handleExpr(lastArg);
}
Also used : Expr(org.csstudio.autocomplete.parser.engine.expr.Expr) FunctionDescriptor(org.csstudio.autocomplete.parser.FunctionDescriptor)

Example 4 with Expr

use of org.csstudio.autocomplete.parser.engine.expr.Expr in project yamcs-studio by yamcs.

the class FormulaContentParser method handleConditionalOperation.

private void handleConditionalOperation(ExprConditionalOperator co) {
    Expr value = co.getValueIfFalse();
    if (value == null)
        value = co.getValueIfTrue();
    if (value == null)
        return;
    handleExpr(value);
}
Also used : Expr(org.csstudio.autocomplete.parser.engine.expr.Expr)

Example 5 with Expr

use of org.csstudio.autocomplete.parser.engine.expr.Expr in project yamcs-studio by yamcs.

the class FormulaContentParser method handleBinaryOperation.

private void handleBinaryOperation(ExprBinaryOperator bo) {
    Expr rhs = bo.getRHS();
    if (rhs == null)
        return;
    handleExpr(rhs);
}
Also used : Expr(org.csstudio.autocomplete.parser.engine.expr.Expr)

Aggregations

Expr (org.csstudio.autocomplete.parser.engine.expr.Expr)11 ExprMissing (org.csstudio.autocomplete.parser.engine.expr.ExprMissing)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ExprDouble (org.csstudio.autocomplete.parser.engine.expr.ExprDouble)2 ExprException (org.csstudio.autocomplete.parser.engine.expr.ExprException)2 ExprFunction (org.csstudio.autocomplete.parser.engine.expr.ExprFunction)2 ExprInteger (org.csstudio.autocomplete.parser.engine.expr.ExprInteger)2 ExprVariable (org.csstudio.autocomplete.parser.engine.expr.ExprVariable)2 FunctionDescriptor (org.csstudio.autocomplete.parser.FunctionDescriptor)1 ExprArray (org.csstudio.autocomplete.parser.engine.expr.ExprArray)1 ExprBinaryOperator (org.csstudio.autocomplete.parser.engine.expr.ExprBinaryOperator)1 ExprConditionalOperator (org.csstudio.autocomplete.parser.engine.expr.ExprConditionalOperator)1 ExprExpression (org.csstudio.autocomplete.parser.engine.expr.ExprExpression)1 ExprPV (org.csstudio.autocomplete.parser.engine.expr.ExprPV)1 ExprString (org.csstudio.autocomplete.parser.engine.expr.ExprString)1