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

enh(c) Update keyword list for C11/C18 #3010

Closed
joshgoebel opened this issue Feb 15, 2021 · 7 comments · Fixed by #3077
Closed

enh(c) Update keyword list for C11/C18 #3010

joshgoebel opened this issue Feb 15, 2021 · 7 comments · Fixed by #3077
Labels
enhancement An enhancement or new feature good first issue Should be easier for first time contributors help welcome Could use help from community language

Comments

@joshgoebel
Copy link
Member

joshgoebel commented Feb 15, 2021

Pulling this out because we should eventually apply this to our C grammar (removing the C++ keywords and types, etc).


The full list of keywords for C11/C18 is

                auto                          if                             unsigned
                break                         inline                         void
                case                          int                            volatile
                char                          long                           while
                const                         register                       _Alignas
                continue                      restrict                       _Alignof
                default                       return                         _Atomic
                do                            short                          _Bool
                double                        signed                         _Complex
                else                          sizeof                         _Generic
                enum                          static                         _Imaginary
                extern                        struct                         _Noreturn
                float                         switch                         _Static_assert
                for                           typedef                        _Thread_local
                goto                          union

Originally posted by @ztane in #2973 (comment)

@joshgoebel joshgoebel added enhancement An enhancement or new feature good first issue Should be easier for first time contributors help welcome Could use help from community language labels Feb 15, 2021
@joshgoebel joshgoebel changed the title enh(c) The full list of *keywords* for C11/C18 enh(c) Update keyword list for C11/C18 Feb 15, 2021
@il3ven
Copy link
Contributor

il3ven commented Feb 21, 2021

These keyword just need to be added in c.js? I was confirming before opening a PR.

@joshgoebel
Copy link
Member Author

Well really someone with a larger knowledge of C could really help here. Hopefully a PR here will do more than just replace KEYWORDS#keyword. There are related connections also to:

  • enh(cpp) Highlight all function dispatches #3005 (though eventually I'll get to this).
    • More important that we just get a correct list of built_in (ie, removing any cpp ones) for starters...
  • Even the above keywords need to be split between keyword and type
  • Review the rest of the syntax (for wrong modes like class and decltype, etc)

So that would be my hope here.

@joshgoebel
Copy link
Member Author

@klmr Does modern C have namespaces?

@joshgoebel
Copy link
Member Author

There is also begin: '\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array)\\s*<', which I dunno if it applies to C as well as C++ or not.

@klmr
Copy link
Contributor

klmr commented Feb 21, 2021

No namespaces, no.

And that begin rule is pure C++, not C.

@joshgoebel
Copy link
Member Author

What are _Bool and _Imaginary? Should we flag them as types?

@klmr
Copy link
Contributor

klmr commented Mar 26, 2021

They’re types, yes, but they’re also keywords (unlike e.g. bool, which in C is an alias for _Bool, but only if the stdbool.h header is included — otherwise it’s just any old identifier). https://en.cppreference.com/w/c/keyword is a good reference.

(Apologies for the lack of activity, I’m still snowed under with two other projects that unfortunately take priority and take up all my nominal “free time”.)

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 good first issue Should be easier for first time contributors help welcome Could use help from community language
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants