Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gumtree implementation in swift programming language #164

Open
aminul7506 opened this issue Sep 25, 2019 · 10 comments
Open

gumtree implementation in swift programming language #164

aminul7506 opened this issue Sep 25, 2019 · 10 comments

Comments

@aminul7506
Copy link

How can I implement gumtree for swift programming language using the existing codebase ? Should I implement a swift AST in java for this ?

@jrfaller jrfaller self-assigned this Sep 27, 2019
@jrfaller
Copy link
Member

Hi! It would be a nice feature! There are two solution, depending on if a parser for swift exists in Java. In this case you can use the parsers API to generate an AST compatible with Gumtree (see how it is done for instance in the module gen.js that uses Rhino. If this is not the case, you'll have to build an external tool that produces a XML file compatible with Gumtree, this how it's done in the gen.c module for instance. Which parser do you want to use?

@aminul7506
Copy link
Author

A parser for swift does not exist in Java but we have a parser for swift written in swift from https://github.com/yanagiba/swift-ast . I want to use this AST for swift. For this what should I do ? Should I make a tool from this swift AST that produces gumtree compatible XML file ? It would be helpful for me if you tell me about this.

@jrfaller
Copy link
Member

Yes you have to make an executable tool that uses your parser to produce a XML compatible with GumTree!

You can take a look to the format here (in testSerializeTree()): https://github.com/GumTreeDiff/gumtree/blob/develop/core/src/test/java/com/github/gumtreediff/test/TestTreeIoUtils.java

You can look how to implement the adapter here : https://github.com/GumTreeDiff/gumtree/tree/develop/gen.c/src/main/java/com/github/gumtreediff/gen/c

Good luck with that!

@aminul7506
Copy link
Author

Thank you sir. I am trying this.

@aminul7506
Copy link
Author

Sir, can you please tell me what is Type, Label , Length and Position of a Node with an example?

@jrfaller
Copy link
Member

jrfaller commented Oct 2, 2019

For instance consider the Python code v = 12;

We have the following tree :

Therefore, type: lexical category of the node
value (only valid for leaf nodes): associated value (for instance v for the NameStore or 12 for the Num
pos: absolute position (number of elapsed characters) of the beginning of the node in the text file
length: length of the node in the text file, in characters (we have end_pos = pos + length)

Cheers!

@aminul7506
Copy link
Author

aminul7506 commented Oct 3, 2019

Another question. Where I have to install cgum for seeing the diff for C programme? I am trying to see the C programme diff in gumtree but failed

@jrfaller
Copy link
Member

jrfaller commented Oct 4, 2019

Hi! cgum is here : https://github.com/GumTreeDiff/cgum

But if it's easier you can also look into the gen.python and https://github.com/GumTreeDiff/pythonparser tools that does exactly the same also. I just fixed these two yesterday so they use all the good practices for implementing an external generator.

Cheers!

@jrfaller
Copy link
Member

Hi! Any progress on this issue? Cheers!

@jrfaller
Copy link
Member

Hi @aminul7506!

If you are still interested by having Swift into GumTree I think I can use the tree sitter parser easily now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants