Package org.boris.expr

Examples of org.boris.expr.ExprException


            break;
        case OpenBrace:
            parseArray(lexer, callback);
            break;
        default:
            throw new ExprException("Unexpected " + token.type + " found");
        }
    }
View Full Code Here


        int count = 0;
        ArrayList args = new ArrayList();
        while ((e = lexer.next()) != null) {
            if (e.type.equals(ExprTokenType.Comma)) {
                if (current == null)
                    throw new ExprException(
                            "Arrays cannot contain empty values");
                else
                    args.add(current);
                current = null;
                count++;
            } else if (e.type.equals(ExprTokenType.SemiColon)) {
                if (current == null)
                    throw new ExprException(
                            "Arrays cannot contain empty values");
                else
                    args.add(current);
                current = null;
                count++;

                if (count == 0) {
                    throw new ExprException(
                            "Array rows must contain at least one element");
                }
                if (cols != -1 && count != cols) {
                    throw new ExprException("Array rows must be equal sizes");
                }

                cols = count;
                count = 0;
            } else if (e.type.equals(ExprTokenType.CloseBrace)) {
View Full Code Here

            return;
        } else {
            Expr c = current;
            do {
                if (!(c instanceof IBinaryOperator))
                    throw new ExprException("Expected operator not found");

                Expr rhs = ((IBinaryOperator) c).getRHS();
                if (rhs == null) {
                    ((IBinaryOperator) c).setRHS(value);
                    return;
                } else {
                    c = rhs;
                }
            } while (c != null);

            throw new ExprException("Unexpected token found");
        }
    }
View Full Code Here

            break;
        case Equal:
            current = new ExprEqual(current, null);
            break;
        default:
            throw new ExprException("Unhandled operator type: " + e.type);
        }
    }
View Full Code Here

        }
    }

    private void parseMultiplyDivide(IBinaryOperator md) throws ExprException {
        if (current == null)
            throw new ExprException("Unexpected null token");

        Expr c = current;
        Expr prev = null;
        while (c != null) {
            if (c instanceof ExprAddition || c instanceof ExprSubtraction) {
View Full Code Here

    public Expr parse(String expression) throws ExprException {
        try {
            return ExprParser.parse(expression, evaluator).optimize();
        } catch (IOException e) {
            throw new ExprException(e);
        }
    }
View Full Code Here

            }

            return ExprError.NAME;
        }

        throw new ExprException("Invalid argument for function ROW");
    }
View Full Code Here

        return sb.toString();
    }

    public static Range valueOf(String var) throws ExprException {
        if (var == null) {
            throw new ExprException("Invalid empty variable name");
        }
        String namespace = null;
        int ni = var.indexOf('!');
        if (ni != -1) {
            namespace = var.substring(0, ni);
            if (!namespace.startsWith("'") &&
                    !GridReference.isValidVariable(namespace)) {
                throw new ExprException("Invalid namespace: " + namespace);
            }
            var = var.substring(ni + 1);
        }

        String dim1Name = null;
        GridReference dim1 = null;
        String dim2Name = null;
        GridReference dim2 = null;

        int di = var.indexOf(':');
        if (di != -1) {
            dim1Name = var.substring(0, di);
            dim1 = GridReference.valueOf(dim1Name);
            if (dim1 == null && !GridReference.isValidVariable(dim1Name)) {
                throw new ExprException("Invalid variable: " + dim1Name);
            }
            dim2Name = var.substring(di + 1);
            dim2 = GridReference.valueOf(dim2Name);
            if (dim2 == null && !GridReference.isValidVariable(dim2Name)) {
                throw new ExprException("Invalid variable: " + dim2Name);
            }
        } else {
            dim1Name = var;
            dim1 = GridReference.valueOf(var);
            if (dim1 == null && !GridReference.isValidVariable(dim1Name)) {
                throw new ExprException("Invalid variable: " + dim1Name);
            }

        }

        return new Range(namespace, dim1Name, dim1, dim2Name, dim2);
View Full Code Here

        return false;
    }

    protected void assertArgCount(Expr[] args, int count) throws ExprException {
        if (args == null && count != 0) {
            throw new ExprException(getClass().getSimpleName() +
                    " function takes no arguments");
        }

        if (args.length != count)
            throw new ExprException(getClass().getSimpleName() +
                    " function takes " + count + " arguments");
    }
View Full Code Here

    protected void assertArgTypes(Expr[] args, ExprType... types)
            throws ExprException {
        assertArgCount(args, types.length);
        for (int i = 0; i < args.length; i++) {
            if (!args[i].type.equals(types[i])) {
                throw new ExprException("Invalid argument (" + i + 1 +
                        ") to function: " + getClass().getSimpleName());
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.boris.expr.ExprException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.