-
Notifications
You must be signed in to change notification settings - Fork 732
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
Improve consistency of lexing of class-like names in C++ lexer #1495
Improve consistency of lexing of class-like names in C++ lexer #1495
Conversation
There are are a number of issues mentioned in #394, but for ease of reference, I note that this will fix two of the bullet points in the OP. |
@integricho Sorry to lean on you again but if you're able to have a peek at this, that'd be great. I don't think I'll ever not feel out of my depth when it comes to C++ :P |
Looks good, thanks! but take everything I say with a grain of salt :) |
@integricho Thanks for your help! I've merged this into the main branch and it will be part of the next release of Rouge. That's scheduled for release on Tuesday 14 April 🎉 |
…ouge-ruby#1495) Rouge's C++ lexer currently tokenises identifiers that come after the class keyword with the `Name::Class` token and identifiers that come after the `struct` keyword with the generic `Name` token. This is despite the fact that the only difference between a struct and a class in C++ is the default access specifier. Similarly, when used in a template definition, a typename is equivalent to a class but Rouge treats the identifiers that follow the `typename` and `class` keywords differently. This commit addresses this problem. It treats class and struct as equivalent in all cases while treating typename as equivalent when used in a template definition.
The change in #1495 to the way that the `template` keyword caused template parameter packs not to be highlighted correctly. This commit fixes that bug while also introducing a more robust set of rules for highlighting identifiers succeeding the `template` keyword.
The change in rouge-ruby#1495 to the way that the `template` keyword caused template parameter packs not to be highlighted correctly. This commit fixes that bug while also introducing a more robust set of rules for highlighting identifiers succeeding the `template` keyword.
Rouge's C++ lexer currently tokenises identifiers that come after the
class
keyword with theName::Class
token and identifiers that come after thestruct
keyword with the genericName
token. This is despite the fact that the only difference between a struct and a class in C++ is the default access specifier. Similarly, when used in a template definition, a typename is equivalent to a class but Rouge treats the identifiers that follow thetypename
andclass
keywords differently.This PR addresses this problem. It treats
class
andstruct
as equivalent in all cases while treatingtypename
as equivalent when used in a template definition.It fixes #1484.