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

(cpp) Add additional keywords #2289

Merged
merged 3 commits into from Nov 24, 2019
Merged

(cpp) Add additional keywords #2289

merged 3 commits into from Nov 24, 2019

Conversation

aostrowski
Copy link
Contributor

No description provided.

@joshgoebel joshgoebel self-requested a review November 17, 2019 10:50
@joshgoebel joshgoebel added enhancement An enhancement or new feature language labels Nov 17, 2019
src/languages/cpp.js Outdated Show resolved Hide resolved
'asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp ' +
'fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper ' +
'isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow ' +
'printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp ' +
'strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan ' +
'vfprintf vprintf vsprintf endl initializer_list unique_ptr',
'vfprintf vprintf vsprintf endl initializer_list unique_ptr _Bool complex _Complex _Imaginary',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we also have imaginary as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprisingly, no. Those are keywords coming from C99, not all of them have their equivalents in the C++ standard library.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I said that because of: https://en.cppreference.com/w/c/numeric/complex/imaginary

    double imaginary i = 2.0*I; // pure imaginary

This macro expands to the keyword _Imaginary.

Defined in complex.h... if we don't count both how are we deciding that _Imaginary is a keyword but imaginary is not?

I'm welcome to be wrong here, but I'm trying to understand the logic we're using to call something a keyword.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You didn't respond? Am I thinking about this wrong? ... ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double imaginary i = 2.0*I; // pure imaginary
double _Imaginary i = 2.0*I; // pure imaginary

Given this snippet, wouldn't both cases of imaginary there count as keywords? Yes/no? Or are we drawing a distinction between build-in vs pulled in via some include?

Complex seems to be in the same boat:

https://en.cppreference.com/w/c/language/arithmetic_types#Complex_floating_types

So it seems to me if complex is a keyword, then imaginary also should be, and if not, then it should not? Same for bool...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you just want to do the simplest thing to get this PR approved from where I'm setting it seems we need to add imaginary as a keyword also, and then we're consistent. But fell free to make a case the other way if you think that's not correct.

@joshgoebel
Copy link
Member

Also, please add a changelog entry.

@joshgoebel joshgoebel changed the title Add missing C++ keywords (cpp) Add additional keywords Nov 17, 2019
@joshgoebel joshgoebel merged commit ca0ce8f into highlightjs:master Nov 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature language
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants