|
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 | +\newenvironment{ncsimplebnf} |
705 | 703 | {
|
706 | 704 | \begin{bnfbase}
|
707 | 705 | \BnfNontermshape
|
|
712 | 710 | \end{bnfbase}
|
713 | 711 | }
|
714 | 712 |
|
715 |
| -\newenvironment{bnf} |
| 713 | +\newenvironment{ncbnf} |
716 | 714 | {
|
717 | 715 | \begin{bnfbase}
|
718 | 716 | \begin{bnflist}
|
|
724 | 722 | \end{bnfbase}
|
725 | 723 | }
|
726 | 724 |
|
| 725 | +% "nc" are the non-copied versions of bnf environments; the non-"nc" |
| 726 | +% versions are copied to the grammar extraction file. |
| 727 | +\NewEnviron{bnf}{\begin{ncbnf}% |
| 728 | +\BODY% |
| 729 | +\gramWrite{\string\begin{ncbnf}\meaningbody\BODY\string\end{ncbnf}}% |
| 730 | +\end{ncbnf}}{} |
| 731 | +
|
| 732 | +\NewEnviron{simplebnf}{\begin{ncsimplebnf}% |
| 733 | +\BODY% |
| 734 | +\gramwrite{\string\begin{ncsimplebnf}\meaningbody\BODY\string\end{ncsimplebnf}}% |
| 735 | +\end{ncsimplebnf}}{} |
| 736 | +
|
| 737 | +% The regex grammar is never copied. |
727 | 738 | \newenvironment{ncrebnf}
|
728 | 739 | {
|
729 | 740 | \begin{bnfbase}
|
|
737 | 748 | \end{bnfbase}
|
738 | 749 | }
|
739 | 750 |
|
740 |
| -% non-copied versions of bnf environments |
741 |
| -\let\ncsimplebnf\simplebnf |
742 |
| -\let\endncsimplebnf\endsimplebnf |
743 |
| -\let\ncbnf\bnf |
744 |
| -\let\endncbnf\endbnf |
745 |
| -
|
746 | 751 | %%--------------------------------------------------
|
747 | 752 | %% Environment for imported graphics
|
748 | 753 | %%--------------------------------------------------
|
|
0 commit comments