-
Notifications
You must be signed in to change notification settings - Fork 17
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
Verilog preprocessor: implement multi-line defines #77
Conversation
This implements multi-line macros in the Verilog preprocessor.
@@ -362,13 +362,23 @@ void verilog_preprocessort::directive() | |||
// skip whitespace | |||
tokenizer().skip_ws(); | |||
|
|||
// Read any tokens until end of line. | |||
// Read any tokens until end of line, | |||
// but note that \n can be escaped with a backslash. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't verilog_preprocessor_token_sourcet::skip_until_eol
also learn about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately the standard is very unclear under which circumstances this is supposed to happen. I'll need to experiment with some standard tools.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is global, it might be preferable to move the escaping into the flex tokenizer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it might need to move into the tokenizer.
https://www.cs.utexas.edu/users/moore/acl2/manuals/current/manual/index-seo.php/VL____LEX-STRINGS
auto nl = tokenizer().next_token(); | ||
define.tokens.push_back(std::move(nl)); | ||
} | ||
else | ||
define.tokens.push_back(std::move(token)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably a matter of taste:
...
token = tokenizer().next_token();
}
define.tokens.push_back(std::move(token));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed a matter of taste; I do feel that the longer version is quicker to understand.
Also, are we still getting line numbers right in any warnings/errors affecting lines after a multi-line define? |
Yes, the line counting happens in the tokenizer. |
Right instinct; while the line counting in the preprocessor works, the line counting in the parser is off. |
This implements multi-line macros in the Verilog preprocessor.