-
Notifications
You must be signed in to change notification settings - Fork 812
alx-0014 - Refactor syntax of preprocessing directives #8270
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
Open
alejandro-colomar
wants to merge
7
commits into
cplusplus:main
Choose a base branch
from
alejandro-colomar:alx-0014
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+137
−102
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8a7862f
(alx-0014r6-A) Refactor syntax of include directives
alejandro-colomar 90e5fd4
(alx-0014r6-B) Refactor syntax of embed directives
alejandro-colomar cf3a68a
(alx-0014r6-C) Refactor syntax of macros
alejandro-colomar acbd537
(alx-0014r6-D) Refactor syntax of conditional directives
alejandro-colomar ebc741a
(alx-0014r6-F) Refactor syntax of diagnostic directives
alejandro-colomar 8441d23
(alx-0014r6-G) Refactor syntax of pragma directives
alejandro-colomar 3a31df2
(alx-0014r6-H) Refactor syntax of null directives
alejandro-colomar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 gets us a "hanging paragraph" in ISO parlance (text directly in a subsection that also has further sub-subsections).
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.
I based the diff on related existing code. There's for example a recent commit that did the same thing, I believe:
commit 2c473cc8744fc5b2077349add2283826061ce881 Author: Jens Maurer <Jens.Maurer@gmx.net> Date: 2025-11-09 20:46:24 +0100 P3868R1 Allow #line before module declarations Fixes NB US 55-102 (C++26 CD). Editorial note: * Retained position of #line alternative within control-line. diff --git a/source/preprocessor.tex b/source/preprocessor.tex index 487c0360..e449e830 100644 --- a/source/preprocessor.tex +++ b/source/preprocessor.tex @@ -16,11 +16,11 @@ module-file \end{bnf} \begin{bnf} \nontermdef{module-file}\br - \opt{pp-global-module-fragment} pp-module \opt{group} \opt{pp-private-module-fragment} + \opt{line-directives} \opt{pp-global-module-fragment} pp-module \opt{group} \opt{pp-private-module-fragment} \end{bnf} \begin{bnf} \nontermdef{pp-global-module-fragment}\br \keyword{module} \terminal{;} new-line \opt{group} @@ -53,17 +53,22 @@ \terminal{\# define } identifier replacement-list new-line\br \terminal{\# define } identifier lparen \opt{identifier-list} \terminal{)} replacement-list new-line\br \terminal{\# define } identifier lparen \terminal{... )} replacement-list new-line\br \terminal{\# define } identifier lparen identifier-list \terminal{, ... )} replacement-list new-line\br \terminal{\# undef \ } identifier new-line\br - \terminal{\# line \ \ } pp-tokens new-line\br + line-directive\br \terminal{\# error \ } \opt{pp-tokens} new-line\br \terminal{\# warning} \opt{pp-tokens} new-line\br \terminal{\# pragma } \opt{pp-tokens} new-line\br \terminal{\# }new-line \end{bnf} +\begin{bnf} +\nontermdef{line-directives}\br + line-directive \opt{line-directives} +\end{bnf} + \begin{bnf} \nontermdef{if-section}\br if-group \opt{elif-groups} \opt{else-group} endif-line \end{bnf} @@ -2060,10 +2065,15 @@ a macro name. \rSec1[cpp.line]{Line control}% \indextext{preprocessing directive!line control}% \indextext{\idxcode{\#line}|see{preprocessing directive, line control}} +\begin{bnf} +\nontermdef{line-directive}\br + \terminal{\# line} pp-tokens new-line +\end{bnf} + \pnum The \grammarterm{string-literal} of a \tcode{\#line} directive, if present, shall be a character string literal.Am I missing something?
Uh oh!
There was an error while loading. Please reload this page.
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.
Oh, now I see. Embed has subsections, while the others don't. What do you suggest? I don't know what should be done here. Is there any part of the standard that I could imitate for this?
Maybe put it in General (cpp.embed.gen)?