GumTreeDiff / gumtree

An awesome code differencing tool
https://github.com/GumTreeDiff/gumtree/wiki
GNU Lesser General Public License v3.0
893 stars 170 forks source link

Can't generate a parse tree I get this error #348

Closed kahyata closed 1 month ago

kahyata commented 2 months ago

Here's the error Error while running client 'parse'. java.lang.UnsupportedOperationException: No generator found for file: C:\Users\User\Desktop\Slik\gumtree-main\gumtree-main at com.github.gumtreediff.gen.TreeGenerators.getTree(TreeGenerators.java:57) at com.github.gumtreediff.gen.TreeGenerators.getTree(TreeGenerators.java:70) at com.github.gumtreediff.client.ParseClient.getTreeContext(ParseClient.java:63) at com.github.gumtreediff.client.ParseClient.run(ParseClient.java:54) at com.github.gumtreediff.client.Run.startClient(Run.java:94) at com.github.gumtreediff.client.Run.main(Run.java:128)

despite adding the dependency required to my system and restarting it I am failing to run this simple as Trial for an assignment I am working on. Please Help The code is as follows import com.github.javaparser.StaticJavaParser; import com.github.javaparser.ast.CompilationUnit;

public class ParseTree{

public static void main(String[] args) throws Exception {
    String code = "public class ParseTrees {\n" +
            "public static void main(String[] args) {\n" +
            "\tString name = \"Kahyata\";\n" +
            "\tSystem.out.println(name);\n" +
            "}\n" +
            "}";

    CompilationUnit cu = StaticJavaParser.parse(code);

    // Count tokens
    countTokens(cu);

    // Generate parse tree
    // (implementation depends on your desired output format)
    System.out.println("Parse Tree (example):");
    // ... (your code to print the parse tree)
}

private static void countTokens(CompilationUnit cu) {
    // Implement logic to iterate through the AST and count occurrences of different token types
    // (e.g., keywords, identifiers, literals, operators)
}

}

jrfaller commented 2 months ago

Hi! The parser detection is based upon the file extension. What is the file extension of the file you are trying to parse?