Package org.python.pydev.parser.jython

Examples of org.python.pydev.parser.jython.ParseException


        int errorStart = -1;
        int errorEnd = -1;
        int errorLine = -1;
        String message = null;
        if (error instanceof ParseException) {
            ParseException parseErr = (ParseException) error;

            // Figure out where the error is in the document, and create a
            // marker for it
            if (parseErr.currentToken == null) {
                IRegion endLine = doc.getLineInformationOfOffset(doc.getLength());
                errorStart = endLine.getOffset();
                errorEnd = endLine.getOffset() + endLine.getLength();

            } else {
                Token errorToken = parseErr.currentToken.next != null ? parseErr.currentToken.next
                        : parseErr.currentToken;
                IRegion startLine = doc.getLineInformation(getDocPosFromAstPos(errorToken.beginLine));
                IRegion endLine;
                if (errorToken.endLine == 0) {
                    endLine = startLine;
                } else {
                    endLine = doc.getLineInformation(getDocPosFromAstPos(errorToken.endLine));
                }
                errorStart = startLine.getOffset() + getDocPosFromAstPos(errorToken.beginColumn);
                errorEnd = endLine.getOffset() + errorToken.endColumn;
            }
            message = parseErr.getMessage();

        } else if (error instanceof TokenMgrError) {
            TokenMgrError tokenErr = (TokenMgrError) error;
            IRegion startLine = doc.getLineInformation(tokenErr.errorLine - 1);
            errorStart = startLine.getOffset();
View Full Code Here


            return createSpecialStr(((String) o).trim(), AbstractPythonGrammar.DEFAULT_SEARCH_ON_LAST, false);
        }
    }

    private ParseException createException(String token, final Token currentToken) {
        ParseException e;
        //return put;
        if (currentToken != null) {
            e = new ParseException("Expected:" + token, currentToken);

        } else if (grammar.getJJLastPos() != null) {
            e = new ParseException("Expected:" + token, grammar.getJJLastPos());

        } else {
            e = new ParseException("Expected:" + token);
        }
        return e;
    }
View Full Code Here

            }
        }

        if (throwException) {
            ParseException e = createException(token, currentToken);

            //we found it at the wrong position!
            if (foundToken != null) {
                //we found it, but not on the position we were expecting, so, we must skip some tokens to get to it --
                //and report the needed exception)
View Full Code Here

        }
        numberToFill.type = Num.Float;
    }

    private void handleNumberFormatException(Token t, NumberFormatException e) throws ParseException {
        grammar.addAndReport(new ParseException("Unable to parse number: " + t.image, t), e.getMessage());
    }
View Full Code Here

    }

    public Object visitName(Name node) throws Exception {
        if (ctx == expr_contextType.Store) {
            if (node.reserved) {
                throw new ParseException(com.aptana.shared_core.string.StringUtils.format("Cannot assign value to %s (because it's a keyword)",
                        node.id), node);
            }
        }
        node.ctx = ctx;
        return null;
View Full Code Here

        return null;
    }

    public Object visitList(List node) throws Exception {
        if (ctx == expr_contextType.AugStore) {
            throw new ParseException("augmented assign to list not possible", node);
        }
        node.ctx = ctx;
        traverse(node);
        return null;
    }
View Full Code Here

        return null;
    }

    public Object visitTuple(Tuple node) throws Exception {
        if (ctx == expr_contextType.AugStore) {
            throw new ParseException("augmented assign to tuple not possible", node);
        }
        node.ctx = ctx;
        traverse(node);
        return null;
    }
View Full Code Here

        traverse(node);
        return null;
    }

    public Object visitCall(Call node) throws Exception {
        throw new ParseException("can't assign to function call", node);
    }
View Full Code Here

    public Object visitCall(Call node) throws Exception {
        throw new ParseException("can't assign to function call", node);
    }

    public Object visitListComp(Call node) throws Exception {
        throw new ParseException("can't assign to list comprehension call", node);
    }
View Full Code Here

    public Object visitListComp(Call node) throws Exception {
        throw new ParseException("can't assign to list comprehension call", node);
    }

    public Object unhandled_node(SimpleNode node) throws Exception {
        throw new ParseException("can't assign to operator:" + node, node);
    }
View Full Code Here

TOP

Related Classes of org.python.pydev.parser.jython.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.