diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3experimental/l3str')
-rw-r--r-- | Master/texmf-dist/source/latex/l3experimental/l3str/l3regex.dtx | 75 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/l3experimental/l3str/l3str-expl.dtx (renamed from Master/texmf-dist/source/latex/l3experimental/l3str/l3str.dtx) | 3 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/l3experimental/l3str/l3str.ins | 6 |
3 files changed, 60 insertions, 24 deletions
diff --git a/Master/texmf-dist/source/latex/l3experimental/l3str/l3regex.dtx b/Master/texmf-dist/source/latex/l3experimental/l3str/l3regex.dtx index 00eeafe26e1..182e09b4e51 100644 --- a/Master/texmf-dist/source/latex/l3experimental/l3str/l3regex.dtx +++ b/Master/texmf-dist/source/latex/l3experimental/l3str/l3regex.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3regex.dtx Copyright (C) 2011-2013 The LaTeX3 Project +%% File: l3regex.dtx Copyright (C) 2011-2014 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of the %% LaTeX Project Public License (LPPL), either version 1.3c of this @@ -35,7 +35,7 @@ % %<*driver|package> \RequirePackage{expl3} -\GetIdInfo$Id: l3regex.dtx 5067 2014-06-06 16:51:35Z bruno $ +\GetIdInfo$Id: l3regex.dtx 5218 2014-07-17 14:23:10Z bruno $ {L3 Experimental regular expressions} %</driver|package> %<*driver> @@ -105,7 +105,7 @@ % it can be compiled once, and stored in a regex % variable using \cs{regex_const:Nn}. For example, % \begin{verbatim} -% \regex_const:Nn \c_foo_regex { \c{begin} \cB. (\c[^BE].*) \cE. } +% \regex_const:Nn \c_foo_regex { \c{begin} \cB. (\c[^BE].*) \cE. } % \end{verbatim} % stores in \cs{c_foo_regex} a regular expression which matches the % starting marker for an environment: \cs{begin}, followed by a @@ -314,6 +314,7 @@ % |(?i)[^aeiou]| matches any character which is not a vowel. Neither % character properties, nor |\c{...}| nor |\u{...}| are affected by the % |i| option. +% ^^A \] % % In character classes, only |[|, |^|, |-|, |]|, |\| and spaces are % special, and should be escaped. Other non-alphanumeric characters can @@ -353,11 +354,13 @@ % % \subsection{Syntax of the replacement text} % -% Most of the features described in regular expressions do not make sense -% within the replacement text. Escaped characters are supported as inside -% regular expressions. The whole match is accessed as |\0|, and the first -% $9$ submatches are accessed as |\1|, \ldots{}, |\9|. Submatches with -% numbers higher than $9$ are accessed as |\g{|\meta{number}|}| instead. +% Most of the features described in regular expressions do not make +% sense within the replacement text. Escaped characters are supported +% as inside regular expressions. The whole match is accessed as~|\0|, +% and the first~$9$ submatches are accessed as |\1|, \ldots{},~|\9|. +% Further submatches are accessed through |\g{|\meta{number}|}| where +% \meta{number} is any non-negative integer. If there are fewer than +% \meta{number} capturing groups, the submatch is empty. % % For instance, % \begin{verbatim} @@ -366,18 +369,37 @@ % \end{verbatim} % results in \cs{l_my_tl} holding |H(ell--el)(o,--o) w(or--o)(ld--l)!| % +% Submatches keep the same category codes as in the original token list. % The characters inserted by the replacement have category code $12$ -% (other) by default. The escape sequence |\c| allows to insert characters +% (other) by default, with the exception of space characters. Spaces +% inserted through \verb*|\ | have category code $10$, while spaces +% inserted through |\x20| or |\x{20}| have category code $12$. +% The escape sequence |\c| allows to insert characters % with arbitrary category codes, as well as control sequences. % \begin{l3regex-syntax} -% \item[\\cXY] Produces the character |Y| (which can be given as -% an escape sequence such as |\t| for tab) with category code |X|, -% which must be one of |CBEMTPUDSLOA|. +% \item[\\cXY] Produces the character~|Y| (which can be given as an +% escape sequence such as~|\t| for tab, or |\(| or~|\)| for a +% parenthesis) with category code~|X|, which must be one of +% |CBEMTPUDSLOA|. % \item[\\c\Arg{text}] Produces the control sequence with csname -% \meta{text}. The \meta{text} may contain references to the submatches -% |\0|, |\1| \emph{etc.} +% \meta{text}. The \meta{text} may contain references to the +% submatches |\0|, |\1|, \emph{etc.} % \end{l3regex-syntax} % +% The escape sequence |\u|\Arg{tl~var~name} allows to insert the +% contents of the token list with name \meta{tl~var~name} directly into +% the replacement, avoiding the need to escape special characters. +% Within the construction |\c|\Arg{text}, the |\u|~escape sequence only +% expands its argument once, in effect performing \cs{tl_to_str:v}. +% Submatches can be used within the argument of |\u|. For instance, +% \begin{verbatim} +% \tl_set:Nn \l_my_one_tl { first } +% \tl_set:Nn \l_my_two_tl { \emph{second} } +% \tl_set:Nn \l_my_tl { one , two , one , one } +% \regex_replace_all:nnN { [^,]+ } { \u{l_my_\0_tl} } \l_my_tl +% \end{verbatim} +% results in \cs{l_my_tl} holding |first,\emph{second},first,first|. +% % \subsection{Pre-compiling regular expressions} % % If a regular expression is to be used several times, @@ -888,6 +910,15 @@ % \end{macrocode} % \end{variable} % +% \begin{variable}{\l_@@_cs_name_tl} +% This variable is used in \cs{@@_item_cs:n} to store the csname of +% the currently-tested token when the regex contains a sub-regex for +% testing csnames. +% \begin{macrocode} +\tl_new:N \l_@@_cs_name_tl +% \end{macrocode} +% \end{variable} +% % \subsubsection{Testing characters} % % \begin{macro}[int]{\@@_break_point:TF} @@ -1092,22 +1123,25 @@ % indeed matches. The three \cs{exp_after:wN} expand the contents % of the \tn{toks}\meta{current position} (of the form \cs{exp_not:n} % \Arg{control sequence}) to \meta{control sequence}. +% We store the cs name before building states for the cs, as those +% states may overlap with toks registers storing the user's input. % \begin{macrocode} \cs_new_protected:Npn \@@_item_cs:n #1 { \int_compare:nNnT \l_@@_current_catcode_int = \c_zero { \group_begin: - \@@_single_match: - \@@_disable_submatches: - \@@_build_for_cs:n {#1} - \bool_set_eq:NN \l_@@_saved_success_bool \g_@@_success_bool - \exp_args:Nx \@@_match:n + \tl_set:Nx \l_@@_cs_name_tl { \exp_after:wN \exp_after:wN \exp_after:wN \cs_to_str:N \tex_the:D \tex_toks:D \l_@@_current_pos_int } + \@@_single_match: + \@@_disable_submatches: + \@@_build_for_cs:n {#1} + \bool_set_eq:NN \l_@@_saved_success_bool \g_@@_success_bool + \exp_args:NV \@@_match:n \l_@@_cs_name_tl \if_meaning:w \c_true_bool \g_@@_success_bool \group_insert_after:N \@@_break_true:w \fi: @@ -4787,6 +4821,7 @@ % As in parsing a regular expression, we use an auxiliary built from % |#1| if defined. Otherwise, check for escaped digits (standing from % submatches from $0$ to $9$): anything else is a raw character. +% We use \cs{token_to_str:N} to give spaces the right category code. % \begin{macrocode} \cs_new_protected:Npn \@@_replacement_escaped:N #1 { @@ -4795,7 +4830,7 @@ \if_int_compare:w \c_one < 1#1 \exp_stop_f: \@@_replacement_put_submatch:n {#1} \else: - \__tl_build_one:n #1 + \__tl_build_one:o { \token_to_str:N #1 } \fi: } } diff --git a/Master/texmf-dist/source/latex/l3experimental/l3str/l3str.dtx b/Master/texmf-dist/source/latex/l3experimental/l3str/l3str-expl.dtx index 09d44a5f28c..9305a8fe07c 100644 --- a/Master/texmf-dist/source/latex/l3experimental/l3str/l3str.dtx +++ b/Master/texmf-dist/source/latex/l3experimental/l3str/l3str-expl.dtx @@ -35,8 +35,9 @@ % %<*driver|package> \RequirePackage{expl3} -\GetIdInfo$Id: l3str.dtx 4889 2014-05-26 19:59:25Z joseph $ +\GetIdInfo$Id: l3str-expl.dtx 5226 2014-07-18 18:08:01Z joseph $ {L3 Experimental strings} +\def\ExplSyntaxName{l3str} %</driver|package> %<*driver> \documentclass[full]{l3doc} diff --git a/Master/texmf-dist/source/latex/l3experimental/l3str/l3str.ins b/Master/texmf-dist/source/latex/l3experimental/l3str/l3str.ins index 8f6983abde3..0cb61fee4cc 100644 --- a/Master/texmf-dist/source/latex/l3experimental/l3str/l3str.ins +++ b/Master/texmf-dist/source/latex/l3experimental/l3str/l3str.ins @@ -35,9 +35,9 @@ Do not distribute a modified version of this file. \keepsilent -\generate{\file{l3flag.sty} {\from{l3flag.dtx} {package}}} -\generate{\file{l3str.sty} {\from{l3str.dtx} {package}}} -\generate{\file{l3regex.sty} {\from{l3regex.dtx} {package}}} +\generate{\file{l3flag.sty} {\from{l3flag.dtx} {package}}} +\generate{\file{l3str.sty} {\from{l3str-expl.dtx}{package}}} +\generate{\file{l3regex.sty} {\from{l3regex.dtx} {package}}} \generate{\file{l3str-convert.sty} {\from{l3str-convert.dtx} {package}}} \generate{\file{l3str-format.sty} {\from{l3str-format.dtx} {package}}} \generate{\file{l3tl-analysis.sty} {\from{l3tl-analysis.dtx} {package}}} |