-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Parse] Tokens.def cleanup and documentation #6618
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
Conversation
…age. Added a level of structure to the macro definitions to allow Swift keywords to be cleanly accessed separately from SIL and Swift keywords together. Documented structure and usage.
Used guarantees about undefining macros after import and new SWIFT_KEYWORD abstraction to simplify usage of the Token.def imports.
@swift-ci please smoke test |
LGTM. Thanks! @swift-ci please smoke test. |
/// | ||
/// To use, simply define one or more of the macro functions listed below and | ||
/// then import this file. The macro functions follow a hierarchical pattern, | ||
/// and defining a higher-level macro will expend (by default) all the patterns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/expend/expand/
#ifndef POUND_OBJECT_LITERAL | ||
#define POUND_OBJECT_LITERAL(kw, desc, proto) POUND_KEYWORD(kw) | ||
#endif | ||
|
||
/// POUND_OLD_OBJECT_LITERAL(kw, new_kw, old_arg, new_arg) | ||
/// Every keyword in the #foo namespace representing an object literal. | ||
/// Every keyword in the # namespace representing an old-form object literal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good addition, but perhaps it'd be better to explicitly say it's obsolete; it's not one of two valid ways of spelling an object literal, it's just here for migrator purposes.
#ifndef POUND_KEYWORD | ||
#define POUND_KEYWORD(kw) | ||
#endif | ||
|
||
/// POUND_OBJECT_LITERAL(kw, desc, proto) | ||
/// Every keyword in the #foo namespace representing an object literal. | ||
/// Every keyword in the # namespace representing a new-form object literal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following up on the comment below, I'd say that this is the syntax for an object literal. "New-form" is not a term used elsewhere to refer to the current syntax, and it implies that there is another form in the language, which there isn't.
/// Expands for every Swift keyword used in a pattern, which is currently | ||
/// limited to '_' | ||
#ifndef PAT_KEYWORD | ||
#define PAT_KEYWORD(kw) SWIFT_KEYWORD(kw) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question about the taxonomy here: isn't every pattern keyword an expression keyword, and every expression keyword a statement keyword?
@DougGregor or @jckarter can you take a look? |
These changes were merged into master on #10034 Thank you for your contribution @micahhainline. I apologize for not getting this reviewed sooner. |
This request cleans up the internal structure of Tokens.def, introduces some minor abstraction layers for ease of use and consistency, and documents usage. It also updates usage for consistency.
This was discussed briefly but with only positive feedback on the swift-dev mailing list.