Example usage for org.antlr.v4.runtime CharStreams fromString

List of usage examples for org.antlr.v4.runtime CharStreams fromString

Introduction

In this page you can find the example usage for org.antlr.v4.runtime CharStreams fromString.

Prototype

public static CodePointCharStream fromString(String s, String sourceName) 

Source Link

Document

Creates a CharStream given a String and the sourceName from which it came.

Usage

From source file:za.co.mip.ablduck.javadoc.Javadoc.java

License:Apache License

public List<String> parseComment(String comment, String source) {

    JavadocLexer lexer = new JavadocLexer(CharStreams.fromString(comment, source));
    lexer.removeErrorListeners();// ww  w  .  j a v  a 2 s .c  o  m
    lexer.addErrorListener(this.errorListener);

    CommonTokenStream tokens = new CommonTokenStream(lexer);

    JavadocParser parser = new JavadocParser(tokens);
    parser.removeErrorListeners();
    parser.addErrorListener(this.errorListener);

    JavadocParser.DocumentationContext documentation = parser.documentation();

    ParseTreeWalker walker = new ParseTreeWalker();
    JavadocListener listener = new JavadocListener();
    walker.walk(listener, documentation);

    return listener.getTags();
}