-
Notifications
You must be signed in to change notification settings - Fork 542
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
Skip linenum increment for indented code blocks #599
Conversation
An indented code block would cause the subsequent all subsequent code block line numbers (including its own) to be out by one. For example, the following would cause the line number for the `BEGIN` code block to have the line number for the `warning` code block. This would also affect the code in the final section after the second `%%`. %% yyflexdebug = 0; grab_frame = GRAB_FRAME; grab_other = GRAB_OTHER; grab_write = GRAB_WRITE; yylval->pointer = 0;// ensure pointer vals are null "/*" { BEGIN (COMMENT); } <COMMENT>"/*" { warning (0, "nested /* in comment"); }
This should have a test case to detect regression in the future. Is that someting you're able to add? |
Sure, I'll look into that. |
This checks the line numbers in multiple places, so it should help keep line numbers working in general.
Done. I covered as many places as I could think of, and I verified that it does catch the incorrect lines before the patch. |
What do you think about having the lexer be generated from something that e.g. grep -n 's the line numbers so that changing the source is less prone to break the test? |
Oh, hmm, I hadn't thought of that. Interesting idea. I'll see what I can come up with, but generation certainly makes sense. |
This makes the test much less fragile as now all that is need is for @line@ and __LINE__ to be on the same line (the comment gets substituted too, but it's a comment...)
I came up with something that works nicely so long as the two ( |
I had forgotten about distcheck
@westes are there any further issues? |
This looks great; thank you! |
An indented code block would cause the subsequent all subsequent code block line numbers (including its own) to be out by one.
For example, the following would cause the line number for the
BEGIN
code block to have the line number for thewarning
code block. This would also affect the code in the final section after the second%%
.