Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tool to find commented out VHDL code

Tags:

comments

vhdl

This question asks the general question. I'm asking about VHDL in particular, since the tools that question's answer mentions are for Java and PL/SQL. It doesn't need to be perfect, some manual interpretation would be fine. I'm doing this for an automated commit task.

EDIT 3/9/11: @phillipe pointed out automated commit task is inconsistent with manual interpretation. I'm trying to encourage other engineers to get rid of code and see that they did it. I guess a pessimistic tool would be better for commits; if it misses some code that isn't the end of the world. Or I could make it report the number of such lines and email me rather than stop the commit.

like image 440
Brian Carlton Avatar asked Oct 12 '22 13:10

Brian Carlton


1 Answers

It seems to me that the ideal answer requires that you apply a parser that can recognize langauge substrings to the content of each comment. If the syntax error rate is small compared to the size of the comment, then you have commented-out code.

To do this, you need a parser that is willing to parse incomplete code fragments. Program transformation systems that offer source-to-source transformations (if you see this structure, replace it by that structure) have this machinery built-in; they must parse code patterns comprising the source-to-source transformations, which are generally language sentential forms.

Our DMS Software Reengineering Toolkit has exactly this property. As usual with DMS, it would have to be configured to parse VHDL (or Verilog) [this easy, DMS has full VHDL, Verilog and SystemVerilog front ends), scan the parse tree, find the attached comments (DMS captures comments as it parses), and then attempt to parse the comments using DMS's built-in "Pattern Parser". Some bookeeping to count syntax errors is needed. So this is possible.

I suspect it isn't worth the trouble. Your regexp hueristic is probably pretty good especially when backed up by a human being, if that human doesn't mind having to extra code reviews.

like image 64
Ira Baxter Avatar answered Oct 18 '22 02:10

Ira Baxter