texlive[64091] Master/texmf-dist: simplebnf (10aug22)

commits+karl at tug.org commits+karl at tug.org
Wed Aug 10 22:37:00 CEST 2022


Revision: 64091
          http://tug.org/svn/texlive?view=revision&revision=64091
Author:   karl
Date:     2022-08-10 22:37:00 +0200 (Wed, 10 Aug 2022)
Log Message:
-----------
simplebnf (10aug22)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/simplebnf/LICENSE
    trunk/Master/texmf-dist/doc/latex/simplebnf/simplebnf-doc.tex
    trunk/Master/texmf-dist/tex/latex/simplebnf/simplebnf.sty

Modified: trunk/Master/texmf-dist/doc/latex/simplebnf/LICENSE
===================================================================
--- trunk/Master/texmf-dist/doc/latex/simplebnf/LICENSE	2022-08-10 20:36:43 UTC (rev 64090)
+++ trunk/Master/texmf-dist/doc/latex/simplebnf/LICENSE	2022-08-10 20:37:00 UTC (rev 64091)
@@ -1,6 +1,6 @@
 The MIT License (MIT)
 
-Copyright © 2019-2020 Jay Lee <jaeho.lee at snu.ac.kr>
+Copyright © 2019-2022 Jay Lee <jaeho.lee at snu.ac.kr>
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the "Software"),

Modified: trunk/Master/texmf-dist/doc/latex/simplebnf/simplebnf-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/simplebnf/simplebnf-doc.tex	2022-08-10 20:36:43 UTC (rev 64090)
+++ trunk/Master/texmf-dist/doc/latex/simplebnf/simplebnf-doc.tex	2022-08-10 20:37:00 UTC (rev 64091)
@@ -32,10 +32,10 @@
 
 \title{%
   \textsf{simplebnf} --- A simple package to format Backus-Naur form%
-  \footnote{This file describes v0.3.0.}}
+  \footnote{This file describes v0.3.1.}}
 \author{Jay Lee\footnote{E-mail: %
   \href{mailto:jaeho.lee at snu.ac.kr}{\texttt{jaeho.lee at snu.ac.kr}}}}
-\date{2022/05/07}
+\date{2022/05/08}
 
 \begin{document}
 \maketitle
@@ -43,11 +43,26 @@
 This package provides a simple way to typeset grammars written in Backus-Naur form (BNF).
 
 \begin{presentcommand}
-  \cmd{bnfexpr} \cmd{bnfannot}
+  \cmd{SimpleBNFDefEq}
 \end{presentcommand}
-These commands are wrappers around \cmd{texttt} and \cmd{textit} respectively.
+This command is used to typeset the definition symbol separate a nonterminal from its productions. It defaults to \SimpleBNFDefEq. It can be redefined to customized output using \verb|RenewDocumentCommand|.
 
 \begin{presentcommand}
+  \cmd{SimpleBNFDefOr}
+\end{presentcommand}
+This command is used to typeset the separator symbol between productions. It defaults to \SimpleBNFDefOr. It can be redefined to customized output using \verb|RenewDocumentCommand|.
+
+\begin{presentcommand}
+  \cmd{bnfexpr}
+\end{presentcommand}
+This command is used when typesetting the BNF nonterminal and productions. It defaults to a wrappers around \cmd{texttt}. It can be redefined to customized output using \verb|RenewDocumentCommand|.
+
+\begin{presentcommand}
+ \cmd{bnfannot}
+\end{presentcommand}
+This command is used when typesetting the annotations on nonterminals and productions. It defaults to a wrappers around \cmd{textit}. It can be redefined to customized output using \verb|RenewDocumentCommand|.
+
+\begin{presentcommand}
   \env{bnfgrammar}{text}
 \end{presentcommand}
 can be used to typeset BNF grammars. The \textit{text} inside the environment should be formatted as:

Modified: trunk/Master/texmf-dist/tex/latex/simplebnf/simplebnf.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/simplebnf/simplebnf.sty	2022-08-10 20:36:43 UTC (rev 64090)
+++ trunk/Master/texmf-dist/tex/latex/simplebnf/simplebnf.sty	2022-08-10 20:37:00 UTC (rev 64091)
@@ -13,18 +13,16 @@
 \RequirePackage{mathtools}
 \ProvidesExplPackage
   {simplebnf}
-  {2022/05/07}
-  {0.3.0}
+  {2022/05/08}
+  {0.3.1}
   {A simple package to format Backus–Naur form}
 
 \cs_generate_variant:Nn \regex_split:nnNTF {nVNTF}
 \cs_generate_variant:Nn \regex_split:NnN {NVN}
 
-\tl_new:N \g__simplebnf_defeq_tl
-\tl_gset:Nn \g__simplebnf_defeq_tl { \ensuremath{\Coloneqq} }
+\NewDocumentCommand\SimpleBNFDefEq{}{\ensuremath{\Coloneqq}}
 
