Package org.python.antlr

Examples of org.python.antlr.PythonLexer


     */
    private void highlightLexicalTokens() {
        RecognizerSharedState state = new RecognizerSharedState();
        state.errorRecovery = true// don't issue 10 billion errors

        PythonLexer lex = new PythonLexer(
            new ANTLRStringStream(source) {
                @Override
                public String getSourceName() {
                    return path;
                }
            },
            state);

        lex.setErrorHandler(new RecordingErrorHandler() {
                @Override
                public void error(String message, PythonTree t) {
                    // don't println
                }
                @Override
                public void reportError(BaseRecognizer br, RecognitionException re) {
                    // don't println
                }
            });

        Token tok;
        while ((tok = lex.nextToken()) != Token.EOF_TOKEN) {
            switch (tok.getType()) {
                case PythonLexer.STRING: {
                    int beg = ((CommonToken)tok).getStartIndex();
                    int end = ((CommonToken)tok).getStopIndex();
                    if (!docOffsets.contains(beg)) {
View Full Code Here

TOP

Related Classes of org.python.antlr.PythonLexer

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.