Package org.python.antlr

Examples of org.python.antlr.ParseException


    }

    public static void checkFromFuture(ImportFrom node) throws Exception {
        if (node.from_future_checked) return;
        if (node.getInternalModule().equals(FutureFeature.MODULE_NAME)) {
            throw new ParseException("from __future__ imports must occur "
                    + "at the beginning of the file", node);
        }
        node.from_future_checked = true;
    }
View Full Code Here


    }

    public void defineAsGenerator(expr node) {
        generator = true;
        if (hasReturnWithValue) {
            throw new ParseException("'return' with argument " +
                    "inside generator", node);
        }
    }
View Full Code Here

        }
    }

    public void noteReturnValue(Return node) {
        if (generator) {
            throw new ParseException("'return' with argument " +
                    "inside generator", node);
        }
        hasReturnWithValue = true;
    }
View Full Code Here

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

        if (node.getInternalCtx() != expr_contextType.Store && node.getInternalCtx() != expr_contextType.Param) {
            return null;
        }

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

                reader = null;
            }
        }

        if (t instanceof ParseException) {
            ParseException e = (ParseException)t;
            PythonTree node = (PythonTree)e.node;
            int line=e.line;
            int col=e.charPositionInLine;
            if (node != null) {
                line = node.getLine();
                col = node.getCharPositionInLine();
            }
            String text= getLine(reader, line);
            String msg = e.getMessage();
            if (e.getType() == Py.IndentationError) {
                return new PyIndentationError(msg, line, col, text, filename);
            }
            return new PySyntaxError(msg, line, col, text, filename);
        } else if (t instanceof CharacterCodingException) {
            String msg;
View Full Code Here

        cflags.encoding = "utf-8";
       
        BufferedReader bufferedReader = new BufferedReader(reader);
        bufferedReader.mark(MARK_LIMIT);
        if (findEncoding(bufferedReader) != null)
            throw new ParseException("encoding declaration in Unicode string");
        bufferedReader.reset();

        return new ExpectedEncodingBufferedReader(bufferedReader, null);
    }
View Full Code Here

                encoding = cflags.encoding;
            }
        }
        if (cflags.source_is_utf8) {
            if (encoding != null) {
                throw new ParseException("encoding declaration in Unicode string");
            }
            encoding = "utf-8";
        }
        cflags.encoding = encoding;
View Full Code Here

    private static boolean adjustForBOM(InputStream stream) throws IOException {
        stream.mark(3);
        int ch = stream.read();
        if (ch == 0xEF) {
            if (stream.read() != 0xBB) {
                throw new ParseException("Incomplete BOM at beginning of file");
            }
            if (stream.read() != 0xBF) {
                throw new ParseException("Incomplete BOM at beginning of file");
            }
            return true;
        }
        stream.reset();
        return false;
View Full Code Here

            this.message = message;
        }

        @Override
        public Pragma getPragma(String name) {
            throw new ParseException(message);
        }
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.