Package org.python.antlr

Examples of org.python.antlr.ParseException


                if (!e.match(Py.SyntaxWarning)) {
                    throw e;
                }
            }
        }
        throw new ParseException(msg, node);
    }
View Full Code Here


    @Override
    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_(breakLabels.peek());
View Full Code Here

    @Override
    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_(continueLabels.peek());
View Full Code Here

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

        int stackState = saveStack();

        if (node.getInternalValue() != null) {
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.getInternalValue() != null) {
            if (my_scope.generator) {
                throw new ParseException("'return' with argument " +
                        "inside generator", node);
            }
            visit(node.getInternalValue());
            tmp = code.getReturnLocal();
            code.astore(tmp);
View Full Code Here

        Future.checkFromFuture(node); // future stmt support
        setline(node);
        code.ldc(node.getInternalModule());
        java.util.List<alias> aliases = node.getInternalNames();
        if (aliases == null || aliases.size() == 0) {
            throw new ParseException("Internel parser error", node);
        } else if (aliases.size() == 1 && aliases.get(0).getInternalName().equals("*")) {
            if (node.getInternalLevel() > 0) {
                throw new ParseException("'import *' not allowed with 'from .'", node);
            }
            if (my_scope.func_level > 0) {
                module.error("import * only allowed at module level", false, node);

                if (my_scope.contains_ns_free_vars) {
View Full Code Here

                code.invokevirtual(p(PyException.class), "match", sig(Boolean.TYPE,
                        PyObject.class));
                code.ifeq(end_of_self);
            } else {
                if (i != node.getInternalHandlers().size() - 1) {
                    throw new ParseException(
                            "default 'except:' must be last", handler);
                }
            }

            if (handler.getInternalName() != null) {
View Full Code Here

                        code.aload(temporary);
                        code.invokevirtual(p(PyFrame.class), "setlocal",
                                sig(Void.TYPE, String.class, PyObject.class));
                    } else {
                        if (syminf == null) {
                            throw new ParseException("internal compiler error", node);
                        }
                        if ((syminf.flags & ScopeInfo.CELL) != 0) {
                            code.iconst(syminf.env_index);
                            code.aload(temporary);
                            code.invokevirtual(p(PyFrame.class), "setderef", sig(Void.TYPE,
                                    Integer.TYPE, PyObject.class));
                        } else {
                            code.iconst(syminf.locals_index);
                            code.aload(temporary);
                            code.invokevirtual(p(PyFrame.class), "setlocal", sig(Void.TYPE,
                                    Integer.TYPE, PyObject.class));
                        }
                    }
                }
                return null;
            case Del: {
                loadFrame();
                if (syminf != null && (syminf.flags & ScopeInfo.GLOBAL) != 0) {
                    code.ldc(name);
                    code.invokevirtual(p(PyFrame.class), "delglobal", sig(Void.TYPE, String.class));
                } else {
                    if (!fast_locals) {
                        code.ldc(name);
                        code.invokevirtual(p(PyFrame.class), "dellocal",
                                sig(Void.TYPE, String.class));
                    } else {
                        if (syminf == null) {
                            throw new ParseException("internal compiler error", node);
                        }
                        if ((syminf.flags & ScopeInfo.CELL) != 0) {
                            module.error("can not delete variable '" + name +
                                    "' referenced in nested scope", true, node);
                        }
View Full Code Here

    }

    @Override
    public Object visitWith(With node) throws Exception {
        if (!module.getFutures().withStatementSupported()) {
            throw new ParseException("'with' will become a reserved keyword in Python 2.6", node);
        }

        final Label label_body_start = new Label();
        final Label label_body_end = new Label();
        final Label label_catch = new Label();
View Full Code Here

    private boolean check(ImportFrom cand) throws Exception {
        if (!cand.getInternalModule().equals(FutureFeature.MODULE_NAME))
            return false;
        if (cand.getInternalNames().isEmpty()) {
            throw new ParseException(
                    "future statement does not support import *", cand);
        }
        try {
            for (alias feature : cand.getInternalNames()) {
                // *known* features
                FutureFeature.addFeature(feature.getInternalName(), features);
            }
        } catch (ParseException pe) {
            throw new ParseException(pe.getMessage(), cand);
        }
        return true;
    }
View Full Code Here

TOP

Related Classes of org.python.antlr.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.