diff options
author | Norbert Preining <norbert@preining.info> | 2023-07-01 03:01:25 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2023-07-01 03:01:25 +0000 |
commit | 3a29216caca37803e25b84a50fd5f7f91ebc04d3 (patch) | |
tree | 45c329c33b2bc8601810e0983b3590448a3279ec /macros/latex/contrib/naive-ebnf | |
parent | 711112a97f2a98854236304a216213632d61eeb7 (diff) |
CTAN sync 202307010301
Diffstat (limited to 'macros/latex/contrib/naive-ebnf')
-rw-r--r-- | macros/latex/contrib/naive-ebnf/naive-ebnf.dtx | 49 | ||||
-rw-r--r-- | macros/latex/contrib/naive-ebnf/naive-ebnf.pdf | bin | 591999 -> 631010 bytes |
2 files changed, 34 insertions, 15 deletions
diff --git a/macros/latex/contrib/naive-ebnf/naive-ebnf.dtx b/macros/latex/contrib/naive-ebnf/naive-ebnf.dtx index 8f7768f156..d3105b2b87 100644 --- a/macros/latex/contrib/naive-ebnf/naive-ebnf.dtx +++ b/macros/latex/contrib/naive-ebnf/naive-ebnf.dtx @@ -50,7 +50,7 @@ %<package>\NeedsTeXFormat{LaTeX2e} %<package>\ProvidesPackage{naive-ebnf} %<*package> -[2023-05-27 0.0.6 EBNF in Plain Text] +[2023-06-30 0.0.7 EBNF in Plain Text] %</package> %<*driver> \documentclass{ltxdoc} @@ -133,7 +133,7 @@ % \begin{ebnf}[1.5in] % <VeryLongVariable> := <X> | <Y> \\ % <X> := "X" 'EOL' \\ -% <Y> := "Y" +% <Y> := "Y" \\ % \end{ebnf} % \end{document} % \end{docshot} @@ -171,6 +171,21 @@ % \end{document} % \end{docshot} +% Special symbols are interpreted correctly, if they stay inside quotes: +% \docshotOptions{} +% \begin{docshot} +% \documentclass{minimal} +% \usepackage[T1]{fontenc} +% \usepackage{naive-ebnf} +% \begin{document}\noindent +% \begin{ebnf}[1.5in] +% <X> := 'EOL' "'" "|" \\ +% <Y> := ">" "<" "]" "[" \\ +% <Z> := "\LaTeX" "\textdollar" \\ +% \end{ebnf} +% \end{document} +% \end{docshot} + % \section{Package Options} % It's possible to configure the behavior of the package with the help of a few package options: @@ -215,7 +230,6 @@ bw/.store in=\ebnf@bw, trail/.store in=\ebnf@trail, trail/.default=naive-ebnf.tmp.tex, - trail } \ProcessPgfPackageOptions{/ebnf} % \end{macrocode} @@ -257,10 +271,10 @@ % Then, we a command to render a single non-terminal: % \begin{macrocode} \makeatletter -\newcommand\nonterminal[1]{% +\newcommand\nonterminal[1]{{% \ebnf@color{gray}{\relax\ifmmode\langle\else\(\langle\)\fi}% \relax\ifmmode\textsf{#1}\else{\sffamily#1}\fi% - \ebnf@color{gray}{\relax\ifmmode\rangle\else\(\rangle\)\fi}} + \ebnf@color{gray}{\relax\ifmmode\rangle\else\(\rangle\)\fi}}} \makeatother % \end{macrocode} % \end{macro} @@ -270,7 +284,7 @@ % Then, we a command to render a single non-terminal: % \begin{macrocode} \makeatletter -\newcommand\sterminal[1]{\relax\ifmmode\else\ttfamily\fi#1}% +\newcommand\sterminal[1]{{\relax\ifmmode\else\ttfamily\fi#1}}% \makeatother % \end{macrocode} % \end{macro} @@ -286,18 +300,18 @@ {\ebnf@color{gray}{(}#1\ebnf@color{gray}{)}} \ExplSyntaxOn \newcommand\ebnf@terminal[1]{ - \tl_set:Nn \l_ebnf_tl { } - \tl_set_rescan:Nno \l_ebnf_tl { } { #1 } + \tl_set:Nn \l_ebnf_tl {} + \tl_set_rescan:Nnn \l_ebnf_tl {} { #1 } \terminal{\l_ebnf_tl} } \newcommand\ebnf@sterminal[1]{ - \tl_set:Nn \l_ebnf_tl { } - \tl_set_rescan:Nno \l_ebnf_tl { } { #1 } + \tl_set:Nn \l_ebnf_tl {} + \tl_set_rescan:Nnn \l_ebnf_tl {} { #1 } \sterminal{\l_ebnf_tl} } \newcommand\ebnf@nonterminal[1]{ - \tl_set:Nn \l_ebnf_tl { } - \tl_set_rescan:Nno \l_ebnf_tl { } { #1 } + \tl_set:Nn \l_ebnf_tl {} + \tl_set_rescan:Nnn \l_ebnf_tl {} { #1 } \nonterminal{\l_ebnf_tl} } \ExplSyntaxOff @@ -318,11 +332,16 @@ \NewDocumentEnvironment{ebnf}{O{4em}+b} {\tl_set:Nn\l__ebnf_tmp_tl{#2}} {% - \regex_replace_all:nnN { \{(.+?)\} }% + \regex_replace_all:nnN { ([^\ ])< } {\1\\textless{}} \l__ebnf_tmp_tl% + \regex_replace_all:nnN { >([^\ ]) } {\\textgreater{}\1} \l__ebnf_tmp_tl% + \regex_replace_all:nnN { ([^\ ])'([^\ ]) } {\1\\textquotesingle{}\2} \l__ebnf_tmp_tl% + \regex_replace_all:nnN { ([^\ ])\|([^\ ]) } {\1\\textbar{}\2} \l__ebnf_tmp_tl% + % + \regex_replace_all:nnN { \{\ (.+?)\ \} }% {\c{ebnf@repetition}{\1}} \l__ebnf_tmp_tl% - \regex_replace_all:nnN { \((.+?)\) }% + \regex_replace_all:nnN { \(\ (.+?)\ \) }% {\c{ebnf@grouping}{\1}} \l__ebnf_tmp_tl% - \regex_replace_all:nnN { \[(.+?)\] }% + \regex_replace_all:nnN { \[\ (.+?)\ \] }% {\c{ebnf@optional}{\1}} \l__ebnf_tmp_tl% \regex_replace_all:nnN { (<[^>]+?>\ :=) }% {\c{makebox}[#1][r]{\1}} \l__ebnf_tmp_tl% diff --git a/macros/latex/contrib/naive-ebnf/naive-ebnf.pdf b/macros/latex/contrib/naive-ebnf/naive-ebnf.pdf Binary files differindex 96b2f8a7d3..d15fe959a6 100644 --- a/macros/latex/contrib/naive-ebnf/naive-ebnf.pdf +++ b/macros/latex/contrib/naive-ebnf/naive-ebnf.pdf |