|
39 | 39 | \newenvironment{addedblock}{\color{addclr}}{\color{black}}
|
40 | 40 | \newenvironment{removedblock}{\color{remclr}}{\color{black}}
|
41 | 41 |
|
42 |
| -%%-------------------------------------------------- |
| 42 | +%%------------------------------------------------------------- |
43 | 43 | %% Grammar extraction.
|
44 |
| -%%-------------------------------------------------- |
45 |
| -\def\gramSec[#1]#2{} |
46 |
| - |
| 44 | +%% Assumes that the output file \gramout is managed externally. |
| 45 | +%%------------------------------------------------------------- |
47 | 46 | \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 |
| -} |
| 47 | +\newcommand{\gramWrite}[1]{\protected@write\gramout{}{#1}} |
| 48 | +\newcommand{\meaningbody}[1]{\expandafter\strip@prefix\meaning#1} |
54 | 49 | \makeatother
|
55 | 50 |
|
| 51 | +\newcommand{\gramSec}[2][]{\gramWrite{% |
| 52 | +\string\rSec1\string[\string#1\string]\string{\string#2\string}}} |
| 53 | + |
56 | 54 | %%--------------------------------------------------
|
57 | 55 | % Escaping for index entries. Replaces ! with "! throughout its argument.
|
58 | 56 | %%--------------------------------------------------
|
|
701 | 699 | \nonfrenchspacing
|
702 | 700 | }
|
703 | 701 |
|
704 |
| -\newenvironment{simplebnf} |
| 702 | +% "ncbnf" is the non-copied "base" versions of the bnf environment; |
| 703 | +% instances of the full "bnf" environment is copied to the grammar |
| 704 | +% extraction file. |
| 705 | +% (Similarly for "ncsimplebnf", though in fact we never extract any |
| 706 | +% hypothetical "simplebnf" environments.) |
| 707 | +\newenvironment{ncsimplebnf} |
705 | 708 | {
|
706 | 709 | \begin{bnfbase}
|
707 | 710 | \BnfNontermshape
|
|
712 | 715 | \end{bnfbase}
|
713 | 716 | }
|
714 | 717 |
|
715 |
| -\newenvironment{bnf} |
| 718 | +\newenvironment{ncbnf} |
716 | 719 | {
|
717 | 720 | \begin{bnfbase}
|
718 | 721 | \begin{bnflist}
|
|
724 | 727 | \end{bnfbase}
|
725 | 728 | }
|
726 | 729 |
|
| 730 | +% The regex grammar is never copied. |
727 | 731 | \newenvironment{ncrebnf}
|
728 | 732 | {
|
729 | 733 | \begin{bnfbase}
|
|
737 | 741 | \end{bnfbase}
|
738 | 742 | }
|
739 | 743 |
|
740 |
| -% non-copied versions of bnf environments |
741 |
| -\let\ncsimplebnf\simplebnf |
742 |
| -\let\endncsimplebnf\endsimplebnf |
743 |
| -\let\ncbnf\bnf |
744 |
| -\let\endncbnf\endbnf |
| 744 | +\NewEnviron{bnf}{\begin{ncbnf}% |
| 745 | +\BODY% |
| 746 | +\gramWrite{\string\begin{ncbnf}\meaningbody\BODY\string\end{ncbnf}}% |
| 747 | +\end{ncbnf}}{} |
745 | 748 |
|
746 | 749 | %%--------------------------------------------------
|
747 | 750 | %% Environment for imported graphics
|
|
0 commit comments