lint external waiver file question: regex for multi-line waiver?

240 views
Skip to first unread message

Mark Pearce

unread,
Aug 10, 2021, 6:35:42 PM8/10/21
to Verible Users
Hello,

I'm using the external waiver file to waive lint errors (verible-verilog-lint) and I was wondering if someone knows a way to waive multiple lines with a single waiver, maybe with a --regex expression, or some other method?

Note: I cannot use the --line=5:10 method as the file is partially autogenerated and depending on the parameter settings etc. the failing lines will shift up and down by an unknown amount.

For example, 
```systemverilog
  assign var1 = <insert enough characters to fail line-length>
  // some comments maybe
  assign var2 = <insert enough characters to fail line-length>
  assign var3 = <insert enough characters to fail line-length>
```
And the waiver file could have something like:
```
waive --rule=line-length --location=".*failing_file_example.sv" --regex="assign([\s]+)var1(.*)assign([\s]+)var3"
```
(I'm no regex expert, but the middle (.*) is meant to include all chars, including newlines).  The idea being, the lines of code from "assign var1" through "assign var3" inclusive would be waived for line length.

The purpose being it would save me from writing three lines in the waive file:
```
waive --rule=line-length --location=".*failing_file_example.sv" --regex="assign([\s]+)var1"
waive --rule=line-length --location=".*failing_file_example.sv" --regex="assign([\s]+)var2"
waive --rule=line-length --location=".*failing_file_example.sv" --regex="assign([\s]+)var3"
```
I know I sound lazy, but I was thinking since there's a regex engine, maybe this is easy to implement?  Or maybe it's just that I'm crap at regex's and this already works if I correct my regex :-)

Thanks!

Mark

Tomasz Gorochowik

unread,
Aug 16, 2021, 9:02:55 AM8/16/21
to Mark Pearce, Verible Users
Hi Mark

the regex engine we use in the waiver config does not by default allow multi line matches. We could probably change the config for it to work but it could have some other unforeseen consequences (for other users) so I'd rather we created a ticker for this first before doing that to let people discuss it first.

That being said, I think in your case it should be okay to match each line individually. Assuming your three-line waiver configuration works correctly, the following should do the trick:
```
waive --rule=line-length --location=".*failing_file_example.sv" --regex="assign\s+var[1-3]"
```

I hope this helps!
Tom

--
You received this message because you are subscribed to the Google Groups "Verible Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to verible-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/verible-users/29fc5887-b7c0-4959-ba07-11f4c30d722bn%40googlegroups.com.


--
Tomasz Gorochowik
Antmicro Ltd | www.antmicro.com
Zwierzyniecka 3, 60-813 Poznan, Poland

Mark Pearce

unread,
Aug 18, 2021, 12:17:39 PM8/18/21
to Verible Users
Hi Tom,

Thanks for this response.  I'll file a discussion/feature ticket to initiate the discussion on whether and if so how to enable multiline regex matches.

And thanks for the regex tips, I'm still learning, even after many years of trying :-)

All the best,

Mark

Reply all
Reply to author
Forward
0 new messages