Skip to content

Commit

Permalink
#14 stricter regexps
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jul 11, 2023
1 parent 78b87d1 commit 6feab24
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions naive-ebnf.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
% \end{docshot}

% Special symbols are interpreted correctly, if they stay inside quotes:
% \docshotOptions{}
% \docshotOptions{firstline=5,lastline=9}
% \begin{docshot}
% \documentclass{minimal}
% \usepackage[T1]{fontenc}
Expand All @@ -212,6 +212,21 @@
% \end{document}
% \end{docshot}

% Nested brackets work fine too:
% \docshotOptions{firstline=5,lastline=9}
% \begin{docshot}
% \documentclass{minimal}
% \usepackage[T1]{fontenc}
% \usepackage{naive-ebnf}
% \begin{document}\noindent
% \begin{ebnf}[1.5in]
% <x> := ( "x" ( "y" | ( "z" | <z> ) ) ) \\
% <y> := [ [ "x" ] "y" ( <x> | <z> ) ] \\
% <z> := { { { <x> } <y> } <z> } \\
% \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:
Expand Down Expand Up @@ -379,11 +394,11 @@
\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 { \{\ (.+?)\ \} }%
\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%
Expand Down

0 comments on commit 6feab24

Please sign in to comment.