diff options
author | Karl Berry <karl@freefriends.org> | 2014-06-17 22:32:09 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-06-17 22:32:09 +0000 |
commit | 3c2f50b92407533aabaef1823006032eedd6ef90 (patch) | |
tree | eb67245dd952c951b95c485a5eb66f9539ac83df /Master/texmf-dist/tex/latex/l3experimental/l3str/l3regex.sty | |
parent | 4aa0b8110f2fdb3044d8b26d54e12cbb49a9a3dc (diff) |
l3
git-svn-id: svn://tug.org/texlive/trunk@34268 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/l3experimental/l3str/l3regex.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/l3experimental/l3str/l3regex.sty | 201 |
1 files changed, 113 insertions, 88 deletions
diff --git a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3regex.sty b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3regex.sty index 12774db5615..55bd0e1464c 100644 --- a/Master/texmf-dist/tex/latex/l3experimental/l3str/l3regex.sty +++ b/Master/texmf-dist/tex/latex/l3experimental/l3str/l3regex.sty @@ -46,7 +46,7 @@ %% %% ----------------------------------------------------------------------- \RequirePackage{expl3} -\GetIdInfo$Id: l3regex.dtx 4623 2013-12-14 13:53:40Z bruno $ +\GetIdInfo$Id: l3regex.dtx 5067 2014-06-06 16:51:35Z bruno $ {L3 Experimental regular expressions} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} @@ -363,12 +363,12 @@ \if_charcode:w \c_space_token #1 \exp_after:wN \__regex_escape_x_test:N \else: - \exp_after:wN \__regex_escape_x_test_two:N + \exp_after:wN \__regex_escape_x_testii:N \exp_after:wN #1 \fi: } } -\cs_new:Npn \__regex_escape_x_test_two:N #1 +\cs_new:Npn \__regex_escape_x_testii:N #1 { \if_charcode:w \c_left_brace_str #1 \exp_after:wN \__regex_escape_x_loop:N @@ -389,25 +389,32 @@ } \cs_new:Npn \__regex_escape_x_loop:N #1 { - \__str_hexadecimal_use:NTF #1 - { \__regex_escape_x_loop:N } + \str_if_eq_x:nnTF {#1} { break } + { ; \__regex_escape_x_loop_error:n { } {#1} } { - \token_if_eq_charcode:NNTF \c_space_token #1 + \__str_hexadecimal_use:NTF #1 { \__regex_escape_x_loop:N } { - ; - \exp_after:wN \token_if_eq_charcode:NNTF \c_right_brace_str #1 - { \__regex_escape_loop:N } + \token_if_eq_charcode:NNTF \c_space_token #1 + { \__regex_escape_x_loop:N } { - \if_false: { \fi: } - \__tl_build_one:o \l__regex_internal_b_tl - \__msg_kernel_error:nn { regex } { x-missing-rbrace } {#1} - \tl_set:Nx \l__regex_internal_b_tl - { \if_false: } \fi: \__regex_escape_loop:N #1 + ; + \exp_after:wN + \token_if_eq_charcode:NNTF \c_right_brace_str #1 + { \__regex_escape_loop:N } + { \__regex_escape_x_loop_error:n {#1} } } } } } +\cs_new:Npn \__regex_escape_x_loop_error:n #1 + { + \if_false: { \fi: } + \__tl_build_one:o \l__regex_internal_b_tl + \__msg_kernel_error:nnx { regex } { x-missing-rbrace } {#1} + \tl_set:Nx \l__regex_internal_b_tl + { \if_false: } \fi: \__regex_escape_loop:N #1 + } \prg_new_conditional:Npnn \__regex_char_if_special:N #1 { TF } { \if_int_compare:w `#1 < \c_ninety_one @@ -612,6 +619,8 @@ { #1 } \prg_do_nothing: \prg_do_nothing: \prg_do_nothing: \prg_do_nothing: + \int_compare:nNnT \l__regex_mode_int = \c_two + { \__msg_kernel_error:nn { regex } { c-trailing } } \int_compare:nNnT \l__regex_mode_int < \c_zero { \__msg_kernel_error:nn { regex } { c-missing-rbrace } @@ -1065,7 +1074,7 @@ { __regex_compile_special_group_\token_to_str:N #4 :w } { \__msg_kernel_warning:nnx { regex } { special-group-unknown } - { (? \token_to_str:N #4 } + { (? #4 } \__regex_compile_group_begin:N \__regex_group:nnnN \__regex_compile_raw:N ? #3 #4 } @@ -2562,47 +2571,48 @@ } } \__msg_kernel_new:nnnn { regex } { trailing-backslash } - { Trailing~escape~character~\iow_char:N\\. } + { Trailing~escape~character~`\iow_char:N\\'. } { A~regular~expression~or~its~replacement~text~ends~with~ - the~escape~character~\iow_char:N\\.~It~will~be~ignored. + the~escape~character~`\iow_char:N\\'.~It~will~be~ignored. } \__msg_kernel_new:nnnn { regex } { x-missing-rbrace } - { Missing~closing~brace~in~\iow_char:N\\x~hexadecimal~sequence. } + { Missing~closing~brace~in~`\iow_char:N\\x'~hexadecimal~sequence. } { You~wrote~something~like~ - `\iow_char:N\\x\{\int_to_hexadecimal:n{#1}'.~ + `\iow_char:N\\x\{...#1'.~ The~closing~brace~is~missing. } \__msg_kernel_new:nnnn { regex } { x-overflow } - { Character~code~'#1'~too~large~in~\iow_char:N\\x~hexadecimal~sequence. } + { Character~code~`#1'~too~large~in~`\iow_char:N\\x'~hexadecimal~sequence. } { You~wrote~something~like~ `\iow_char:N\\x\{\int_to_hexadecimal:n{#1}\}'.~ - The~character~code~'#1'~is~larger~than~\int_use:N \c_max_char_int. + The~character~code~#1~is~larger~than~ + the~maximum~value~\int_use:N \c_max_char_int. } \__msg_kernel_new:nnnn { regex } { invalid-quantifier } - { Braced~quantifier~'#1'~may~not~be~followed~by~'#2'. } + { Braced~quantifier~`#1'~may~not~be~followed~by~`#2'. } { - The~character~'#2'~is~invalid~in~the~braced~quantifier~'#1'.~ - The~only~valid~quantifiers~are~'*',~'?',~'+',~'{<int>}',~ - '{<min>,}'~and~'{<min>,<max>}',~followed~or~not~by~'?'. + The~character~`#2'~is~invalid~in~the~braced~quantifier~`#1'.~ + The~only~valid~quantifiers~are~`*',~`?',~`+',~`{<int>}',~ + `{<min>,}'~and~`{<min>,<max>}',~optionally~followed~by~`?'. } \__msg_kernel_new:nnnn { regex } { missing-rbrack } { Missing~right~bracket~inserted~in~regular~expression. } { LaTeX~was~given~a~regular~expression~where~a~character~class~ - was~started~with~'[',~but~the~matching~']'~is~missing. + was~started~with~`[',~but~the~matching~`]'~is~missing. } \__msg_kernel_new:nnnn { regex } { missing-rparen } { - Missing~right~parenthes\int_compare:nTF{#1=1}{i}{e}s~ + Missing~right~ + \int_compare:nTF { #1 = 1 } { parenthesis } { parentheses } ~ inserted~in~regular~expression. } { - LaTeX~was~given~a~regular~expression~with~\int_eval:n{#1}~ - more~left~parenthes\int_compare:nTF{#1=1}{i}{e}s~than~right~ - parenthes\int_compare:nTF{#1=1}{i}{e}s. + LaTeX~was~given~a~regular~expression~with~\int_eval:n {#1} ~ + more~left~parentheses~than~right~parentheses. } \__msg_kernel_new:nnnn { regex } { extra-rparen } { Extra~right~parenthesis~ignored~in~regular~expression. } @@ -2612,7 +2622,7 @@ } \__msg_kernel_new:nnnn { regex } { bad-escape } { - Invalid~escape~\c_backslash_str #1~ + Invalid~escape~`\iow_char:N\\#1'~ \__regex_if_in_cs:TF { within~a~control~sequence. } { \__regex_if_in_class:TF @@ -2621,96 +2631,102 @@ } } { - The~escape~sequence~\iow_char:N\\#1~may~not~appear~ + The~escape~sequence~`\iow_char:N\\#1'~may~not~appear~ \__regex_if_in_cs:TF { within~a~control~sequence~test~introduced~by~ - \iow_char:N\\c\iow_char:N\{. + `\iow_char:N\\c\iow_char:N\{'. } { \__regex_if_in_class:TF { within~a~character~class~ } - { following~a~category~test~such~as~\iow_char:N\\cL~ } + { following~a~category~test~such~as~`\iow_char:N\\cL'~ } because~it~does~not~match~exactly~one~character. } } \__msg_kernel_new:nnnn { regex } { range-missing-end } - { Invalid~end-point~for~range~'#1-#2'~in~character~class. } + { Invalid~end-point~for~range~`#1-#2'~in~character~class. } { - The~end-point~'#2'~of~the~range~'#1-#2'~may~not~serve~as~an~ + The~end-point~`#2'~of~the~range~`#1-#2'~may~not~serve~as~an~ end-point~for~a~range:~alphanumeric~characters~should~not~be~ escaped,~and~non-alphanumeric~characters~should~be~escaped. } \__msg_kernel_new:nnnn { regex } { range-backwards } - { Range~[#1-#2]~out~of~order~in~character~class. } + { Range~`[#1-#2]'~out~of~order~in~character~class. } { - In~ranges~of~characters~[x-y]~appearing~in~character~classes,~ + In~ranges~of~characters~`[x-y]'~appearing~in~character~classes,~ the~first~character~code~must~not~be~larger~than~the~second.~ - Here,~#1~has~character~code~\int_eval:n {`#1},~while~#2~has~ - character~code~\int_eval:n {`#2}. + Here,~`#1'~has~character~code~\int_eval:n {`#1},~while~ + `#2'~has~character~code~\int_eval:n {`#2}. } \__msg_kernel_new:nnnn { regex } { c-bad-mode } - { Invalid~nested~\iow_char:N\\c~escape~in~regular~expression. } + { Invalid~nested~`\iow_char:N\\c'~escape~in~regular~expression. } { - The~\iow_char:N\\c~escape~cannot~be~used~within~ - a~control~sequence~test~'\iow_char:N\\c{...}'.~ - To~combine~several~category~tests,~use~'\iow_char:N\\c[...]'. + The~`\iow_char:N\\c'~escape~cannot~be~used~within~ + a~control~sequence~test~`\iow_char:N\\c{...}'.~ + To~combine~several~category~tests,~use~`\iow_char:N\\c[...]'. } \__msg_kernel_new:nnnn { regex } { c-missing-rbrace } - { Missing~right~brace~inserted~for~\iow_char:N\\c~escape. } + { Missing~right~brace~inserted~for~`\iow_char:N\\c'~escape. } { LaTeX~was~given~a~regular~expression~where~a~ - '\iow_char:N\\c\iow_char:N\{...'~construction~was~not~ended~ - with~a~closing~brace~'\iow_char:N\}'. + `\iow_char:N\\c\iow_char:N\{...'~construction~was~not~ended~ + with~a~closing~brace~`\iow_char:N\}'. } \__msg_kernel_new:nnnn { regex } { c-missing-rbrack } - { Missing~right~bracket~inserted~for~\iow_char:N\\c~escape. } + { Missing~right~bracket~inserted~for~`\iow_char:N\\c'~escape. } { - A~construction~'\iow_char:N\\c[...'~appears~in~a~ - regular~expression,~but~the~closing~']'~is~not~present. + A~construction~`\iow_char:N\\c[...'~appears~in~a~ + regular~expression,~but~the~closing~`]'~is~not~present. } \__msg_kernel_new:nnnn { regex } { c-missing-category } - { Invalid~character~'#1'~following~\iow_char:N\\c~escape. } + { Invalid~character~`#1'~following~`\iow_char:N\\c'~escape. } { - In~regular~expressions,~the~\iow_char:N\\c~escape~sequence~ + In~regular~expressions,~the~`\iow_char:N\\c'~escape~sequence~ may~only~be~followed~by~a~left~brace,~a~left~bracket,~or~a~ capital~letter~representing~a~character~category,~namely~ - one~of~ABCDELMOPSTU. + one~of~`ABCDELMOPSTU'. + } +\__msg_kernel_new:nnnn { regex } { c-trailing } + { Trailing~category~code~escape~`\iow_char:N\\c'... } + { + A~regular~expression~ends~with~`\iow_char:N\\c'~followed~ + by~a~letter.~It~will~be~ignored. } \__msg_kernel_new:nnnn { regex } { u-missing-lbrace } - { Missing~left~brace~following~\iow_char:N\\u~escape. } + { Missing~left~brace~following~`\iow_char:N\\u'~escape. } { - The~\iow_char:N\\u~escape~sequence~must~be~followed~by~ + The~`\iow_char:N\\u'~escape~sequence~must~be~followed~by~ a~brace~group~with~the~name~of~the~variable~to~use. } \__msg_kernel_new:nnnn { regex } { u-missing-rbrace } - { Missing~right~brace~inserted~for~\iow_char:N\\u~escape. } + { Missing~right~brace~inserted~for~`\iow_char:N\\u'~escape. } { LaTeX~ \str_if_eq_x:nnTF { } {#2} { reached~the~end~of~the~string~ } - { encountered~an~escaped~alphanumeric~character '\iow_char:N\\#2'~ } - when~parsing~the~argument~of~an~'\iow_char:N\\u\iow_char:N\{...\}'~escape. + { encountered~an~escaped~alphanumeric~character `\iow_char:N\\#2'~ } + when~parsing~the~argument~of~an~`\iow_char:N\\u\iow_char:N\{...\}'~escape. } \__msg_kernel_new:nnnn { regex } { posix-unsupported } - { POSIX~collating~element~'[#1 ~ #1]'~not~supported. } + { POSIX~collating~element~`[#1 ~ #1]'~not~supported. } { - The~[.foo.]~and~[=bar=]~syntaxes~have~a~special~meaning~in~POSIX~ - regular~expressions.~This~is~not~supported~by~LaTeX.~Maybe~you~ - forgot~to~escape~a~left~bracket~in~a~character~class? + The~`[.foo.]'~and~`[=bar=]'~syntaxes~have~a~special~meaning~ + in~POSIX~regular~expressions.~This~is~not~supported~by~LaTeX.~ + Maybe~you~forgot~to~escape~a~left~bracket~in~a~character~class? } \__msg_kernel_new:nnnn { regex } { posix-unknown } - { POSIX~class~[:#1:]~unknown. } + { POSIX~class~`[:#1:]'~unknown. } { - [:#1:]~is~not~among~the~known~POSIX~classes~ - [:alnum:],~[:alpha:],~[:ascii:],~[:blank:],~ - [:cntrl:],~[:digit:],~[:graph:],~[:lower:],~ - [:print:],~[:punct:],~[:space:],~[:upper:],~ - [:word:],~and~[:xdigit:]. + `[:#1:]'~is~not~among~the~known~POSIX~classes~ + `[:alnum:]',~`[:alpha:]',~`[:ascii:]',~`[:blank:]',~ + `[:cntrl:]',~`[:digit:]',~`[:graph:]',~`[:lower:]',~ + `[:print:]',~`[:punct:]',~`[:space:]',~`[:upper:]',~ + `[:word:]',~and~`[:xdigit:]'. } \__msg_kernel_new:nnnn { regex } { posix-missing-close } - { Missing~closing~':]'~for~POSIX~class. } - { The~POSIX~syntax~'#1'~must~be~followed~by~':]',~not~'#2'. } + { Missing~closing~`:]'~for~POSIX~class. } + { The~POSIX~syntax~`#1'~must~be~followed~by~`:]',~not~`#2'. } \__msg_kernel_new:nnnn { regex } { result-unbalanced } { Missing~brace~inserted~when~#1. } { @@ -2722,55 +2738,64 @@ \__msg_kernel_new:nnnn { regex } { unknown-option } { Unknown~option~`#1'~for~regular~expressions. } { - The~only~available~option~is~'case-insensitive',~toggled~by~ - '(?i)'~and~'(?-i)'. + The~only~available~option~is~`case-insensitive',~toggled~by~ + `(?i)'~and~`(?-i)'. + } +\__msg_kernel_new:nnnn { regex } { special-group-unknown } + { Unknown~special~group~`#1~...'~in~a~regular~expression. } + { + The~only~valid~constructions~starting~with~`(?'~are~ + `(?:~...~)',~`(?|~...~)',~`(?i)',~and~`(?-i)'. } \__msg_kernel_new:nnnn { regex } { replacement-c } - { Misused~\iow_char:N\\c~command~in~a~replacement~text. } + { Misused~`\iow_char:N\\c'~command~in~a~replacement~text. } { - In~a~replacement~text,~the~\iow_char:N\\c~escape~sequence~ - can~be~followed~by~one~of~the~letters~ABCDELMOPSTU~ - or~a~brace~group,~not~by~'#1'. + In~a~replacement~text,~the~`\iow_char:N\\c'~escape~sequence~ + can~be~followed~by~one~of~the~letters~`ABCDELMOPSTU'~ + or~a~brace~group,~not~by~`#1'. } \__msg_kernel_new:nnnn { regex } { replacement-u } - { Misused~\iow_char:N\\u~command~in~a~replacement~text. } + { Misused~`\iow_char:N\\u'~command~in~a~replacement~text. } { - In~a~replacement~text,~the~\iow_char:N\\u~escape~sequence~ + In~a~replacement~text,~the~`\iow_char:N\\u'~escape~sequence~ must~be~~followed~by~a~brace~group~holding~the~name~of~the~ variable~to~use. } \__msg_kernel_new:nnnn { regex } { replacement-g } - { Missing~brace~for~the~\iow_char:N\\g~construction~in~a~replacement~text. } + { + Missing~brace~for~the~`\iow_char:N\\g'~construction~ + in~a~replacement~text. + } { In~the~replacement~text~for~a~regular~expression~search,~ - submatches~are~represented~either~as~\iow_char:N \\g{dd..d},~ - or~\\d,~where~`d'~are~single~digits.~Here,~a~brace~is~missing. + submatches~are~represented~either~as~`\iow_char:N \\g{dd..d}',~ + or~`\\d',~where~`d'~are~single~digits.~Here,~a~brace~is~missing. } \__msg_kernel_new:nnnn { regex } { replacement-catcode-end } { - Missing~character~for~the~\iow_char:N\\c<category><character>~ + Missing~character~for~the~`\iow_char:N\\c<category><character>'~ construction~in~a~replacement~text. } { - In~a~replacement~text,~the~\iow_char:N\\c~escape~sequence~ - can~be~followed~by~one~of~the~letters~ABCDELMOPSTU~representing~ + In~a~replacement~text,~the~`\iow_char:N\\c'~escape~sequence~ + can~be~followed~by~one~of~the~letters~`ABCDELMOPSTU'~representing~ the~character~category.~Then,~a~character~must~follow.~LaTeX~ reached~the~end~of~the~replacement~when~looking~for~that. } \__msg_kernel_new:nnnn { regex } { replacement-null-space } { TeX~cannot~build~a~space~token~with~character~code~0. } { - You~asked~for~a~character~token~with~category~'space',~ + You~asked~for~a~character~token~with~category~space,~ and~character~code~0,~for~instance~through~ - '\iow_char:N\\cS\iow_char:N\\x00'.~ + `\iow_char:N\\cS\iow_char:N\\x00'.~ This~specific~case~is~impossible~and~will~be~replaced~ by~a~normal~space. } \__msg_kernel_new:nnnn { regex } { replacement-missing-rbrace } { Missing~right~brace~inserted~in~replacement~text. } { - There~were~\int_use:N \l__regex_replacement_csnames_int \ - missing~right~braces. + There~ \int_compare:nTF { #1 = 1 } { was } { were } ~ #1~ + missing~right~\int_compare:nTF { #1 = 1 } { brace } { braces } . } \cs_new:Npn \__regex_msg_repeated:nnN #1#2#3 { |