Package org.python.antlr.base

Examples of org.python.antlr.base.mod


    }
    public PyCode compile(String script, String filename) {
        return compile(new StringReader(script), filename);
    }
    public PyCode compile(Reader reader, String filename) {
        mod node = ParserFacade.parseExpressionOrModule(reader, filename, cflags);
        setSystemState();
        return Py.compile_flags(node, filename, CompileMode.eval, cflags);
    }
View Full Code Here


        parser.setTreeAdaptor(new PythonTreeAdaptor());
        return parser;
    }

    public mod parseExpression() {
        mod tree = null;
        PythonParser parser = setupParser(false);
        try {
            PythonParser.eval_input_return r = parser.eval_input();
            tree = (mod)r.tree;
        } catch (RecognitionException e) {
View Full Code Here

        }
        return tree;
    }

    public mod parseInteractive() {
        mod tree = null;
        PythonParser parser = setupParser(true);
        try {
            PythonParser.single_input_return r = parser.single_input();
            tree = (mod)r.tree;
        } catch (RecognitionException e) {
View Full Code Here

        }
        return tree;
    }

    public mod parseModule() {
        mod tree = null;
        PythonParser parser = setupParser(false);
        try {
            PythonParser.file_input_return r = parser.file_input();
            tree = (mod)r.tree;
        } catch (RecognitionException e) {
View Full Code Here

            in = new ANTLRFileStream(args[0]);
        } catch (Exception x) {
            x.printStackTrace();
        }
        AnalyzingParser p = new AnalyzingParser(in, args[0], "ascii");
        mod ast = p.parseModule();
        if (ast != null) {
            System.out.println("parse result: \n" + ast.toStringTree());
        } else {
            System.out.println("failure: \n" + p.getRecognitionErrors());
        }
    }
View Full Code Here

        String name = "<lambda>";

        //Add a return node onto the outside of suite;
        java.util.List<stmt> bod = new ArrayList<stmt>();
        bod.add(new Return(node, node.getInternalBody()));
        mod retSuite = new Suite(node, bod);

        setline(node);

        ScopeInfo scope = module.getScopeInfo(node);
View Full Code Here

    /**
     * Parse a file.  Does not look in the cache or cache the result.
     */
    private NModule parse(String path) throws Exception {
        fine("parsing " + path);
        mod ast = invokeANTLR(path);
        return generateAST(ast, path);
    }
View Full Code Here

    /**
     * Parse a string.  Does not look in the cache or cache the result.
     */
    private NModule parse(String path, String contents) throws Exception {
        fine("parsing " + path);
        mod ast = invokeANTLR(path, contents);
        return generateAST(ast, path);
    }
View Full Code Here

        return invokeANTLR(text, filename);
    }

    private mod invokeANTLR(CharStream text, String filename) {
        AnalyzingParser p = new AnalyzingParser(text, filename, null);
        mod ast = null;
        try {
            ast = p.parseModule();
        } catch (Exception x) {
            fine("parse for " + filename + " failed: " + x);
        }
View Full Code Here

    /**
     * Compiles python source code coming from a file or another external stream
     */
    public static PyCode compile_flags(InputStream istream, String filename,
                                         CompileMode kind, CompilerFlags cflags) {
        mod node = ParserFacade.parse(istream, kind, filename, cflags);
        return Py.compile_flags(node, filename, kind, cflags);
    }
View Full Code Here

TOP

Related Classes of org.python.antlr.base.mod

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.