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

import-keyword, module-keyword, and export-keyword are not preprocessing tokens #5301

Open
xmh0511 opened this issue Feb 17, 2022 · 3 comments

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Feb 17, 2022

According to clause [lex.phases], phase 3 occurs previous to phase 4, In other words, the determination of preprocessing tokens occurs before the execution of preprocessing directives.

phase 3:

The source file is decomposed into preprocessing tokens ([lex.pptoken]) and sequences of whitespace characters (including comments).

phase 4:

Preprocessing directives are executed, macro invocations are expanded, and _­Pragma unary operator expressions are executed.

That is, the replacement of preprocessing tokens import to import-keyword, module to module-keyword, and export to export-keyword all occur within the duration of execution of preprocessing directives. As specified in [cpp.module], and [cpp.import], they are:

The module and export (if it exists) preprocessing tokens are replaced by the module-keyword and export-keyword preprocessing tokens respectively.

In all three forms of pp-import, the import and export (if it exists) preprocessing tokens are replaced by the import-keyword and export-keyword preprocessing tokens respectively.

The emphasized parts also confirm this point. We should admit that: import, module, and export are preprocessing tokens in phase 3. They also remain to be preprocessing tokens until the execution of the relevant preprocessing directives in phase 4. After these phases, these replaced x-keywords will be used as keywords in the subsequent phases.

@jensmaurer
Copy link
Member

I'm not seeing a problem.

export, import, module clearly are (lexical) preprocessing-tokens (identifier in [lex.pptoken])
and the x-keyword things are also preprocessing tokens per [lex.pptoken]; they are mentioned explicitly in the grammar for preprocessing-token.

@jensmaurer
Copy link
Member

Or are you concerned that [lex.key] p1 only treats things in table 5 as keywords, but not the x-keyword things mentioned in the keyword grammar?

@xmh0511
Copy link
Contributor Author

xmh0511 commented Feb 18, 2022

You're correct on that the identifiers cover the original "import", "module", and "export" things. [lex.key] p1 should also cover the resulted things from the former.

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

No branches or pull requests

2 participants