Search in sources :

Example 1 with Lexer

use of org.antlr.runtime.Lexer in project coffeescript-eclipse by adamschmideg.

the class FirstCommentIncludingXtextTokenStream method toString.

@Override
public String toString() {
    if (p == -1) {
        fillBuffer();
    }
    if (tokenSource instanceof Lexer) {
        if (tokens.isEmpty())
            return "";
        Token lastToken = (Token) tokens.get(tokens.size() - 1);
        if (lastToken instanceof CommonToken) {
            CommonToken commonStop = (CommonToken) lastToken;
            CharStream charStream = ((Lexer) tokenSource).getCharStream();
            String result = charStream.substring(0, commonStop.getStopIndex());
            return result;
        }
    }
    return super.toString();
}
Also used : Lexer(org.antlr.runtime.Lexer) Token(org.antlr.runtime.Token) CommonToken(org.antlr.runtime.CommonToken) CommonToken(org.antlr.runtime.CommonToken) CharStream(org.antlr.runtime.CharStream)

Aggregations

CharStream (org.antlr.runtime.CharStream)1 CommonToken (org.antlr.runtime.CommonToken)1 Lexer (org.antlr.runtime.Lexer)1 Token (org.antlr.runtime.Token)1