diff options
Diffstat (limited to 'macros/latex/contrib/l3kernel/l3int.dtx')
-rw-r--r-- | macros/latex/contrib/l3kernel/l3int.dtx | 81 |
1 files changed, 56 insertions, 25 deletions
diff --git a/macros/latex/contrib/l3kernel/l3int.dtx b/macros/latex/contrib/l3kernel/l3int.dtx index 6ec7cd6528..faab276e44 100644 --- a/macros/latex/contrib/l3kernel/l3int.dtx +++ b/macros/latex/contrib/l3kernel/l3int.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-05-05} +% \date{Released 2020-05-11} % % \maketitle % @@ -1053,6 +1053,37 @@ % \end{macro} % \end{macro} % +% \begin{variable}{\s_@@_mark,\s_@@_stop} +% Scan marks used throughout the module. +% \begin{macrocode} +\scan_new:N \s_@@_mark +\scan_new:N \s_@@_stop +% \end{macrocode} +% \end{variable} +% +% \begin{macro}[EXP]{\@@_use_none_delimit_by_s_stop:w} +% Function to gobble until a scan mark. +% \begin{macrocode} +\cs_new:Npn \@@_use_none_delimit_by_s_stop:w #1 \s_@@_stop { } +% \end{macrocode} +% \end{macro} +% +% \begin{variable}{\q_@@_recursion_tail,\q_@@_recursion_stop} +% Quarks for recursion. +% \begin{macrocode} +\quark_new:N \q_@@_recursion_tail +\quark_new:N \q_@@_recursion_stop +% \end{macrocode} +% \end{variable} +% +% \begin{macro}[EXP]{\@@_if_recursion_tail_stop_do:Nn,\@@_if_recursion_tail_stop:N} +% Functions to query quarks. +% \begin{macrocode} +\__kernel_quark_new_test:N \@@_if_recursion_tail_stop_do:Nn +\__kernel_quark_new_test:N \@@_if_recursion_tail_stop:N +% \end{macrocode} +% \end{macro} +% % \subsection{Integer expressions} % % \begin{macro}{\int_eval:n} @@ -1469,7 +1500,7 @@ \@@_compare_error: } \cs_new:Npn \@@_compare_error:Nw - #1#2 \q_stop + #1#2 \s_@@_stop { { } \c_zero_int \fi: @@ -1525,7 +1556,7 @@ % \cs{@@_compare:w} receives as its argument an integer, a relation % symbol, and some more tokens. We then setup the loop, which is % ended by the two odd-looking items |e| and |{=nd_}|, with a trailing -% \cs{q_stop} used to grab the entire argument when necessary. +% \cs{s_@@_stop} used to grab the entire argument when necessary. % \begin{macrocode} \prg_new_conditional:Npnn \int_compare:n #1 { p , T , F , TF } { @@ -1535,7 +1566,7 @@ \cs_new:Npn \@@_compare:w #1 \@@_compare_error: { \exp_after:wN \if_false: \int_value:w - \@@_compare:Nw #1 e { = nd_ } \q_stop + \@@_compare:Nw #1 e { = nd_ } \s_@@_stop } % \end{macrocode} % The goal here is to find an \meta{operand} and a \meta{comparison}. @@ -1552,13 +1583,13 @@ % \cs{scan_stop:}, ignored thanks to \tn{unexpanded}, and % \cs{@@_compare_error:Nw} raises an error. % \begin{macrocode} -\cs_new:Npn \@@_compare:Nw #1#2 \q_stop +\cs_new:Npn \@@_compare:Nw #1#2 \s_@@_stop { \exp_after:wN \@@_compare:NNw - \@@_to_roman:w - 0 #2 \q_mark - #1#2 \q_stop + \@@_to_roman:w - 0 #2 \s_@@_mark + #1#2 \s_@@_stop } -\cs_new:Npn \@@_compare:NNw #1#2#3 \q_mark +\cs_new:Npn \@@_compare:NNw #1#2#3 \s_@@_mark { \__kernel_exp_not:w \use:c @@ -1585,7 +1616,7 @@ % and call \cs{@@_compare:Nw} to look for additional operands, after % evaluating the following expression. % \begin{macrocode} -\cs_new:cpn { @@_compare_end_=:NNw } #1#2#3 e #4 \q_stop +\cs_new:cpn { @@_compare_end_=:NNw } #1#2#3 e #4 \s_@@_stop { {#3} \exp_stop_f: \prg_return_false: \else: \prg_return_true: \fi: @@ -1593,7 +1624,7 @@ \cs_new:Npn \@@_compare:nnN #1#2#3 { {#2} \exp_stop_f: - \prg_return_false: \exp_after:wN \use_none_delimit_by_q_stop:w + \prg_return_false: \exp_after:wN \@@_use_none_delimit_by_s_stop:w \fi: #1 #2 #3 \exp_after:wN \@@_compare:Nw \int_value:w \@@_eval:w } @@ -1665,14 +1696,14 @@ \exp_args:Nf \@@_case:nnTF { \int_eval:n {#1} } {#2} { } { } } \cs_new:Npn \@@_case:nnTF #1#2#3#4 - { \@@_case:nw {#1} #2 {#1} { } \q_mark {#3} \q_mark {#4} \q_stop } + { \@@_case:nw {#1} #2 {#1} { } \s_@@_mark {#3} \s_@@_mark {#4} \s_@@_stop } \cs_new:Npn \@@_case:nw #1#2#3 { \int_compare:nNnTF {#1} = {#2} { \@@_case_end:nw {#3} } { \@@_case:nw {#1} } } -\cs_new:Npn \@@_case_end:nw #1#2#3 \q_mark #4#5 \q_stop +\cs_new:Npn \@@_case_end:nw #1#2#3 \s_@@_mark #4#5 \s_@@_stop { \exp_end: #1 #4 } % \end{macrocode} % \end{macro} @@ -2261,10 +2292,10 @@ % \subsection{Converting from other formats to integers} % % \begin{macro}[rEXP]{\@@_pass_signs:wn, \@@_pass_signs_end:wn} -% Called as \cs{@@_pass_signs:wn} \meta{signs and digits} \cs{q_stop} +% Called as \cs{@@_pass_signs:wn} \meta{signs and digits} \cs{s_@@_stop} % \Arg{code}, this function leaves in the input stream any sign it % finds, then inserts the \meta{code} before the first non-sign token -% (and removes \cs{q_stop}). More precisely, it deletes any~|+| and +% (and removes \cs{s_@@_stop}). More precisely, it deletes any~|+| and % passes any~|-| to the input stream, hence should be called in an % integer expression. % \begin{macrocode} @@ -2277,7 +2308,7 @@ \exp_after:wN #1 \fi: } -\cs_new:Npn \@@_pass_signs_end:wn #1 \q_stop #2 { #2 #1 } +\cs_new:Npn \@@_pass_signs_end:wn #1 \s_@@_stop #2 { #2 #1 } % \end{macrocode} % \end{macro} % @@ -2295,13 +2326,13 @@ \int_eval:n { \exp_after:wN \@@_pass_signs:wn \tl_to_str:n {#1} - \q_stop { \@@_from_alph:nN { 0 } } - \q_recursion_tail \q_recursion_stop + \s_@@_stop { \@@_from_alph:nN { 0 } } + \q_@@_recursion_tail \q_@@_recursion_stop } } \cs_new:Npn \@@_from_alph:nN #1#2 { - \quark_if_recursion_tail_stop_do:Nn #2 {#1} + \@@_if_recursion_tail_stop_do:Nn #2 {#1} \exp_args:Nf \@@_from_alph:nN { \int_eval:n { #1 * 26 + \@@_from_alph:N #2 } } } @@ -2327,13 +2358,13 @@ \int_eval:n { \exp_after:wN \@@_pass_signs:wn \tl_to_str:n {#1} - \q_stop { \@@_from_base:nnN { 0 } {#2} } - \q_recursion_tail \q_recursion_stop + \s_@@_stop { \@@_from_base:nnN { 0 } {#2} } + \q_@@_recursion_tail \q_@@_recursion_stop } } \cs_new:Npn \@@_from_base:nnN #1#2#3 { - \quark_if_recursion_tail_stop_do:Nn #3 {#1} + \@@_if_recursion_tail_stop_do:Nn #3 {#1} \exp_args:Nf \@@_from_base:nnN { \int_eval:n { #1 * #2 + \@@_from_base:N #3 } } {#2} @@ -2409,16 +2440,16 @@ ( 0 \exp_after:wN \@@_from_roman:NN \tl_to_str:n {#1} - \q_recursion_tail \q_recursion_tail \q_recursion_stop + \q_@@_recursion_tail \q_@@_recursion_tail \q_@@_recursion_stop ) } } \cs_new:Npn \@@_from_roman:NN #1#2 { - \quark_if_recursion_tail_stop:N #1 + \@@_if_recursion_tail_stop:N #1 \int_if_exist:cF { c_@@_from_roman_ #1 _int } { \@@_from_roman_error:w } - \quark_if_recursion_tail_stop_do:Nn #2 + \@@_if_recursion_tail_stop_do:Nn #2 { + \use:c { c_@@_from_roman_ #1 _int } } \int_if_exist:cF { c_@@_from_roman_ #2 _int } { \@@_from_roman_error:w } @@ -2436,7 +2467,7 @@ \@@_from_roman:NN #2 } } -\cs_new:Npn \@@_from_roman_error:w #1 \q_recursion_stop #2 +\cs_new:Npn \@@_from_roman_error:w #1 \q_@@_recursion_stop #2 { #2 * 0 - 1 } % \end{macrocode} % \end{macro} |