Search in sources :

Example 1 with JdomTreeAdaptor

use of org.freud.core.parser.JdomTreeAdaptor 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)

Example 2 with JdomTreeAdaptor

use of org.freud.core.parser.JdomTreeAdaptor in project freud by LMAX-Exchange.

the class CssJdomParser method parseCssToDocument.

private static Document parseCssToDocument(final Reader reader) throws RecognitionException, IOException {
    CssParser parser = new CssParser(new CommonTokenStream(new CssLexer(new ANTLRReaderStream(reader))));
    final JdomTreeAdaptor treeAdaptor = new JdomTreeAdaptor(CSS_ROOT_ELEMENT_NAME, CSS_TOKEN_TYPES);
    parser.setTreeAdaptor(treeAdaptor);
    parser.stylesheet();
    return treeAdaptor.getDocument();
}
Also used : CommonTokenStream(org.antlr.runtime.CommonTokenStream) JdomTreeAdaptor(org.freud.core.parser.JdomTreeAdaptor) ANTLRReaderStream(org.antlr.runtime.ANTLRReaderStream) CssParser(org.freud.analysed.css.parser.CssParser) CssLexer(org.freud.analysed.css.parser.CssLexer)

Aggregations

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