chipsalliance / verible

Verible is a suite of SystemVerilog developer tools, including a parser, style-linter, formatter and language server
https://chipsalliance.github.io/verible/
Other
1.38k stars 214 forks source link

Verilog dialect support for lint rules (Verilog2009 vs. SystemVerilog2017) #141

Open fangism opened 4 years ago

fangism commented 4 years ago

A subset of the lint rules shouldn't apply to Verilog (2009) source files, e.g. forbid-defparam.

This multi-part task is to introduce a mapping of lint rule to dialects. For now, I think two dialects is sufficient: verilog (assume 2009), and systemverilog (assume 2017). Left unspecified, a rule should be enabled for all dialects, which should be most rules.

Introduce a mode/enum:

enum class VerilogDialect {
  kAutomatic,   // (default) use file extension to infer dialect
  kVerilog,  // Verilog2009
  kSystemVerilog,   // SystemVerilog2017
};

Another part of this task will be to introduce a --lang=[verilog|systemverilog|auto] flag to override.

The mode, once determined as Verilog/SystemVerilog will affect the linter configuration initialization. Use of the Verilog mode will automatically and silently disable a subset of lint rules (even if they are explicitly requested).

Non-goals: We do not intend to distinguish/fork parsers for the different dialects at this time. This means that even old Verilog files will be lexed/parsed as SystemVerilog, and produce compatible concrete syntax trees (same node enumerations). The consequence is that some SystemVerilog constructs may be accepted where they should be rejected, but that can be handled at a later time.

fangism commented 4 years ago

b/72410891

fangism commented 4 years ago

Thinking about this more, we could also maintain a std::set of rules-by-name to disable (unconditionally) when a source is being evaluated in kVerilog mode. const std::set<absl::string_view> kNotApplicableToVerilog? This might be more maintainable, especially if this list is short.