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

[lex.phases] Some unused links are useful #4874

Open
xmh0511 opened this issue Sep 7, 2021 · 0 comments
Open

[lex.phases] Some unused links are useful #4874

xmh0511 opened this issue Sep 7, 2021 · 0 comments

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Sep 7, 2021

[lex.phases]/1.3

The source file is decomposed into preprocessing tokens ([lex.pptoken]) and sequences of whitespace characters (including comments). A source file shall not end in a partial preprocessing token or in a partial comment. Each comment is replaced by one space character. New-line characters are retained. Whether each nonempty sequence of whitespace characters other than new-line is retained or replaced by one space character is unspecified. The process of dividing a source file's characters into preprocessing tokens is context-dependent.

After this phase, the sequence of the tokens in a source file should be in compliance with that specified by preprocessing-file that is defined in [cpp.pre], it is unused in the current draft but it is useful to interpret what is a valid sequence of preprocessing tokens in a source file. For instance

// a.h

// b.cpp
#include "a.h"
module ;
export module X;

b.cpp is an invalid source file after translation phase 3 even though a.h is empty. A valid processing file is either group<opt> or module-file but not both.

[lex.phases]/1.7

Whitespace characters separating tokens are no longer significant. Each preprocessing token is converted into a token ([lex.token]). The resulting tokens are syntactically and semantically analyzed and translated as a translation unit.

translation-unit is defined in [basic.link] and is unused in the current draft. However, it is useful to interpret what the grammar or resulting tokens should be in a valid translation unit, translation-unit specifies that and is useful here.

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

1 participant