Package org.python.parser

Examples of org.python.parser.ParseException


    }

    public Object visitBreak(Break node) throws Exception {
        //setline(node); Not needed here...
        if (breakLabels.empty()) {
            throw new ParseException("'break' outside loop", node);
        }

        doFinallysDownTo(bcfLevel);

        code.goto_((Label) breakLabels.peek());
View Full Code Here


    }

    public Object visitContinue(Continue node) throws Exception {
        //setline(node); Not needed here...
        if (continueLabels.empty()) {
            throw new ParseException("'continue' not properly in loop", node);
        }

        doFinallysDownTo(bcfLevel);

        code.goto_((Label) continueLabels.peek());
View Full Code Here

    int f_savedlocals;

    public Object visitYield(Yield node) throws Exception {
        setline(node);
        if (!fast_locals) {
            throw new ParseException("'yield' outside function", node);
        }

        if (inFinallyBody()) {
            throw new ParseException("'yield' not allowed in a 'try' " + "block with a 'finally' clause", node);
        }

        saveLocals();
        visit(node.value);
        setLastI(++yield_count);
View Full Code Here

    }

    public Object visitReturn(Return node, boolean inEval) throws Exception {
        setline(node);
        if (!inEval && !fast_locals) {
            throw new ParseException("'return' outside function", node);
        }
        int tmp = 0;
        if (node.value != null) {
            if (my_scope.generator)
                throw new ParseException("'return' with argument " + "inside generator", node);
            visit(node.value);
            tmp = code.getReturnLocal();
            code.astore(tmp);
        }
        doFinallysDownTo(0);
View Full Code Here

                }
                code.invokestatic(mrefs.match_exception);
                code.ifeq(end_of_self);
            } else {
                if (i != node.handlers.length - 1) {
                    throw new ParseException("bare except must be last except clause", handler.type);
                }
            }

            if (handler.name != null) {
                code.aload(exc);
View Full Code Here

    }

    public Object visitUnicode(Unicode node) throws Exception {
        String s = node.s;
        if (s.length() > 32767) {
            throw new ParseException("string constant too large (more than 32767 characters)", node);
        }
        module.PyUnicode(s).get(code);
        return null;
    }
View Full Code Here

    }

    public Object visitStr(Str node) throws Exception {
        String s = node.s;
        if (s.length() > 32767) {
            throw new ParseException("string constant too large (more than 32767 characters)", node);
        }
        module.PyString(s).get(code);
        return null;
    }
View Full Code Here

        }

        defaults = args.defaults;
        for (int i = 0; i < defaults.length; i++) {
            if (defaults[i] == null)
                throw new ParseException("non-default argument follows default argument", args.args[args.args.length
                        - defaults.length + i]);
        }
    }
View Full Code Here

    public Object visitName(Name node) throws Exception {
        if (node.ctx != Name.Store)
            return null;

        if (fpnames.contains(node.id)) {
            throw new ParseException("duplicate argument name found: " + node.id, node);
        }
        fpnames.addElement(node.id);
        return node.id;
    }
View Full Code Here

    }

    // if reader != null, reset it
    public static PyException fixParseError(ReaderCharStream reader, Throwable t, String filename) {
        if (t instanceof ParseException) {
            ParseException e = (ParseException) t;
            Token tok = e.currentToken;
            int col = 0;
            int line = 0;
            if (tok != null && tok.next != null) {
                col = tok.next.beginColumn;
                line = tok.next.beginLine;
            }
            String text = getLine(reader, line);
            return new PySyntaxError(e.getMessage(), line, col, text, filename);
        }
        if (t instanceof TokenMgrError) {
            TokenMgrError e = (TokenMgrError) t;
            boolean eofSeen = e.EOFSeen;

            int col = e.errorColumn;
            int line = e.errorLine;
            //System.err.println("eof seen: "+eofSeen+", "+e.curChar+", "+col+
            //                   ", "+line);
            String text = getLine(reader, line);
            if (eofSeen)
                col -= 1;
            return new PySyntaxError(e.getMessage(), line, col, text, filename);
        } else
            return Py.JavaError(t);
    }
View Full Code Here

TOP

Related Classes of org.python.parser.ParseException

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.