Skip to content

Commit

Permalink
Yet more quark replacements (l3expan)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhelypeOleinik committed Mar 13, 2020
1 parent 4d5ccd4 commit 603f539
Showing 1 changed file with 69 additions and 40 deletions.
109 changes: 69 additions & 40 deletions l3kernel/l3expan.dtx
Expand Up @@ -2165,6 +2165,35 @@
%<@@=cs>
% \end{macrocode}
%
% \begin{variable}{\s_@@_mark,\s_@@_stop}
% Internal scan marks. No \pkg{l3scan} yet, so do things by hand.
% \begin{macrocode}
\cs_new_eq:NN \s_@@_mark \scan_stop:
\cs_new_eq:NN \s_@@_stop \scan_stop:
% \end{macrocode}
% \end{variable}
%
% \begin{variable}{\q_@@_recursion_stop}
% Internal recursion quarks. No \pkg{l3quark} yet, so do things by hand.
% \begin{macrocode}
\cs_new:Npn \q_@@_recursion_stop { \q_@@_recursion_stop }
% \end{macrocode}
% \end{variable}
%
% \begin{macro}[EXP]{
% \@@_use_none_delimit_by_s_stop:w,
% \@@_use_i_delimit_by_s_stop:nw,
% \@@_use_none_delimit_by_q_recursion_stop:w
% }
% Internal scan marks.
% \begin{macrocode}
\cs_new:Npn \@@_use_none_delimit_by_s_stop:w #1 \s_@@_stop { }
\cs_new:Npn \@@_use_i_delimit_by_s_stop:nw #1 #2 \s_@@_stop {#1}
\cs_new:Npn \@@_use_none_delimit_by_q_recursion_stop:w
#1 \q_@@_recursion_stop { }
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\cs_generate_variant:Nn, \cs_generate_variant:cn}
% \begin{arguments}
% \item Base form of a function; \emph{e.g.},~\cs{tl_set:Nn}
Expand All @@ -2189,7 +2218,7 @@
\exp_not:N #1
\tl_to_str:n {#2} ,
\exp_not:N \scan_stop: ,
\exp_not:N \q_recursion_stop
\exp_not:N \q_@@_recursion_stop
}
}
\cs_new_protected:Npn \cs_generate_variant:cn
Expand Down Expand Up @@ -2229,20 +2258,20 @@
\exp_not:N \else:
\exp_not:N \exp_after:wN \exp_not:N \@@_generate_variant:ww
\exp_not:N \token_to_meaning:N #1 \tl_to_str:n { ma }
\exp_not:N \q_mark
\exp_not:N \q_mark \cs_new_protected:Npx
\exp_not:N \s_@@_mark
\exp_not:N \s_@@_mark \cs_new_protected:Npx
\tl_to_str:n { pr }
\exp_not:N \q_mark \cs_new:Npx
\exp_not:N \q_stop
\exp_not:N \s_@@_mark \cs_new:Npx
\exp_not:N \s_@@_stop
\exp_not:N \fi:
}
\exp_last_unbraced:NNNNo
\cs_new_protected:Npn \@@_generate_variant:ww
#1 { \tl_to_str:n { ma } } #2 \q_mark
#1 { \tl_to_str:n { ma } } #2 \s_@@_mark
{ \@@_generate_variant:wwNw #1 }
\exp_last_unbraced:NNNNo
\cs_new_protected:Npn \@@_generate_variant:wwNw
#1 { \tl_to_str:n { pr } } #2 \q_mark #3 #4 \q_stop
#1 { \tl_to_str:n { pr } } #2 \s_@@_mark #3 #4 \s_@@_stop
{ \cs_set_eq:NN \@@_tmp:w #3 }
% \end{macrocode}
% \end{macro}
Expand All @@ -2265,7 +2294,7 @@
\if_meaning:w \c_false_bool #3
\__kernel_msg_error:nnx { kernel } { missing-colon }
{ \token_to_str:c {#1} }
\exp_after:wN \use_none_delimit_by_q_recursion_stop:w
\exp_after:wN \@@_use_none_delimit_by_q_recursion_stop:w
\fi:
\@@_generate_variant:Nnnw #4 {#1}{#2}
}
Expand Down Expand Up @@ -2325,19 +2354,19 @@
\cs_new_protected:Npn \@@_generate_variant:Nnnw #1#2#3#4 ,
{
\if_meaning:w \scan_stop: #4
\exp_after:wN \use_none_delimit_by_q_recursion_stop:w
\exp_after:wN \@@_use_none_delimit_by_q_recursion_stop:w
\fi:
\use:x
{
\exp_not:N \@@_generate_variant:wwNN
\@@_generate_variant_loop:nNwN { }
#4
\@@_generate_variant_loop_end:nwwwNNnn
\q_mark
\s_@@_mark
#3 ~
{ ~ { } \fi: \@@_generate_variant_loop_long:wNNnn } ~
{ }
\q_stop
\s_@@_stop
\exp_not:N #1 {#2} {#4}
}
\@@_generate_variant:Nnnw #1 {#2} {#3}
Expand Down Expand Up @@ -2407,7 +2436,7 @@
% argument: this empty brace group produces the correct signature for
% the full variant.
% \begin{macrocode}
\cs_new:Npn \@@_generate_variant_loop:nNwN #1#2#3 \q_mark #4
\cs_new:Npn \@@_generate_variant_loop:nNwN #1#2#3 \s_@@_mark #4
{
\if:w #2 #4
\exp_after:wN \@@_generate_variant_loop_same:w
Expand All @@ -2426,7 +2455,7 @@
#1
\prg_do_nothing:
#2
\@@_generate_variant_loop:nNwN { } #3 \q_mark
\@@_generate_variant_loop:nNwN { } #3 \s_@@_mark
}
\cs_new:Npn \@@_generate_variant_loop_base:N #1
{
Expand Down Expand Up @@ -2454,46 +2483,46 @@
#1 \prg_do_nothing: #2#3#4
{ #3 { #1 \@@_generate_variant_same:N #2 } }
\cs_new:Npn \@@_generate_variant_loop_end:nwwwNNnn
#1#2 \q_mark #3 ~ #4 \q_stop #5#6#7#8
#1#2 \s_@@_mark #3 ~ #4 \s_@@_stop #5#6#7#8
{
\scan_stop: \scan_stop: \fi:
\exp_not:N \q_mark
\exp_not:N \q_stop
\exp_not:N \s_@@_mark
\exp_not:N \s_@@_stop
\exp_not:N #6
\exp_not:c { #7 : #8 #1 #3 }
}
\cs_new:Npn \@@_generate_variant_loop_long:wNNnn #1 \q_stop #2#3#4#5
\cs_new:Npn \@@_generate_variant_loop_long:wNNnn #1 \s_@@_stop #2#3#4#5
{
\exp_not:n
{
\q_mark
\s_@@_mark
\__kernel_msg_error:nnxx { kernel } { variant-too-long }
{#5} { \token_to_str:N #3 }
\use_none:nnn
\q_stop
\s_@@_stop
#3
#3
}
}
\cs_new:Npn \@@_generate_variant_loop_invalid:NNwNNnn
#1#2 \fi: \fi: \fi: #3 \q_stop #4#5#6#7
#1#2 \fi: \fi: \fi: #3 \s_@@_stop #4#5#6#7
{
\fi: \fi: \fi:
\exp_not:n
{
\q_mark
\s_@@_mark
\__kernel_msg_error:nnxxxx { kernel } { invalid-variant }
{#7} { \token_to_str:N #5 } {#1} {#2}
\use_none:nnn
\q_stop
\s_@@_stop
#5
#5
}
}
\cs_new:Npn \@@_generate_variant_loop_special:NNwNNnn
#1#2#3 \q_stop #4#5#6#7
#1#2#3 \s_@@_stop #4#5#6#7
{
#3 \q_stop #4 #5 {#6} {#7}
#3 \s_@@_stop #4 #5 {#6} {#7}
\exp_not:n
{
\__kernel_msg_error:nnxxxx
Expand Down Expand Up @@ -2534,7 +2563,7 @@
% combining the |\exp_args:N #3| variant and the base function.
% \begin{macrocode}
\cs_new_protected:Npn \@@_generate_variant:wwNN
#1 \q_mark #2 \q_stop #3#4
#1 \s_@@_mark #2 \s_@@_stop #3#4
{
#2
\cs_if_free:NT #4
Expand Down Expand Up @@ -2568,20 +2597,20 @@
\cs_new_protected:Npx \@@_generate_internal_variant:n #1
{
\exp_not:N \@@_generate_internal_variant:wwnNwn
#1 \exp_not:N \q_mark
#1 \exp_not:N \s_@@_mark
{ \cs_set_eq:NN \exp_not:N \@@_tmp:w \cs_new_protected:Npx }
\cs_new_protected:cpn
\use:x
\token_to_str:N x \exp_not:N \q_mark
\token_to_str:N x \exp_not:N \s_@@_mark
{ }
\cs_new:cpn
\exp_not:N \tex_expanded:D
\exp_not:N \q_stop
\exp_not:N \s_@@_stop
{#1}
}
\exp_last_unbraced:NNNNo
\cs_new_protected:Npn \@@_generate_internal_variant:wwnNwn #1
{ \token_to_str:N x } #2 \q_mark #3#4#5#6 \q_stop #7
{ \token_to_str:N x } #2 \s_@@_mark #3#4#5#6 \s_@@_stop #7
{
#3
\cs_if_free:cT { exp_args:N #7 }
Expand All @@ -2600,7 +2629,7 @@
\exp_after:wN \@@_generate_internal_test_aux:w \exp_after:wN #1
\fi:
##3
\q_mark
\s_@@_mark
{
\use:x
{
Expand All @@ -2609,12 +2638,12 @@
}
}
#1
\q_mark
\s_@@_mark
{ \exp_not:n { \@@_generate_internal_one_go:NNn ##1 ##2 {##3} } }
\q_stop
\s_@@_stop
}
\cs_new_protected:Npn \@@_generate_internal_test_aux:w
##1 #1 ##2 \q_mark ##3 ##4 \q_stop {##3}
##1 #1 ##2 \s_@@_mark ##3 ##4 \s_@@_stop {##3}
\cs_if_exist:NTF \tex_expanded:D
{
\cs_new_eq:NN \@@_generate_internal_test:Nw
Expand Down Expand Up @@ -2722,20 +2751,20 @@
\if_meaning:w \c_false_bool #3
\__kernel_msg_error:nnx { kernel } { missing-colon }
{ \token_to_str:c {#1} }
\use_i_delimit_by_q_stop:nw
\@@_use_i_delimit_by_s_stop:nw
\fi:
\exp_after:wN \@@_generate_variant:w
\tl_to_str:n {#5} , \scan_stop: , \q_recursion_stop
\use_none_delimit_by_q_stop:w \q_mark {#1} {#2} {#4} \q_stop
\tl_to_str:n {#5} , \scan_stop: , \q_@@_recursion_stop
\@@_use_none_delimit_by_s_stop:w \s_@@_mark {#1} {#2} {#4} \s_@@_stop
}
\cs_new_protected:Npn \@@_generate_variant:w
#1 , #2 \q_mark #3#4#5
#1 , #2 \s_@@_mark #3#4#5
{
\if_meaning:w \scan_stop: #1 \scan_stop:
\if_meaning:w \q_nil #1 \q_nil
\if_meaning:w \q_@@_nil #1 \q_@@_nil
\use_i:nnn
\fi:
\exp_after:wN \use_none_delimit_by_q_recursion_stop:w
\exp_after:wN \@@_use_none_delimit_by_q_recursion_stop:w
\else:
\cs_if_exist_use:cTF { @@_generate_variant_#1_form:nnn }
{ {#3} {#4} {#5} }
Expand All @@ -2745,7 +2774,7 @@
{#1} { \token_to_str:c { #3 : #4 } }
}
\fi:
\@@_generate_variant:w #2 \q_mark {#3} {#4} {#5}
\@@_generate_variant:w #2 \s_@@_mark {#3} {#4} {#5}
}
\cs_new_protected:Npn \@@_generate_variant_p_form:nnn #1#2
{ \cs_generate_variant:cn { #1 _p : #2 } }
Expand Down

0 comments on commit 603f539

Please sign in to comment.