Search in sources :

Example 1 with JavaParser

use of org.freud.analysed.javasource.parser.JavaParser in project freud by LMAX-Exchange.

the class JavaSourceJdomParser method parseJavaSourceToDocument.

private static Document parseJavaSourceToDocument(final Reader javaSourceReader) throws RecognitionException, IOException {
    JavaParser parser = new JavaParser(new CommonTokenStream(new JavaLexer(new ANTLRReaderStream(javaSourceReader))));
    final JdomTreeAdaptor treeAdaptor = new JdomTreeAdaptor(JAVA_SOURCE_ROOT_ELEMENT_NAME, JAVA_SOURCE_TOKEN_TYPES);
    parser.setTreeAdaptor(treeAdaptor);
    parser.compilationUnit();
    return treeAdaptor.getDocument();
}
Also used : JavaParser(org.freud.analysed.javasource.parser.JavaParser) CommonTokenStream(org.antlr.runtime.CommonTokenStream) JdomTreeAdaptor(org.freud.core.parser.JdomTreeAdaptor) JavaLexer(org.freud.analysed.javasource.parser.JavaLexer) ANTLRReaderStream(org.antlr.runtime.ANTLRReaderStream)

Aggregations

ANTLRReaderStream (org.antlr.runtime.ANTLRReaderStream)1 CommonTokenStream (org.antlr.runtime.CommonTokenStream)1 JavaLexer (org.freud.analysed.javasource.parser.JavaLexer)1 JavaParser (org.freud.analysed.javasource.parser.JavaParser)1 JdomTreeAdaptor (org.freud.core.parser.JdomTreeAdaptor)1