-
If I understand correctly, transforming two input source code files into "GumTree's external format"¹ -- the XML output generated, e.g., by tree-sitter-parser -- is always the first step for diffing. I wondered if it is possible to skip this step and tell GumTree to directly process the given XML files. I think this could be useful to learn about the possibilities and limitations of the tool and help, e.g., in creating rewrite rules for tree-sitter-parser. ¹ I saw that this term was used in another discussion. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi! It depends whether or not a Java implementation of a parser is available. It it is, I use the parser API directly to produce a GumTree AST (example: It is possible to directly load an XML (using |
Beta Was this translation helpful? Give feedback.
-
Thanks for your detailled answer!
Yeah, I think it would be helpful. I was just making sure that I don't miss something but can try to provide an implementation in the following days. My first thought was to introduce an "identity generator" that does not parse anything but assumes the input files are already in GumTree's XML format. This way it could already work with all tools, such as the webdiff, etc. But maybe it's better to provide a "--raw" (or similar) argument to gumtree? |
Beta Was this translation helpful? Give feedback.
Hi!
It depends whether or not a Java implementation of a parser is available. It it is, I use the parser API directly to produce a GumTree AST (example:
rhino
for JS orjruby
for ruby). If it's not, I proceed to parsing using external parser with a system call that are expected to produce a custom XML format on the standard output that will be converted to a GumTree AST. I have several external parsers, normally only one language each (example:parso
for Python) at the notable exception oftree-sitter-parser
which is a facade to all available tree-sitter parsers.It is possible to directly load an XML (using
TreeIoUtils.fromXml().generateFrom()
) but there is no associated command line per…