Search in sources :

Example 1 with PyParserCython

use of org.python.pydev.parser.grammar_cython.PyParserCython in project Pydev by fabioz.

the class PyParser method createCythonAst.

public static ParseOutput createCythonAst(ParserInfo info) {
    ParseOutput parseOutput = null;
    if (USE_NEW_CYTHON_PARSER) {
        PyParserCython parserCython = new PyParserCython(info);
        try {
            parseOutput = parserCython.parse();
            parseOutput.isCython = true;
        } catch (Exception e) {
            // If cython is not available, an error is expected.
            Log.log(e);
        }
    }
    if (parseOutput == null || parseOutput.ast == null) {
        // If we couldn't parse with cython, try to give something even if not really complete.
        List<stmtType> classesAndFunctions = FastParser.parseCython(info.document);
        Module ast = new Module(classesAndFunctions.toArray(new stmtType[classesAndFunctions.size()]));
        parseOutput = new ParseOutput(ast, parseOutput != null ? parseOutput.error : null, ((IDocumentExtension4) info.document).getModificationStamp());
        parseOutput.isCython = true;
    }
    return parseOutput;
}
Also used : IDocumentExtension4(org.eclipse.jface.text.IDocumentExtension4) org.python.pydev.parser.jython.ast.stmtType(org.python.pydev.parser.jython.ast.stmtType) PyParserCython(org.python.pydev.parser.grammar_cython.PyParserCython) Module(org.python.pydev.parser.jython.ast.Module) ResourceException(org.eclipse.core.internal.resources.ResourceException) CoreException(org.eclipse.core.runtime.CoreException) ParseException(org.python.pydev.parser.jython.ParseException) BadLocationException(org.eclipse.jface.text.BadLocationException) MisconfigurationException(org.python.pydev.core.MisconfigurationException)

Aggregations

ResourceException (org.eclipse.core.internal.resources.ResourceException)1 CoreException (org.eclipse.core.runtime.CoreException)1 BadLocationException (org.eclipse.jface.text.BadLocationException)1 IDocumentExtension4 (org.eclipse.jface.text.IDocumentExtension4)1 MisconfigurationException (org.python.pydev.core.MisconfigurationException)1 PyParserCython (org.python.pydev.parser.grammar_cython.PyParserCython)1 ParseException (org.python.pydev.parser.jython.ParseException)1 Module (org.python.pydev.parser.jython.ast.Module)1 org.python.pydev.parser.jython.ast.stmtType (org.python.pydev.parser.jython.ast.stmtType)1