Search in sources :

Example 1 with TypeAnnotationLexer

use of org.cx4a.rsense.parser.TypeAnnotationLexer in project rsense by m2ym.

the class AnnotationHelper method parseAnnotation.

public static TypeAnnotation parseAnnotation(String annot, int lineno) {
    if (annot.startsWith("#%")) {
        ANTLRStringStream in = new ANTLRStringStream(annot.substring(2));
        in.setLine(lineno);
        TypeAnnotationLexer lex = new TypeAnnotationLexer(in);
        CommonTokenStream tokens = new CommonTokenStream(lex);
        TypeAnnotationParser parser = new TypeAnnotationParser(tokens);
        try {
            return parser.type();
        } catch (RecognitionException e) {
        }
    }
    return null;
}
Also used : ANTLRStringStream(org.antlr.runtime.ANTLRStringStream) CommonTokenStream(org.antlr.runtime.CommonTokenStream) TypeAnnotationLexer(org.cx4a.rsense.parser.TypeAnnotationLexer) RecognitionException(org.antlr.runtime.RecognitionException) TypeAnnotationParser(org.cx4a.rsense.parser.TypeAnnotationParser)

Aggregations

ANTLRStringStream (org.antlr.runtime.ANTLRStringStream)1 CommonTokenStream (org.antlr.runtime.CommonTokenStream)1 RecognitionException (org.antlr.runtime.RecognitionException)1 TypeAnnotationLexer (org.cx4a.rsense.parser.TypeAnnotationLexer)1 TypeAnnotationParser (org.cx4a.rsense.parser.TypeAnnotationParser)1