|
39 | 39 | \newenvironment{addedblock}{\color{addclr}}{\color{black}} |
40 | 40 | \newenvironment{removedblock}{\color{remclr}}{\color{black}} |
41 | 41 |
|
42 | | -%% %%-------------------------------------------------- |
43 | | -%% %% Grammar extraction. |
44 | | -%% %%-------------------------------------------------- |
45 | | -%% \def\gramSec[#1]#2{} |
| 42 | +%%------------------------------------------------------------- |
| 43 | +%% Grammar extraction. |
| 44 | +%% Assumes that the output file \gramout is managed externally. |
| 45 | +%%------------------------------------------------------------- |
| 46 | +\makeatletter |
| 47 | +\newcommand{\gramWrite}[1]{\protected@write\gramout{}{#1}} |
| 48 | +\newcommand{\meaningbody}[1]{\expandafter\strip@prefix\meaning#1} |
| 49 | +\makeatother |
46 | 50 |
|
47 | | -%% \makeatletter |
48 | | -%% \newcommand{\FlushAndPrintGrammar}{% |
49 | | -%% \immediate\closeout\XTR@out% |
50 | | -%% \immediate\openout\XTR@out=std-gram-dummy.tmp% |
51 | | -%% \def\gramSec[##1]##2{\rSec1[##1]{##2}}% |
52 | | -%% \input{std-gram.ext}% |
53 | | -%% } |
54 | | -%% \makeatother |
| 51 | +\newcommand{\gramSec}[2][]{\gramWrite{% |
| 52 | +\string\rSec1\string[\string#1\string]\string{\string#2\string}}} |
55 | 53 |
|
56 | 54 | %%-------------------------------------------------- |
57 | 55 | % Escaping for index entries. Replaces ! with "! throughout its argument. |
|
237 | 235 | %%-------------------------------------------------- |
238 | 236 | \newcommand{\CodeStyle}{\ttfamily} |
239 | 237 | \newcommand{\CodeStylex}[1]{\texttt{\protect\frenchspacing #1}} |
| 238 | +\makeatletter |
| 239 | +% Append `\@` to restore proper sentence spacing in text mode. This insertion |
| 240 | +% happens only during normal typesetting; it is suppressed for .idx generation. |
| 241 | +\newcommand{\CodeStylexGuarded}[1]{\CodeStylex{#1\ifmmode\else\ifx\protect\@typeset@protect\@\fi\fi}} |
| 242 | +\makeatother |
240 | 243 |
|
241 | 244 | \definecolor{grammar-gray}{gray}{0.2} |
242 | 245 |
|
243 | 246 | % General grammar style |
244 | 247 | \newcommand{\GrammarStylex}[1]{\textcolor{grammar-gray}{\textsf{\textit{#1}}}} |
245 | 248 |
|
246 | 249 | % Code and definitions embedded in text. |
247 | | -\newcommand{\tcode}[1]{\CodeStylex{#1}} |
| 250 | +\newcommand{\tcode}[1]{\CodeStylexGuarded{#1}} |
248 | 251 | \newcommand{\term}[1]{\textit{#1}} |
249 | 252 | \newcommand{\gterm}[1]{\GrammarStylex{#1}} |
250 | 253 | \newcommand{\fakegrammarterm}[1]{\gterm{#1}} |
|
294 | 297 | \newcommand{\CppXXIII}{\Cpp{} 2023} |
295 | 298 | \newcommand{\CppXXVI}{\Cpp{} 2026} |
296 | 299 | \newcommand{\IsoCUndated}{ISO/IEC 9899} |
297 | | -\newcommand{\IsoC}{\IsoCUndated{}:2018} |
| 300 | +\newcommand{\IsoC}{\IsoCUndated{}:2024} |
298 | 301 | \newcommand{\IsoFloatUndated}{ISO/IEC 60559} |
299 | 302 | \newcommand{\IsoPosixUndated}{ISO/IEC/IEEE 9945} |
300 | 303 | \newcommand{\IsoPosix}{\IsoPosixUndated{}:2009} |
|
365 | 368 | \newcommand{\required}{\Fundesc{Required behavior}} |
366 | 369 | \newcommand{\constraints}{\Fundesc{Constraints}} |
367 | 370 | \newcommand{\mandates}{\Fundesc{Mandates}} |
| 371 | +\newcommand{\constantwhen}{\Fundesc{Constant When}} |
368 | 372 | \newcommand{\expects}{\Fundesc{Preconditions}} |
369 | 373 | \newcommand{\hardexpects}{\Fundesc{Hardened preconditions}} |
370 | 374 | \newcommand{\effects}{\Fundesc{Effects}} |
|
464 | 468 | \newcommand{\unspecbool}{\UNSP{unspecified-bool-type}} |
465 | 469 | \newcommand{\seebelow}{\UNSP{see below}} % macro length: 0 |
466 | 470 | \newcommand{\seebelownc}{\UNSPnc{see below}} % macro length: 2 |
| 471 | +\newcommand{\seeabove}{\UNSP{see above}} % macro length: 0 |
| 472 | +\newcommand{\seeabovenc}{\UNSPnc{see above}} % macro length: 2 |
467 | 473 | \newcommand{\unspecuniqtype}{\UNSP{unspecified unique type}} |
468 | 474 | \newcommand{\unspecalloctype}{\UNSP{unspecified allocator type}} |
469 | 475 |
|
| 476 | +%% Convenience macro for double carets in expressions, |
| 477 | +%% particularly within \tcode. |
| 478 | +\newcommand{\reflexpr}[1]{\caret\caret#1} |
| 479 | + |
470 | 480 | %% Manual insertion of italic corrections, for aligning in the presence |
471 | 481 | %% of the above annotations. |
472 | 482 | \newlength{\itcorrwidth} |
|
587 | 597 | \lstset{escapechar=@, aboveskip=\parskip, belowskip=0pt, |
588 | 598 | midpenalty=500, endpenalty=-50, |
589 | 599 | emptylinepenalty=-250, semicolonpenalty=0,upquote=true}% |
590 | | -\renewcommand{\tcode}[1]{\textup{\CodeStylex{##1}}} |
| 600 | +\renewcommand{\tcode}[1]{\textup{\CodeStylexGuarded{##1}}} |
591 | 601 | \renewcommand{\term}[1]{\textit{##1}}% |
592 | 602 | \renewcommand{\grammarterm}[1]{\gterm{##1}}% |
593 | 603 | } |
|
645 | 655 | belowskip=0ex % leave this alone: it keeps these things out of the |
646 | 656 | % footnote area |
647 | 657 | }% |
648 | | - \renewcommand{\tcode}[1]{\textup{\CodeStylex{##1}}} |
| 658 | + \renewcommand{\tcode}[1]{\textup{\CodeStylexGuarded{##1}}} |
649 | 659 | } |
650 | 660 | { |
651 | 661 | } |
|
701 | 711 | \nonfrenchspacing |
702 | 712 | } |
703 | 713 |
|
704 | | -\newenvironment{simplebnf} |
| 714 | +% "ncbnf" is the non-copied "base" versions of the bnf environment; |
| 715 | +% instances of the full "bnf" environment is copied to the grammar |
| 716 | +% extraction file. |
| 717 | +% (Similarly for "ncsimplebnf", though in fact we never extract any |
| 718 | +% hypothetical "simplebnf" environments.) |
| 719 | +\newenvironment{ncsimplebnf} |
705 | 720 | { |
706 | 721 | \begin{bnfbase} |
707 | 722 | \BnfNontermshape |
|
712 | 727 | \end{bnfbase} |
713 | 728 | } |
714 | 729 |
|
715 | | -\newenvironment{bnf} |
| 730 | +\newenvironment{ncbnf} |
716 | 731 | { |
717 | 732 | \begin{bnfbase} |
718 | 733 | \begin{bnflist} |
|
724 | 739 | \end{bnfbase} |
725 | 740 | } |
726 | 741 |
|
| 742 | +% The regex grammar is never copied. |
727 | 743 | \newenvironment{ncrebnf} |
728 | 744 | { |
729 | 745 | \begin{bnfbase} |
|
737 | 753 | \end{bnfbase} |
738 | 754 | } |
739 | 755 |
|
740 | | -% non-copied versions of bnf environments |
741 | | -\let\ncsimplebnf\simplebnf |
742 | | -\let\endncsimplebnf\endsimplebnf |
743 | | -\let\ncbnf\bnf |
744 | | -\let\endncbnf\endbnf |
| 756 | +\NewEnviron{bnf}{\begin{ncbnf}% |
| 757 | +\BODY% |
| 758 | +\gramWrite{\string\begin{ncbnf}\meaningbody\BODY\string\end{ncbnf}}% |
| 759 | +\end{ncbnf}}{} |
745 | 760 |
|
746 | 761 | %%-------------------------------------------------- |
747 | 762 | %% Environment for imported graphics |
|
0 commit comments