summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/lwarp/lwarp-simplebnf.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/lwarp/lwarp-simplebnf.sty')
-rw-r--r--Master/texmf-dist/tex/latex/lwarp/lwarp-simplebnf.sty71
1 files changed, 71 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/lwarp/lwarp-simplebnf.sty b/Master/texmf-dist/tex/latex/lwarp/lwarp-simplebnf.sty
new file mode 100644
index 00000000000..4347a1f73ce
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/lwarp/lwarp-simplebnf.sty
@@ -0,0 +1,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'.