Package com.googlecode.aviator.exception

Examples of com.googlecode.aviator.exception.CompileExpressionErrorException


            mv.visitInsn(ARETURN);
            pushOperand(0);
            popOperand();
        }
        if (this.operandsCount > 0) {
            throw new CompileExpressionErrorException("operand stack is not empty,count=" + operandsCount);
        }
        mv.visitMaxs(maxStacks, maxLocals);
        mv.visitEnd();

        checkClassAdapter.visitEnd();
View Full Code Here


        byte[] bytes = this.classWriter.toByteArray();
        try {
            return new ClassExpression(classLoader.defineClass(className, bytes));
        }
        catch (Exception e) {
            throw new CompileExpressionErrorException("define class error", e);
        }
    }
View Full Code Here

     *            Whether to cache the compiled result,make true to cache it.
     * @return
     */
    public static Expression compile(final String expression, boolean cached) {
        if (expression == null || expression.trim().length() == 0) {
            throw new CompileExpressionErrorException("Blank expression");
        }

        if (cached) {
            FutureTask<Expression> task = cacheExpressions.get(expression);
            if (task != null) {
View Full Code Here

        try {
            return task.get();
        }
        catch (Exception e) {
            cacheExpressions.remove(expression);
            throw new CompileExpressionErrorException("Compile expression failure:" + expression, e);
        }
    }
View Full Code Here

            if (analyse) {
                if (peek == ' ' || peek == '\t') {
                    continue;
                }
                if (peek == '\n') {
                    throw new CompileExpressionErrorException("Aviator doesn't support newline expression,index="
                            + iterator.getIndex());
                }
                else {
                    break;
                }
            }
            else {
                char ch = peek;
                int index = this.iterator.getIndex();
                nextChar();
                return new CharToken(ch, index);
            }

        }

        // If it is a digit
        if (Character.isDigit(peek) || peek == '.') {
            StringBuffer sb = new StringBuffer();
            int startIndex = iterator.getIndex();
            Number value = 0L;
            boolean hasDot = false;
            double d = 10.0;
            do {
                sb.append(peek);
                if (peek == '.') {
                    if (hasDot) {
                        throw new CompileExpressionErrorException("Illegal Number, index=" + iterator.getIndex());
                    }
                    else {
                        hasDot = true;
                        value = new Double(value.longValue());
                        nextChar();
                    }

                }
                else {
                    if (!hasDot) {
                        value = 10 * value.longValue() + Character.digit(peek, 10);
                        nextChar();
                    }
                    else {
                        value = value.doubleValue() + Character.digit(peek, 10) / d;
                        d = d * 10;
                        nextChar();
                    }
                }
            } while (Character.isDigit(peek) || peek == '.');
            return new NumberToken(value, sb.toString(), startIndex);
        }

        // It is a variable
        if (Character.isJavaIdentifierStart(peek)) {
            int startIndex = iterator.getIndex();
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(peek);
                nextChar();
            } while (Character.isJavaIdentifierPart(peek) || peek == '.');
            String lexeme = sb.toString();
            Variable variable = new Variable(lexeme, startIndex);
            // If it is a reserved word(true or false)
            if (symbolTable.contains(lexeme)) {
                return symbolTable.getVariable(lexeme);
            }
            else {
                symbolTable.reserve(lexeme, variable);
                return variable;
            }

        }

        if (isBinaryOP(peek)) {
            CharToken opToken = new CharToken(peek, iterator.getIndex());
            nextChar();
            return opToken;
        }
        // String
        if (peek == '"' || peek == '\'') {
            char left = peek;
            int startIndex = iterator.getIndex();
            StringBuilder sb = new StringBuilder();
            while ((peek = iterator.next()) != left) {
                if (peek == CharacterIterator.DONE) {
                    throw new CompileExpressionErrorException("Illegal String,start index=" + startIndex);
                }
                else {
                    sb.append(peek);
                }
            }
View Full Code Here

TOP

Related Classes of com.googlecode.aviator.exception.CompileExpressionErrorException

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.