Search in sources :

Example 1 with ExprDouble

use of org.csstudio.autocomplete.parser.engine.expr.ExprDouble 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 ExprDouble

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

the class ExprParser method parseOperator.

private void parseOperator(ExprToken e, ExprLexer lexer) throws ExprException, IOException {
    // handle negative numbers
    if ((e.type == ExprTokenType.Minus || e.type == ExprTokenType.Plus) && current == null) {
        ExprToken nextToken = lexer.next();
        if (nextToken == null)
            return;
        Expr value = null;
        switch(nextToken.type) {
            case Decimal:
                value = new ExprDouble(e.type == ExprTokenType.Minus ? -nextToken.doubleValue : nextToken.doubleValue);
                setValue(value);
                return;
            case Integer:
                value = new ExprInteger(e.type == ExprTokenType.Minus ? -nextToken.integerValue : nextToken.integerValue);
                setValue(value);
                return;
            default:
                break;
        }
        current = new ExprBinaryOperator(ExprType.BinaryOperation, null, null);
        parseToken(lexer, nextToken);
        return;
    }
    current = new ExprBinaryOperator(ExprType.BinaryOperation, current, null);
}
Also used : ExprDouble(org.csstudio.autocomplete.parser.engine.expr.ExprDouble) Expr(org.csstudio.autocomplete.parser.engine.expr.Expr) ExprBinaryOperator(org.csstudio.autocomplete.parser.engine.expr.ExprBinaryOperator) ExprInteger(org.csstudio.autocomplete.parser.engine.expr.ExprInteger)

Aggregations

Expr (org.csstudio.autocomplete.parser.engine.expr.Expr)2 ExprDouble (org.csstudio.autocomplete.parser.engine.expr.ExprDouble)2 ExprInteger (org.csstudio.autocomplete.parser.engine.expr.ExprInteger)2 ExprBinaryOperator (org.csstudio.autocomplete.parser.engine.expr.ExprBinaryOperator)1 ExprPV (org.csstudio.autocomplete.parser.engine.expr.ExprPV)1 ExprString (org.csstudio.autocomplete.parser.engine.expr.ExprString)1 ExprVariable (org.csstudio.autocomplete.parser.engine.expr.ExprVariable)1