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

Understand C++: Ignore comments #7

Open
cgmb opened this issue Aug 16, 2013 · 3 comments
Open

Understand C++: Ignore comments #7

cgmb opened this issue Aug 16, 2013 · 3 comments

Comments

@cgmb
Copy link
Owner

cgmb commented Aug 16, 2013

When searching through files, anything within comment blocks should be ignored as irrelevant.

@cgmb
Copy link
Owner Author

cgmb commented Jul 27, 2016

It seems that C gives you a surprising amount of flexibility in placing comments.

e.g.

/* comment */ # /* comment */ include /* comment */ <stdio.h> // comment

@cgmb
Copy link
Owner Author

cgmb commented Aug 4, 2016

It can be even worse...

/*
comment */ # /* comment */ include /* comment */ <stdio.h> /* comment
*/

In the smart parser, I've been stripping comments from the beginning and ends of the lines, because they're usually irrelevant once the code is changed. Unfortunately, it's a little unclear what to do when they span multiple lines. I suspect I should leave them alone. Multi-line comments are probably less likely to be specific to the line I'm removing than single-line comments are.

I've never actually seen this sort of code, but I could imagine it:

/* Copyright <Year> <Author>
   <License>
*/ #pragma once

@cgmb
Copy link
Owner Author

cgmb commented Feb 7, 2017

I should probably mention that the 'smart parser' was dropped in 3af39a7. Not sure if or when I'll work on it again. It would certainly handle a few more weird cases, like the horror above, but I would basically only find out if it was worth the (significant) effort after the fact.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant