Fix comments within function declarations in C (#1891)#2140
Fix comments within function declarations in C (#1891)#2140jeanas merged 14 commits intopygments:masterfrom
Conversation
The regex to detect comments was tweaked to handle whitespace better. A group near the final punctuation in the function regex was accidentally forgotten. The group is now handled using(this).
The existing C parsing code places newlines into their own token, instead of combining them with other whitespace. This change results in the new parser not breaking any exisiting tests.
jeanas
left a comment
There was a problem hiding this comment.
Sorry for the delay. Sounds good, a few comments and we should be good to go.
|
Also, I think that fixing this minor issue by adding this much logic to an already complex part of the lexer is uncalled for, and can introduce maintenance problems. Please simplify this @lambda-karlculus. |
IMHO, with |
This now fails the tests, with: TypeError: get_tokens_unprocessed() got an unexpected keyword argument 'stack' Do not merge.
|
OK, I went ahead and changed your PR directly (don't expect me to do that every time 😄).
@amitkummer I think this is good to go. You have more experience than me tinkering with the |
|
Thank you! That's amazing!
|
I did that one as a simplification before I realized that the |
That would be welcome. |
|
Looks excellent now @jean-abou-samra, thanks! |
|
Thanks for reviewing, merging then. |
Fixes #1891 and other combinations of comments within function declarations in C.
Comments were not properly detected between the parts of function declarations. This was fixed by detecting those comments and passing them to a minimal lexer. A new test snippet file was created to test the fix.