-\tl_new:N \g__simplebnf_defor_tl
-\tl_gset:Nn \g__simplebnf_defor_tl { \ensuremath{|} }
+\NewDocumentCommand\SimpleBNFDefOr{}{\ensuremath{|}}
 
 \seq_new:N \l__input_seq
 \seq_new:N \l__term_seq
@@ -48,7 +46,7 @@
       \bool_set_false:N \l__first_rhs
     }
     {
-      \tl_put_right:Nn \l__table_tl { \\ && \g__simplebnf_defor_tl & }
+      \tl_put_right:Nn \l__table_tl { \\ && \SimpleBNFDefOr & }
     }
 
   \tl_set:Nn \l_tmpa_tl { #1 }
@@ -58,23 +56,30 @@
     {
       \seq_pop_left:NNT \l_tmpa_seq \l_tmpa_tl
         {
-          \regex_replace_all:NnN \g_simplebnf_rhs_nb_r { \c{g__simplebnf_defor_tl} } \l_tmpa_tl
-          \tl_put_right:Nx \l__table_tl { \bnfexpr { \l_tmpa_tl } }
+          \regex_replace_all:NnN \g_simplebnf_rhs_nb_r { \c{SimpleBNFDefOr} } \l_tmpa_tl
+          % Expand only the local temporary variable.
+          \tl_put_right:No \l__table_tl
+             {
+               \exp_after:wN\bnfexpr\exp_after:wN{\l_tmpa_tl} &
+             }
         }
 
-      \tl_put_right:Nn \l__table_tl { & }
-
       \seq_pop_left:NNT \l_tmpa_seq \l_tmpb_tl
         {
-          \tl_set:Nx \l_tmpb_tl { \bnfannot { \l_tmpb_tl } }
-          \tl_put_right:NV \l__table_tl \l_tmpb_tl
+          \regex_replace_once:nnN { ^\s+ } {} \l_tmpb_tl
+          \tl_put_right:No \l__table_tl
+            {
+              \exp_after:wN\bnfannot\exp_after:wN{\l_tmpb_tl}
+            }
         }
     }
     {
-      \regex_replace_all:NnN \g_simplebnf_rhs_nb_r { \c{g__simplebnf_defor_tl} } \l_tmpa_tl
+      \regex_replace_all:NnN \g_simplebnf_rhs_nb_r { \c{SimpleBNFDefOr} } \l_tmpa_tl
 
-      \tl_put_right:Nx \l__table_tl { \bnfexpr { \l_tmpa_tl } }
-      \tl_put_right:Nn \l__table_tl { & }
+      \tl_put_right:No \l__table_tl
+         {
+           \exp_after:wN\bnfexpr\exp_after:wN{\l_tmpa_tl}
+         }
     }
 }
 
@@ -89,20 +94,21 @@
   \regex_split:nVNTF { : } \l_tmpa_tl \l_tmpa_seq
     {
       \seq_pop_right:NN \l_tmpa_seq \l_tmpa_tl
-      \tl_put_right:Nx \l__table_tl
+      \regex_replace_once:nnN { ^\s+ } {} \l_tmpa_tl
+      \tl_put_right:No \l__table_tl
         {
-          \bnfannot{\l_tmpa_tl}
+          \exp_after:wN\bnfannot\exp_after:wN{\l_tmpa_tl} &
         }
       \seq_pop_left:NN \l_tmpa_seq \l_tmpa_tl
-      \tl_put_right:Nx \l__table_tl
+      \tl_put_right:No \l__table_tl
         {
-          & \bnfexpr { \l_tmpa_tl }
+          \exp_after:wN\bnfexpr\exp_after:wN{\l_tmpa_tl}
         }
     }
     {
-      \tl_put_right:Nx \l__table_tl
+      \tl_put_right:No \l__table_tl
         {
-          & \bnfexpr { \l_tmpa_tl }
+          \exp_after:wN&\exp_after:wN\bnfexpr\exp_after:wN{\l_tmpa_tl}
         }
     }
 }
@@ -150,9 +156,9 @@
             \seq_pop_left:NN \l__term_seq \l__keypairs_tl
 
             \simplebnf_typeset_lhs:n{\l__term_tl}
-            \tl_put_right:Nx \l__table_tl
+            \tl_put_right:Nn \l__table_tl
               {
-                & \g__simplebnf_defeq_tl &
+                & \SimpleBNFDefEq &
               }
             %% \l__keypairs_seq - (rhs:annot | rhs)...
             \regex_split:NVN \g_simplebnf_rhs_newline_r \l__keypairs_tl \l__keypairs_seq
@@ -191,7 +197,7 @@
 
 %% The MIT License (MIT)
 %%
-%% Copyright © 2019-2020 Jay Lee <jaeho.lee at snu.ac.kr>
+%% Copyright © 2019-2022 Jay Lee <jaeho.lee at snu.ac.kr>
 %%
 %% Permission is hereby granted, free of charge, to any person obtaining
 %% a copy of this software and associated documentation files (the "Software"),



More information about the tex-live-commits mailing list.