Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automatically comment preprocessor conditionals #2171

Open
fangism opened this issue Apr 30, 2024 · 0 comments
Open

automatically comment preprocessor conditionals #2171

fangism opened this issue Apr 30, 2024 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers preprocessor anything related to preprocessing (conditionals, macros, etc.) style-linter Verilog style-linter issues

Comments

@fangism
Copy link
Collaborator

fangism commented Apr 30, 2024

Summary

This request captures features from a script that lived outside of Verible, but some developers found useful.
The script (by @jonmayergoogle ) would automatically add comments after ifdef elsif else endif directives that reflected the condition under which the section was active, and served as a readability aid.

Test cases and examples

/* Hello, world. */
alpha
`ifdef FOO
/*
beta
`ifndef BAR
*/
luke
`ifdef BUM  // is BUM defined
wookie
`endif  // this comment gets removed
r2d2
`endif
wedge

would automatically become annotated like:

/* Hello, world. */
alpha
`ifdef FOO  // FOO
/*
beta
`ifndef BAR
*/
luke
`ifdef BUM  // FOO && BUM
wookie
`endif  // FOO && BUM
r2d2
`endif  // FOO
wedge

Proposal

The implementation for this would be based on an unpreprocessed token stream. No syntactic validation is needed, as this is purely a transformation based on preprocessing tokens. The simplicity of this task means that we don't need a full syntax tree transformation/rewriting framework.

Additional context

cl/629042737 (Google)

@fangism fangism added enhancement New feature or request style-linter Verilog style-linter issues preprocessor anything related to preprocessing (conditionals, macros, etc.) good first issue Good for newcomers labels Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers preprocessor anything related to preprocessing (conditionals, macros, etc.) style-linter Verilog style-linter issues
Projects
None yet
Development

No branches or pull requests

1 participant