Package org.codehaus.commons.compiler

Examples of org.codehaus.commons.compiler.CompileException


    /**
     * Consume characters until a literal character is complete.
     */
    private char unescapeCharacterLiteral() throws CompileException, IOException {
        if (this.nextChar == -1) throw new CompileException("EOF in character literal", this.location());

        if (this.nextChar == '\r' || this.nextChar == '\n') {
            throw new CompileException("Line break in literal not allowed", this.location());
        }

        if (this.nextChar != '\\') {
            char res = (char) this.nextChar;
            this.readNextChar();
            return res;
        }
        this.readNextChar();
        int idx = "btnfr".indexOf(this.nextChar);
        if (idx != -1) {
            char res = "\b\t\n\f\r".charAt(idx);
            this.readNextChar();
            return res;
        }
        idx = "01234567".indexOf(this.nextChar);
        if (idx != -1) {
            int code = idx;
            this.readNextChar();
            idx = "01234567".indexOf(this.nextChar);
            if (idx == -1) return (char) code;
            code = 8 * code + idx;
            this.readNextChar();
            idx = "01234567".indexOf(this.nextChar);
            if (idx == -1) return (char) code;
            code = 8 * code + idx;
            if (code > 255) throw new CompileException("Invalid octal escape", this.location());
            this.readNextChar();
            return (char) code;
        }

        char res = (char) this.nextChar;
View Full Code Here


    // Read one character and store in "nextChar".
    private void readNextChar() throws IOException, CompileException {
        try {
            this.nextChar = this.in.read();
        } catch (UnicodeUnescapeException ex) {
            throw new CompileException(ex.getMessage(), this.location(), ex);
        }
        if (this.nextChar == '\r') {
            ++this.nextCharLineNumber;
            this.nextCharColumnNumber = 0;
            this.crLfPending = true;
View Full Code Here

        public boolean isKeyword() { return false; }
        public boolean isKeyword(String k) { return false; }
        public boolean isKeyword(String[] ks) { return false; }
        public String  getKeyword() throws CompileException {
            throw new CompileException("Not a keyword token", Scanner.this.location());
        }
View Full Code Here

        }

        public boolean isIdentifier() { return false; }
        public boolean isIdentifier(String id) { return false; }
        public String  getIdentifier() throws CompileException {
            throw new CompileException("Not an identifier token", Scanner.this.location());
        }
View Full Code Here

            throw new CompileException("Not an identifier token", Scanner.this.location());
        }

        public boolean isLiteral() { return false; }
        public Object  getLiteralValue() throws CompileException {
            throw new CompileException("Not a literal token", Scanner.this.location());
        }
View Full Code Here

        public boolean isOperator() { return false; }
        public boolean isOperator(String o) { return false; }
        public boolean isOperator(String[] os) { return false; }
        public String  getOperator() throws CompileException {
            throw new CompileException("Not an operator token", Scanner.this.location());
        }
View Full Code Here

        if (this.optionalDefaultImports != null) {
            for (int i = 0; i < this.optionalDefaultImports.length; ++i) {
                Scanner s = new Scanner(null, new StringReader(this.optionalDefaultImports[i]));
                cu.addImportDeclaration(new Parser(s).parseImportDeclarationBody());
                if (!s.peek().isEOF()) {
                    throw new CompileException("Unexpected token \"" + s.peek() + "\" in default import", s.location());
                }
            }
        }

        // Parse all available IMPORT declarations.
View Full Code Here

        this.cook(reader);

        try {
            return this.getClazz().newInstance();
        } catch (InstantiationException ie) {
            CompileException ce = new CompileException((
                "Class is abstract, an interface, an array class, a primitive type, or void; "
                + "or has no zero-parameter constructor"
            ), null);
            ce.initCause(ie);
            throw ce;
        } catch (IllegalAccessException iae) {
            CompileException ce = new CompileException(
                "The class or its zero-parameter constructor is not accessible",
                null
            );
            ce.initCause(iae);
            throw ce;
        }
    }
View Full Code Here

        cbe.cook(scanner);
        Class c = cbe.getClazz();
        try {
            return c.newInstance();
        } catch (InstantiationException e) {
            throw new CompileException(
                "Cannot instantiate abstract class -- one or more method implementations are missing",
                null
            );
        } catch (IllegalAccessException e) {
            // SNO - type and default constructor of generated class are PUBLIC.
View Full Code Here

    public Object createInstance(Reader reader) throws CompileException, IOException {
        this.cook(reader);
        try {
            return this.getClazz().newInstance();
        } catch (InstantiationException ie) {
            CompileException ce = new CompileException((
                "Class is abstract, an interface, an array class, a primitive type, or void; "
                + "or has no zero-parameter constructor"
            ), null);
            ce.initCause(ie);
            throw ce;
        } catch (IllegalAccessException iae) {
            CompileException ce = new CompileException(
                "The class or its zero-parameter constructor is not accessible",
                null
            );
            ce.initCause(iae);
            throw ce;
        }
    }
View Full Code Here

TOP

Related Classes of org.codehaus.commons.compiler.CompileException

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.