Package org.python.parser

Examples of org.python.parser.PythonGrammar


    public static modType parse(byte[] istream, String kind, String filename, CompilerFlags cflags) {
        char[] bufreader = prepBufreader(istream, cflags);

        ReaderCharStream charStream = new ReaderCharStream(bufreader);
        PythonGrammar g = new PythonGrammar(charStream, literalMkrForParser);

        modType node = null;
        try {
            node = doparse(kind, cflags, g);
        } catch (Throwable t) {
View Full Code Here


        //System.err.println(new PyString(string).__repr__().toString());

        char[] bufreader = prepBufreader(PyString.to_bytes(string), cflags);

        ReaderCharStream charStream = new ReaderCharStream(bufreader);
        PythonGrammar g = new PythonGrammar(charStream, literalMkrForParser);

        g.token_source.partial = true;
        g.token_source.stdprompt = stdprompt;

        try {
            node = doparse(kind, cflags, g);
        } catch (Throwable t) {
            /*
             CPython codeop exploits that with CPython parser adding newlines
             to a partial valid sentence move the reported error position,
             this is not true for our parser, so we need a different approach:
             we check whether all sentence tokens have been consumed or
             the remaining ones fullfill lookahead expectations. See:
             PythonGrammar.partial_valid_sentence (def in python.jjt)
            */

            if (g.partial_valid_sentence(t)) {
                return null;
            }
            throw fixParseError(charStream, t, filename);
        }
        return node;
View Full Code Here

TOP

Related Classes of org.python.parser.PythonGrammar

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.