Skip to content

[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

Closed

Conversation

micahhainline
Copy link

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.

…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.
@micahhainline micahhainline changed the title Tokens.def cleanup and documentation [Parse] Tokens.def cleanup and documentation Jan 6, 2017
@micahhainline
Copy link
Author

@swift-ci please smoke test

@CodaFi
Copy link
Contributor

CodaFi commented Jan 6, 2017

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
Copy link
Collaborator

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.
Copy link
Collaborator

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.
Copy link
Collaborator

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)
Copy link
Collaborator

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?

@slavapestov
Copy link
Contributor

@DougGregor or @jckarter can you take a look?

@CodaFi
Copy link
Contributor

CodaFi commented Jun 1, 2017

These changes were merged into master on #10034

Thank you for your contribution @micahhainline. I apologize for not getting this reviewed sooner.

@CodaFi CodaFi closed this Jun 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants