Extract comments, getting a count

14 views
Skip to first unread message

Srinivasan Venkataramanan

unread,
Feb 19, 2025, 2:54:16 PM2/19/25
to Verible Users
Thanks for this wonderful parser + API. I am trying to use the Python API to write some simple lint rule. Say we want to count the number of lines of actual code vs. comments (ideally get rid of blank lines). I read that comments are kept in a separate array, but not clear where. Below is what I have (from provided examples):

// code
  parser = verible_verilog_syntax.VeribleVerilogSyntax()
  data = parser.parse_files(af_ip_f, options={"gen_tree": True})
  for file_path, file_data in data.items():
     print (file_data.tree.text)
 
// code ends

Now, how do I get comments (multiline, single line, ideally even in-line ones) as separate?

Thanks
Srini
  
 
Reply all
Reply to author
Forward
0 new messages