summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/simplebnf/simplebnf.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/simplebnf/simplebnf.sty')
-rw-r--r--Master/texmf-dist/tex/latex/simplebnf/simplebnf.sty56
1 files changed, 31 insertions, 25 deletions
diff --git a/Master/texmf-dist/tex/latex/simplebnf/simplebnf.sty b/Master/texmf-dist/tex/latex/simplebnf/simplebnf.sty
index fd7b707ff79..ae4482c29ba 100644
--- a/Master/texmf-dist/tex/latex/simplebnf/simplebnf.sty
+++ b/Master/texmf-dist/tex/latex/simplebnf/simplebnf.sty
@@ -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@snu.ac.kr>
+%% Copyright © 2019-2022 Jay Lee <jaeho.lee@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"),