From ed2683a463da76cf8c6f7b3d100541a793bd8789 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Wed, 1 Oct 2025 13:51:19 +0200 Subject: [PATCH 1/8] (alx-0014r6-A) Refactor syntax of include directives Signed-off-by: Alejandro Colomar --- source/preprocessor.tex | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/preprocessor.tex b/source/preprocessor.tex index 38c595333c..09ee72b8bb 100644 --- a/source/preprocessor.tex +++ b/source/preprocessor.tex @@ -47,7 +47,7 @@ \begin{bnf} \nontermdef{control-line}\br - \terminal{\# include} pp-tokens new-line\br + include-directive\br pp-import\br \terminal{\# embed \ } pp-tokens new-line\br \terminal{\# define } identifier replacement-list new-line\br @@ -696,6 +696,11 @@ \indextext{inclusion!source file|see{preprocessing directive, source-file inclusion}}% \indextext{\idxcode{\#include}}% +\begin{bnf} +\nontermdef{include-directive}\br + \terminal{\# include} pp-tokens new-line\br +\end{bnf} + \pnum A \defnadj{header}{search} for a sequence of characters searches a sequence of places for a header From c6ce3de1cbb96900f66db3a9016af853d3bfe558 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Wed, 1 Oct 2025 14:05:23 +0200 Subject: [PATCH 2/8] (alx-0014r6-B) Refactor syntax of embed directives Signed-off-by: Alejandro Colomar --- source/preprocessor.tex | 89 ++++++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 42 deletions(-) diff --git a/source/preprocessor.tex b/source/preprocessor.tex index 09ee72b8bb..df29cb97a7 100644 --- a/source/preprocessor.tex +++ b/source/preprocessor.tex @@ -49,7 +49,7 @@ \nontermdef{control-line}\br include-directive\br pp-import\br - \terminal{\# embed \ } pp-tokens new-line\br + embed-directive\br \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 @@ -127,47 +127,6 @@ preprocessing-token \opt{pp-tokens} \end{bnf} -\begin{bnf} -\nontermdef{embed-parameter-seq}\br - embed-parameter \opt{embed-parameter-seq} -\end{bnf} - -\begin{bnf} -\nontermdef{embed-parameter}\br - embed-standard-parameter\br - embed-prefixed-parameter -\end{bnf} - -\begin{bnf} -\nontermdef{embed-standard-parameter}\br - \terminal{limit} \terminal{(} pp-balanced-token-seq \terminal{)}\br - \terminal{prefix} \terminal{(} \opt{pp-balanced-token-seq} \terminal{)}\br - \terminal{suffix} \terminal{(} \opt{pp-balanced-token-seq} \terminal{)}\br - \terminal{if_empty} \terminal{(} \opt{pp-balanced-token-seq} \terminal{)} -\end{bnf} - -\begin{bnf} -\nontermdef{embed-prefixed-parameter}\br - identifier :: identifier\br - identifier :: identifier \terminal{(} \opt{pp-balanced-token-seq} \terminal{)} -\end{bnf} - -\begin{bnf} -\nontermdef{pp-balanced-token-seq}\br - pp-balanced-token \opt{pp-balanced-token-seq} -\end{bnf} - -\begin{bnf} -\nontermdef{pp-balanced-token}\br - \terminal{(} \opt{pp-balanced-token-seq} \terminal{)}\br - \terminal{[} \opt{pp-balanced-token-seq} \terminal{]}\br - \terminal{\{} \opt{pp-balanced-token-seq} \terminal{\}}\br - \textnormal{any} pp-token \textnormal{except:}\br - \bnfindent\textnormal{parenthesis (\unicode{0028}{left parenthesis} and \unicode{0029}{right parenthesis}),}\br - \bnfindent\textnormal{bracket (\unicode{005b}{left square bracket} and \unicode{005d}{right square bracket}), or}\br - \bnfindent\textnormal{brace (\unicode{007b}{left curly bracket} and \unicode{007d}{right curly bracket}).} -\end{bnf} - \begin{bnf} \nontermdef{new-line}\br \descr{the new-line character} @@ -850,6 +809,52 @@ \indextext{preprocessing directive!embed a resource} \indextext{\idxcode{\#embed}}% +\begin{bnf} +\nontermdef{embed-directive}\br + \terminal{\# embed \ } pp-tokens new-line\br +\end{bnf} + +\begin{bnf} +\nontermdef{embed-parameter-seq}\br + embed-parameter \opt{embed-parameter-seq} +\end{bnf} + +\begin{bnf} +\nontermdef{embed-parameter}\br + embed-standard-parameter\br + embed-prefixed-parameter +\end{bnf} + +\begin{bnf} +\nontermdef{embed-standard-parameter}\br + \terminal{limit} \terminal{(} pp-balanced-token-seq \terminal{)}\br + \terminal{prefix} \terminal{(} \opt{pp-balanced-token-seq} \terminal{)}\br + \terminal{suffix} \terminal{(} \opt{pp-balanced-token-seq} \terminal{)}\br + \terminal{if_empty} \terminal{(} \opt{pp-balanced-token-seq} \terminal{)} +\end{bnf} + +\begin{bnf} +\nontermdef{embed-prefixed-parameter}\br + identifier :: identifier\br + identifier :: identifier \terminal{(} \opt{pp-balanced-token-seq} \terminal{)} +\end{bnf} + +\begin{bnf} +\nontermdef{pp-balanced-token-seq}\br + pp-balanced-token \opt{pp-balanced-token-seq} +\end{bnf} + +\begin{bnf} +\nontermdef{pp-balanced-token}\br + \terminal{(} \opt{pp-balanced-token-seq} \terminal{)}\br + \terminal{[} \opt{pp-balanced-token-seq} \terminal{]}\br + \terminal{\{} \opt{pp-balanced-token-seq} \terminal{\}}\br + \textnormal{any} pp-token \textnormal{except:}\br + \bnfindent\textnormal{parenthesis (\unicode{0028}{left parenthesis} and \unicode{0029}{right parenthesis}),}\br + \bnfindent\textnormal{bracket (\unicode{005b}{left square bracket} and \unicode{005d}{right square bracket}), or}\br + \bnfindent\textnormal{brace (\unicode{007b}{left curly bracket} and \unicode{007d}{right curly bracket}).} +\end{bnf} + \rSec2[cpp.embed.gen]{General} \pnum From 600fa4c20321193f7e5b206ef5e80fbed9a4de35 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Wed, 1 Oct 2025 14:11:31 +0200 Subject: [PATCH 3/8] (alx-0014r6-C) Refactor syntax of macros Signed-off-by: Alejandro Colomar --- source/preprocessor.tex | 52 ++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/source/preprocessor.tex b/source/preprocessor.tex index df29cb97a7..7c047c91af 100644 --- a/source/preprocessor.tex +++ b/source/preprocessor.tex @@ -50,11 +50,8 @@ include-directive\br pp-import\br embed-directive\br - \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 + define-directive\br + undef-directive\br \terminal{\# line \ \ } pp-tokens new-line\br \terminal{\# error \ } \opt{pp-tokens} new-line\br \terminal{\# warning} \opt{pp-tokens} new-line\br @@ -106,22 +103,6 @@ pp-tokens new-line \end{bnf} -\begin{bnf} -\nontermdef{lparen}\br - \descr{a \terminal{(} character not immediately preceded by whitespace} -\end{bnf} - -\begin{bnf} -\nontermdef{identifier-list}\br - identifier\br - identifier-list \terminal{,} identifier -\end{bnf} - -\begin{bnf} -\nontermdef{replacement-list}\br - \opt{pp-tokens} -\end{bnf} - \begin{bnf} \nontermdef{pp-tokens}\br preprocessing-token \opt{pp-tokens} @@ -1455,6 +1436,35 @@ \indextext{replacement!macro|see{macro, replacement}}% \indextext{preprocessing directive!macro replacement|see{macro, replacement}} +\begin{bnf} +\nontermdef{define-directive}\br + \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 +\end{bnf} + +\begin{bnf} +\nontermdef{undef-directive}\br + \terminal{\# undef \ } identifier new-line\br +\end{bnf} + +\begin{bnf} +\nontermdef{lparen}\br + \descr{a \terminal{(} character not immediately preceded by whitespace} +\end{bnf} + +\begin{bnf} +\nontermdef{identifier-list}\br + identifier\br + identifier-list \terminal{,} identifier +\end{bnf} + +\begin{bnf} +\nontermdef{replacement-list}\br + \opt{pp-tokens} +\end{bnf} + \pnum \indextext{macro!replacement list}% Two replacement lists are identical if and only if From 22509106551a96ef1700235ae6501cb4c156fea9 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Wed, 1 Oct 2025 14:12:14 +0200 Subject: [PATCH 4/8] (alx-0014r6-D) Refactor syntax of conditional directives Signed-off-by: Alejandro Colomar --- source/preprocessor.tex | 68 ++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/source/preprocessor.tex b/source/preprocessor.tex index 7c047c91af..5c3465306d 100644 --- a/source/preprocessor.tex +++ b/source/preprocessor.tex @@ -59,40 +59,6 @@ \terminal{\# }new-line \end{bnf} -\begin{bnf} -\nontermdef{if-section}\br - if-group \opt{elif-groups} \opt{else-group} endif-line -\end{bnf} - -\begin{bnf} -\nontermdef{if-group}\br - \terminal{\# if \ \ \ \ } constant-expression new-line \opt{group}\br - \terminal{\# ifdef \ } identifier new-line \opt{group}\br - \terminal{\# ifndef } identifier new-line \opt{group} -\end{bnf} - -\begin{bnf} -\nontermdef{elif-groups}\br - elif-group \opt{elif-groups} -\end{bnf} - -\begin{bnf} -\nontermdef{elif-group}\br - \terminal{\# elif \ \ \ } constant-expression new-line \opt{group}\br - \terminal{\# elifdef } identifier new-line \opt{group}\br - \terminal{\# elifndef} identifier new-line \opt{group} -\end{bnf} - -\begin{bnf} -\nontermdef{else-group}\br - \terminal{\# else \ \ } new-line \opt{group} -\end{bnf} - -\begin{bnf} -\nontermdef{endif-line}\br - \terminal{\# endif \ } new-line -\end{bnf} - \begin{bnf} \nontermdef{text-line}\br \opt{pp-tokens} new-line @@ -275,6 +241,40 @@ \indextext{preprocessing directive!conditional inclusion}% \indextext{inclusion!conditional|see{preprocessing directive, conditional inclusion}} +\begin{bnf} +\nontermdef{if-section}\br + if-group \opt{elif-groups} \opt{else-group} endif-line +\end{bnf} + +\begin{bnf} +\nontermdef{if-group}\br + \terminal{\# if \ \ \ \ } constant-expression new-line \opt{group}\br + \terminal{\# ifdef \ } identifier new-line \opt{group}\br + \terminal{\# ifndef } identifier new-line \opt{group} +\end{bnf} + +\begin{bnf} +\nontermdef{elif-groups}\br + elif-group \opt{elif-groups} +\end{bnf} + +\begin{bnf} +\nontermdef{elif-group}\br + \terminal{\# elif \ \ \ } constant-expression new-line \opt{group}\br + \terminal{\# elifdef } identifier new-line \opt{group}\br + \terminal{\# elifndef} identifier new-line \opt{group} +\end{bnf} + +\begin{bnf} +\nontermdef{else-group}\br + \terminal{\# else \ \ } new-line \opt{group} +\end{bnf} + +\begin{bnf} +\nontermdef{endif-line}\br + \terminal{\# endif \ } new-line +\end{bnf} + \indextext{\idxcode{defined}}% \begin{bnf} \nontermdef{defined-macro-expression}\br From 61fd02e74ba0be66cc365826416c8511a9e410a7 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Wed, 1 Oct 2025 14:15:54 +0200 Subject: [PATCH 5/8] (alx-0014r6-E) Refactor syntax of line directives Signed-off-by: Alejandro Colomar --- source/preprocessor.tex | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/preprocessor.tex b/source/preprocessor.tex index 5c3465306d..a8883138d6 100644 --- a/source/preprocessor.tex +++ b/source/preprocessor.tex @@ -52,7 +52,7 @@ embed-directive\br define-directive\br undef-directive\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 @@ -2090,6 +2090,11 @@ \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\br +\end{bnf} + \pnum The \grammarterm{string-literal} of a \tcode{\#line} From fb1efad72a0375a36b9cbc0049dcf9837df7d69b Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Wed, 1 Oct 2025 14:20:36 +0200 Subject: [PATCH 6/8] (alx-0014r6-F) Refactor syntax of diagnostic directives Signed-off-by: Alejandro Colomar --- source/preprocessor.tex | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/preprocessor.tex b/source/preprocessor.tex index a8883138d6..9d77ba46ed 100644 --- a/source/preprocessor.tex +++ b/source/preprocessor.tex @@ -53,8 +53,7 @@ define-directive\br undef-directive\br line-directive\br - \terminal{\# error \ } \opt{pp-tokens} new-line\br - \terminal{\# warning} \opt{pp-tokens} new-line\br + diagnostic-directive\br \terminal{\# pragma } \opt{pp-tokens} new-line\br \terminal{\# }new-line \end{bnf} @@ -2155,6 +2154,12 @@ \indextext{preprocessing directive!warning}% \indextext{\idxcode{\#error}|see{preprocessing directive, error}} +\begin{bnf} +\nontermdef{diagnostic-directive}\br + \terminal{\# error \ } \opt{pp-tokens} new-line\br + \terminal{\# warning} \opt{pp-tokens} new-line\br +\end{bnf} + \pnum A preprocessing directive of the form \begin{ncsimplebnf} From 2f2dee4215925319a260bbd890c0805442843d3b Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Wed, 1 Oct 2025 14:22:06 +0200 Subject: [PATCH 7/8] (alx-0014r6-G) Refactor syntax of pragma directives Signed-off-by: Alejandro Colomar --- source/preprocessor.tex | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/preprocessor.tex b/source/preprocessor.tex index 9d77ba46ed..2bb1ad9b9f 100644 --- a/source/preprocessor.tex +++ b/source/preprocessor.tex @@ -54,7 +54,7 @@ undef-directive\br line-directive\br diagnostic-directive\br - \terminal{\# pragma } \opt{pp-tokens} new-line\br + pragma-directive\br \terminal{\# }new-line \end{bnf} @@ -2182,6 +2182,11 @@ \indextext{preprocessing directive!pragma}% \indextext{\idxcode{\#pragma}|see{preprocessing directive, pragma}} +\begin{bnf} +\nontermdef{pragma-directive}\br + \terminal{\# pragma } \opt{pp-tokens} new-line\br +\end{bnf} + \pnum A preprocessing directive of the form \begin{ncsimplebnf} From 9b4bf160c9552ed64c6a4d32944f80e793884af0 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Wed, 1 Oct 2025 14:23:55 +0200 Subject: [PATCH 8/8] (alx-0014r6-H) Refactor syntax of null directives Signed-off-by: Alejandro Colomar --- source/preprocessor.tex | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/preprocessor.tex b/source/preprocessor.tex index 2bb1ad9b9f..bd0bd6af1c 100644 --- a/source/preprocessor.tex +++ b/source/preprocessor.tex @@ -55,7 +55,7 @@ line-directive\br diagnostic-directive\br pragma-directive\br - \terminal{\# }new-line + null-directive \end{bnf} \begin{bnf} @@ -2201,6 +2201,11 @@ \rSec1[cpp.null]{Null directive}% \indextext{preprocessing directive!null} +\begin{bnf} +\nontermdef{null-directive}\br + \terminal{\# }new-line +\end{bnf} + \pnum A preprocessing directive of the form \begin{ncsimplebnf}