MikePopoloski / slang

SystemVerilog compiler and language services
MIT License
555 stars 120 forks source link

Comments and lines #557

Closed qarlosalberto closed 1 year ago

qarlosalberto commented 1 year ago

Is it possible show the line number and comments in the ast JSON output?

MikePopoloski commented 1 year ago

Yes, it's possible. Well, line number is fairly easy. Comments are perhaps ambiguous about which you want included and which you don't. This will certainly balloon the size of the JSON so it might not be practical for a large design.

qarlosalberto commented 1 year ago

That's cool.

My idea is to use slang in TerosHDL (https://terostechnology.github.io/terosHDLdoc/). Currently I'm using for the parser tree-sitter-verilog (https://github.com/tree-sitter/tree-sitter-verilog)

How you can see I extract the comments in the code to generate the documentation: https://terostechnology.github.io/terosHDLdoc/documenter/start.html

So I would like to do the same using slang instead tree-sitter-verilog

MikePopoloski commented 1 year ago

Ah nice. You might be better off with using slang as a library and having it dump just the various entities you care about and their comments, since you probably don't care about all the expression / statement trees that will otherwise clog up the JSON. I can provide assistance with that if you want.

qarlosalberto commented 1 year ago

Perfect! Sadly I'm not familiarized with C++, but I will try it.

MikePopoloski commented 1 year ago

I added a set of Python bindings along with a (very) simple example of using them to extract comments. Hopefully that helps.

qarlosalberto commented 1 year ago

Thanks!!

El mar., 9 ago. 2022 14:55, Michael Popoloski @.***> escribió:

I added a set of Python bindings along with a (very) simple example of using them to extract comments. Hopefully that helps.

— Reply to this email directly, view it on GitHub https://github.com/MikePopoloski/slang/issues/557#issuecomment-1209345900, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNN4RZ7ONF5EZF366EN4STVYJIKRANCNFSM52I4EPMQ . You are receiving this because you authored the thread.Message ID: @.***>