JetBrains-Research / astminer

A library for mining of path-based representations of code (and more)
MIT License
282 stars 80 forks source link

How to extend to golang? #155

Closed binglinchengxiash closed 3 years ago

binglinchengxiash commented 3 years ago

I met some problems.not find class GoparserBase,I wonder how to write GoparserBase? image

SpirinEgor commented 3 years ago

Hi! It's unclear to me what do you want from GoParser and GoParserBase. Could you provide more details about what do you want to do?

binglinchengxiash commented 3 years ago

Hi! It's unclear to me what do you want from GoParser and GoParserBase. Could you provide more details about what do you want to do? Sorry for not expressing clearly.I want to train code2vec model using go language,and I use astiner to generate the input data needed by code2vec.I follow up this example to extend go language. image I have encountered some problems in step3.Can you give me some detailed descriptions?

illided commented 3 years ago

If you took go grammar from grammar repository try to take GoParserBase from https://github.com/antlr/grammars-v4/blob/master/golang/Java/GoParserBase.java and place it in the src/main/java/me/vovak/antlr/parser and run task again. Then you can write GoParser that will wrap parser from grammar.

binglinchengxiash commented 3 years ago

If you took go grammar from grammar repository try to take GoParserBase from https://github.com/antlr/grammars-v4/blob/master/golang/Java/GoParserBase.java and place it in the src/main/java/me/vovak/antlr/parser and run task again. Then you can write GoParser that will wrap parser from grammar.

Thank you very much.I will try later.

binglinchengxiash commented 3 years ago

If you took go grammar from grammar repository try to take GoParserBase from https://github.com/antlr/grammars-v4/blob/master/golang/Java/GoParserBase.java and place it in the src/main/java/me/vovak/antlr/parser and run task again. Then you can write GoParser that will wrap parser from grammar.

I have implemented GoParser, but I don’t know how to implement GoMethodSpliter, do you know how to do it?GoMethodSpliter is used to generated methods from go source code. image

illided commented 3 years ago

I have implemented GoParser, but I don’t know how to implement GoMethodSpliter, do you know how to do it?GoMethodSpliter is used to generated methods from go source code.

Now you need to split your Tree into subtrees and then create list of Function Info. You can search for examples in parse directory: every combination of parser and language has its own implementation of splitter and function info.

binglinchengxiash commented 3 years ago

I have implemented GoParser, but I don’t know how to implement GoMethodSpliter, do you know how to do it?GoMethodSpliter is used to generated methods from go source code.

Now you need to split your Tree into subtrees and then create list of Function Info. You can search for examples in parse directory: every combination of parser and language has its own implementation of splitter and function info.

OK,thank you,I will search some examples later.