blob: 4347a1f73cea59f2acb0c19a7eb2cea7885095df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
%%
%% This is file `lwarp-simplebnf.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% lwarp.dtx (with options: `simplebnf')
%% This is a generated file.
%% Copyright 2016-2020 Brian Dunn
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
\LWR@ProvidesPackagePass{simplebnf}[2020/09/01]
\ExplSyntaxOn
\RenewDocumentEnvironment { bnfgrammar } { +b }
{
%% \l__input_seq is a list of term definitions.
\regex_split:nnN { ;; } { #1 } \l__input_seq
\begin{center}
\begin{lateximage}[#1]% lwarp
\tl_set:Nn \l__table_tl
{
\begin{tabular}{lcll}
}
\bool_set_true:N \l_tmp_first_term % Is this the first term in this grammar?
\seq_map_inline:Nn \l__input_seq
{
%% \l__term_seq - (term, rhses)...
%% \l__term_tl - term
%% \l__keypairs_tl - rhses
\regex_split:nnN { ::= } { ##1 } \l__term_seq
\seq_pop_left:NN \l__term_seq \l__term_tl
\seq_pop_left:NN \l__term_seq \l__keypairs_tl
\regex_replace_once:nnN { ^\s+ } {} \l__term_tl
\bool_if:NTF \l_tmp_first_term
{
\bool_set_false:N \l_tmp_first_term
}
{
\tl_put_right:Nn \l__table_tl { \\ }
}
\tl_put_right:Nx \l__table_tl
{
\bnfexpr { \l__term_tl } & \g__simplebnf_defeq_tl &
}
%% \l__keypairs_seq - (rhs:annot | rhs)...
\seq_set_split:NnV \l__keypairs_seq { | } \l__keypairs_tl
\bool_set_true:N \l__first_rhs
\seq_map_function:NN \l__keypairs_seq \simplebnf_typeset_rhs:n
}
\tl_put_right:Nn \l__table_tl { \end{tabular} }
\tl_use:N \l__table_tl
\end{lateximage}% lwarp
\end{center}
}
{ }
\ExplSyntaxOff
\endinput
%%
%% End of file `lwarp-simplebnf.sty'.
|