diff options
author | Karl Berry <karl@freefriends.org> | 2015-09-06 23:19:17 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-09-06 23:19:17 +0000 |
commit | 3cb4e75696df6c7abebf17fbc606ca86dcdfb520 (patch) | |
tree | 729978e0726cdb9d9f34a3d2e249c71a82e07f97 /Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx | |
parent | 32f50b97c2ae44e93225d1024afab9727fc02e00 (diff) |
l3 (6sep15)
git-svn-id: svn://tug.org/texlive/trunk@38305 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx | 243 |
1 files changed, 139 insertions, 104 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx index 7ce1c6367b1..2cd25ed4616 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -%% File: l3fp-parse.dtx Copyright (C) 2011-2014 The LaTeX3 Project +%% File: l3fp-parse.dtx Copyright (C) 2011-2015 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 @@ -36,7 +36,7 @@ % %<*driver> \documentclass[full]{l3doc} -\GetIdInfo$Id: l3fp-parse.dtx 5383 2014-08-25 13:17:55Z bruno $ +\GetIdInfo$Id: l3fp-parse.dtx 5893 2015-08-26 16:16:52Z mittelba $ {L3 Floating-point expression parsing} \begin{document} \DocInput{\jobname.dtx} @@ -161,38 +161,38 @@ % already been found, and that we want to parse the next number. The % current status of the code may look as follows. % \begin{quote}\ttfamily -% \cs{exp_after:wN} \cs{add:ww} +% \cs{exp_after:wN} |\add:ww| % \cs{__int_value:w} 12345 \cs{exp_after:wN} ; \newline -% \cs{tex_romannumeral:D} |\operand:w| \meta{stuff} +% \cs{exp:w} |\operand:w| \meta{stuff} % \end{quote} % One step of expansion expands \cs{exp_after:wN}, which triggers the % primitive \cs{__int_value:w}, which reads the five digits we have % already found, |12345|. This integer is unfinished, causing the % second \cs{exp_after:wN} to expand, and to trigger the construction -% \cs{tex_romannumeral:D}, which expands |\operand:w|, defined to read +% \cs{exp:w}, which expands |\operand:w|, defined to read % what follows and make a number out of it, then leave \cs{c_zero}, the % number, and a semicolon in the input stream. Once |\operand:w| is % done expanding, we obtain essentially % \begin{quote}\ttfamily -% \cs{exp_after:wN} \cs{add:ww} \cs{__int_value:w} 12345 ; \newline -% \cs{tex_romannumeral:D} \cs{c_zero} 333444 ; +% \cs{exp_after:wN} |\add:ww| \cs{__int_value:w} 12345 ; \newline +% \cs{exp:w} \cs{c_zero} 333444 ; % \end{quote} % where in fact \cs{exp_after:wN} has already been expanded, % \cs{__int_value:w} has already seen |12345|, and -% \cs{tex_romannumeral:D} is still looking for a number. It finds +% \cs{exp:w} is still looking for a number. It finds % \cs{c_zero}, hence expands to nothing. Now, \cs{__int_value:w} sees % the \texttt{;}, which cannot be part of a number. The expansion % stops, and we are left with % \begin{quote}\ttfamily -% \cs{add:ww} 12345 ; 333444 ; +% |\add:ww| 12345 ; 333444 ; % \end{quote} % which can safely perform the addition by grabbing two arguments % delimited by~|;|. % % If we were to continue parsing the expression, then the following % number should also be cleaned up before the next use of a binary -% operation such as \cs{add:ww}. Just like \cs{__int_value:w} |12345| -% \cs{exp_after:wN}~|;| expanded what follows once, we need \cs{add:ww} +% operation such as |\add:ww|. Just like \cs{__int_value:w} |12345| +% \cs{exp_after:wN}~|;| expanded what follows once, we need |\add:ww| % to do the calculation, and in the process to expand the following % once. This is also true in our real application: all the functions of % the form \cs{@@_..._o:ww} expand what follows once. This comes at the @@ -311,7 +311,7 @@ % \begin{quote} % \cs{exp_after:wN} \cs{@@_parse_continue:NwN} \newline % \cs{exp_after:wN} \meta{precedence} \newline -% \cs{tex_romannumeral:D} |-`0| \newline +% \cs{exp:w} \cs{exp_end_continue_f:w} \newline % ~~\cs{@@_parse_one:Nw} \meta{precedence} % \end{quote} % This expands \cs{@@_parse_one:Nw} \meta{precedence} completely, which @@ -354,9 +354,9 @@ % \begin{quote} % \cs{exp_after:wN} \cs{@@_parse_continue:NwN} \newline % \cs{exp_after:wN} \meta{precedence} \newline -% \cs{tex_romannumeral:D} |-`0| \newline +% \cs{exp:w} \cs{exp_end_continue_f:w} \newline % |\__fp_|\meta{operator}|_o:ww| \meta{number} \meta{number_2} \newline -% \cs{tex_romannumeral:D} |-`0| \newline +% \cs{exp:w} \cs{exp_end_continue_f:w} \newline % |\__fp_parse_infix_|\meta{operator_2}|:N| \meta{precedence} % \end{quote} % where |\__fp_|\meta{operator}|_o:ww| computes \meta{number} @@ -545,7 +545,7 @@ % % \begin{macro}[rEXP, aux]{\@@_parse_operand:Nw} % \begin{syntax} -% \cs{tex_romannumeral:D} \cs{@@_parse_operand:Nw} \meta{precedence} \cs{@@_parse_expand:w} +% \cs{exp:w} \cs{@@_parse_operand:Nw} \meta{precedence} \cs{@@_parse_expand:w} % \end{syntax} % Reads the \enquote{\ttfamily\ldots{}}, performing every computation % with a precedence higher than \meta{precedence}, then expands to @@ -597,14 +597,14 @@ % % \begin{macro}[aux, rEXP]{\@@_parse_expand:w} % \begin{syntax} -% \cs{tex_romannumeral:D} \cs{@@_parse_expand:w} \meta{tokens} +% \cs{exp:w} \cs{@@_parse_expand:w} \meta{tokens} % \end{syntax} -% This function must always come within a \tn{romannumeral} expansion. +% This function must always come within a \cs{exp:w} expansion. % The \meta{tokens} should be the part of the expression that we have % not yet read. This requires in particular closing all conditionals % properly before expanding. % \begin{macrocode} -\cs_new:Npn \@@_parse_expand:w #1 { -`0 #1 } +\cs_new:Npn \@@_parse_expand:w #1 { \exp_end_continue_f:w #1 } % \end{macrocode} % \end{macro} % @@ -652,7 +652,8 @@ % \@@_parse_digits_iv:N , % \@@_parse_digits_iii:N , % \@@_parse_digits_ii:N , -% \@@_parse_digits_i:N +% \@@_parse_digits_i:N , +% \@@_parse_digits_:N % } % These functions must be called within an \cs{__int_value:w} or % \cs{__int_eval:w} construction. The first token which follows must @@ -676,7 +677,7 @@ \cs_new:cpn { @@_parse_digits_ #1 :N } ##1 { \if_int_compare:w \c_nine < 1 \token_to_str:N ##1 \exp_stop_f: - \token_to_str:N ##1 \exp_after:wN #2 \tex_romannumeral:D + \token_to_str:N ##1 \exp_after:wN #2 \exp:w \else: \@@_parse_return_semicolon:w #3 ##1 \fi: @@ -698,19 +699,22 @@ % % \begin{macro}[aux, EXP]{\@@_parse_one:Nw} % This function finds one number, and packs the symbol which follows -% in an \cs{infix_} csname. |#1|~is the previous \meta{precedence}, +% in an |\..._infix_...| csname. |#1|~is the previous \meta{precedence}, % and |#2|~the first token of the operand. We distinguish four cases: % |#2|~is equal to \cs{scan_stop:} in meaning, |#2|~is a different % control sequence, |#2|~is a digit, and |#2|~is something else (this -% last case will be split further. Despite the earlier +% last case will be split further). Despite the earlier % \texttt{f}-expansion, |#2|~may still be expandable if it was -% protected by \cs{exp_not:N}, as happens with the \LaTeXe{} command -% \tn{protect}. Testing if |#2|~is a control sequence thus includes -% \cs{exp_not:N}. +% protected by \cs{exp_not:N}, as may happen with the \LaTeXe{} command +% \tn{protect}. Using a well placed \cs{reverse_if:N}, this case is +% sent to \cs{@@_parse_one_fp:NN} which deals with it robustly. % \begin{macrocode} \cs_new:Npn \@@_parse_one:Nw #1 #2 { \if_catcode:w \scan_stop: \exp_not:N #2 + \exp_after:wN \if_meaning:w \exp_not:N #2 #2 \else: + \exp_after:wN \reverse_if:N + \fi: \if_meaning:w \scan_stop: #2 \exp_after:wN \exp_after:wN \exp_after:wN \@@_parse_one_fp:NN @@ -756,26 +760,50 @@ % defining |\__fp_exp_after_|\meta{type}|_f:nw|. In all cases, we % make sure that the second argument of \cs{@@_parse_infix:NN} is % correctly expanded. +% A special case only enabled in \LaTeXe{} is that if \tn{protect} is +% encountered then the error message mentions the control sequence +% which follows it rather than \tn{protect} itself. The test for +% \LaTeXe{} uses \tn{@unexpandable@protect} rather than \tn{protect} +% because \tn{protect} is often \cs{scan_stop:} hence \enquote{does +% not exist}. % \begin{macrocode} \cs_new:Npn \@@_parse_one_fp:NN #1#2 { \cs:w @@_exp_after \@@_type_from_scan:N #2 _f:nw \cs_end: { \exp_after:wN \@@_parse_infix:NN - \exp_after:wN #1 \tex_romannumeral:D \@@_parse_expand:w + \exp_after:wN #1 \exp:w \@@_parse_expand:w } #2 } \cs_new:Npn \@@_exp_after_mark_f:nw #1 { \__msg_kernel_expandable_error:nn { kernel } { fp-early-end } - \exp_after:wN \c_nan_fp \tex_romannumeral:D -`0 #1 + \exp_after:wN \c_nan_fp \exp:w \exp_end_continue_f:w #1 } \cs_new:cpn { @@_exp_after_?_f:nw } #1#2 { \__msg_kernel_expandable_error:nnn { kernel } { bad-variable } {#2} - \exp_after:wN \c_nan_fp \tex_romannumeral:D -`0 #1 + \exp_after:wN \c_nan_fp \exp:w \exp_end_continue_f:w #1 } +%<*package> +\group_begin: + \char_set_catcode_letter:N \@ + \cs_if_exist:NT \@unexpandable@protect + { + \cs_gset:cpn { @@_exp_after_?_f:nw } #1#2 + { + \exp_after:wN \c_nan_fp \exp:w \exp_end_continue_f:w #1 + \str_if_eq:nnTF {#2} { \protect } + { + \cs_if_eq:NNTF #2 \@unexpandable@protect { \use_i:nn } { \use:n } + { \__msg_kernel_expandable_error:nnn { kernel } { fp-robust-cmd } } + } + { \__msg_kernel_expandable_error:nnn { kernel } { bad-variable } {#2} } + } + } +\group_end: +%</package> % \end{macrocode} % \end{macro} % @@ -808,12 +836,12 @@ { \exp_after:wN \@@_parse_infix_after_operand:NwN \exp_after:wN #1 - \tex_romannumeral:D -`0 + \exp:w \exp_end_continue_f:w \exp_after:wN \@@_parse_one_register_aux:Nw \exp_after:wN #2 \__int_value:w \exp_after:wN \@@_parse_exponent:N - \tex_romannumeral:D \@@_parse_expand:w + \exp:w \@@_parse_expand:w } \group_begin: \char_set_catcode_other:N \P @@ -827,7 +855,7 @@ { \exp_after:wN \use:nn \exp_after:wN \@@_parse_one_register_auxii:wwwNw - \exp_after:wN { \tex_the:D \exp_not:N #1 } + \exp_after:wN { \tex_the:D #1 } ; \@@_parse_one_register_dim:ww PT ; \@@_parse_one_register_mu:www . PT ; \@@_parse_one_register_int:www @@ -862,7 +890,7 @@ { \exp_after:wN \@@_parse_infix_after_operand:NwN \exp_after:wN #1 - \tex_romannumeral:D -`0 + \exp:w \exp_end_continue_f:w \exp_after:wN \@@_sanitize:wN \int_use:N \__int_eval:w \c_zero \@@_parse_trim_zeros:N } @@ -885,8 +913,8 @@ \exp_after:wN \@@_parse_word:Nw \exp_after:wN #1 \exp_after:wN #2 - \tex_romannumeral:D \exp_after:wN \@@_parse_letters:N - \tex_romannumeral:D + \exp:w \exp_after:wN \@@_parse_letters:N + \exp:w \else: \exp_after:wN \@@_parse_prefix:NNN \exp_after:wN #1 @@ -895,7 +923,7 @@ @@_parse_prefix_ \token_to_str:N #2 :Nw \exp_after:wN \cs_end: - \tex_romannumeral:D + \exp:w \fi: \@@_parse_expand:w } @@ -919,14 +947,14 @@ { \__msg_kernel_expandable_error:nnn { kernel } { unknown-fp-word } {#2} - \exp_after:wN \c_nan_fp \tex_romannumeral:D -`0 + \exp_after:wN \c_nan_fp \exp:w \exp_end_continue_f:w \@@_parse_infix:NN } #1 } \cs_new:Npn \@@_parse_letters:N #1 { - -`0 + \exp_end_continue_f:w \if_int_compare:w \if_catcode:w \scan_stop: \exp_not:N #1 \c_zero @@ -937,8 +965,8 @@ \fi: = \c_three \exp_after:wN #1 - \tex_romannumeral:D \exp_after:wN \@@_parse_letters:N - \tex_romannumeral:D + \exp:w \exp_after:wN \@@_parse_letters:N + \exp:w \else: \@@_parse_return_semicolon:w #1 \fi: @@ -974,7 +1002,7 @@ { \__msg_kernel_expandable_error:nnn { kernel } { fp-missing-number } {#1} - \exp_after:wN \c_nan_fp \tex_romannumeral:D -`0 + \exp_after:wN \c_nan_fp \exp:w \exp_end_continue_f:w \@@_parse_infix:NN #3 #1 } { @@ -1009,11 +1037,11 @@ { \if:w 0 \exp_not:N #1 \exp_after:wN \@@_parse_trim_zeros:N - \tex_romannumeral:D + \exp:w \else: \if:w . \exp_not:N #1 \exp_after:wN \@@_parse_strim_zeros:N - \tex_romannumeral:D + \exp:w \else: \@@_parse_trim_end:w #1 \fi: @@ -1048,7 +1076,7 @@ { \if:w 0 \exp_not:N #1 - \c_one - \exp_after:wN \@@_parse_strim_zeros:N \tex_romannumeral:D + \exp_after:wN \@@_parse_strim_zeros:N \exp:w \else: \@@_parse_strim_end:w #1 \fi: @@ -1103,7 +1131,7 @@ \exp_after:wN \@@_parse_small_leading:wwNN \__int_value:w 1 \exp_after:wN \@@_parse_digits_vii:N - \tex_romannumeral:D \@@_parse_expand:w + \exp:w \@@_parse_expand:w } % \end{macrocode} % \end{macro} @@ -1133,7 +1161,7 @@ \exp_after:wN \@@_parse_small_trailing:wwNN \__int_value:w 1 \exp_after:wN \@@_parse_digits_vi:N - \tex_romannumeral:D + \exp:w \else: 0000 0000 \@@_parse_exponent:Nw #4 \fi: @@ -1161,7 +1189,7 @@ \token_to_str:N #4 \exp_after:wN \@@_parse_small_round:NN \exp_after:wN #4 - \tex_romannumeral:D + \exp:w \else: 0 \@@_parse_exponent:Nw #4 \fi: @@ -1227,7 +1255,7 @@ \exp_after:wN \@@_parse_large_leading:wwNN \__int_value:w 1 \token_to_str:N #1 \exp_after:wN \@@_parse_digits_vii:N - \tex_romannumeral:D \@@_parse_expand:w + \exp:w \@@_parse_expand:w } % \end{macrocode} % \end{macro} @@ -1256,17 +1284,17 @@ \exp_after:wN \@@_parse_large_trailing:wwNN \__int_value:w 1 \token_to_str:N #4 \exp_after:wN \@@_parse_digits_vi:N - \tex_romannumeral:D + \exp:w \else: \if:w . \exp_not:N #4 \exp_after:wN \@@_parse_small_leading:wwNN \__int_value:w 1 \cs:w @@_parse_digits_ - \tex_romannumeral:D #3 + \__int_to_roman:w #3 :N \exp_after:wN \cs_end: - \tex_romannumeral:D + \exp:w \else: #2 \exp_after:wN \@@_parse_pack_trailing:NNNNNNww @@ -1306,7 +1334,7 @@ \int_use:N \__int_eval:w 1 #1 \token_to_str:N #4 \exp_after:wN \@@_parse_large_round:NN \exp_after:wN #4 - \tex_romannumeral:D + \exp:w \else: \exp_after:wN \@@_parse_pack_trailing:NNNNNNww \int_use:N \__int_eval:w \c_seven - #3 \exp_stop_f: @@ -1316,10 +1344,10 @@ \__int_value:w 1 \cs:w @@_parse_digits_ - \tex_romannumeral:D #3 + \__int_to_roman:w #3 :N \exp_after:wN \cs_end: - \tex_romannumeral:D + \exp:w \else: #2 0 \@@_parse_exponent:Nw #4 \fi: @@ -1347,10 +1375,10 @@ + \c_one \if:w 0 \token_to_str:N #1 \exp_after:wN \@@_parse_round_loop:N - \tex_romannumeral:D + \exp:w \else: \exp_after:wN \@@_parse_round_up:N - \tex_romannumeral:D + \exp:w \fi: \else: \@@_parse_return_semicolon:w \c_zero #1 @@ -1362,7 +1390,7 @@ \if_int_compare:w \c_nine < 1 \token_to_str:N #1 \exp_stop_f: + \c_one \exp_after:wN \@@_parse_round_up:N - \tex_romannumeral:D + \exp:w \else: \@@_parse_return_semicolon:w \c_one #1 \fi: @@ -1413,7 +1441,7 @@ \exp_after:wN \@@_parse_round_after:wN \int_use:N \__int_eval:w \c_zero * \__int_eval:w \c_zero \exp_after:wN \@@_parse_round_loop:N - \tex_romannumeral:D + \exp:w \else: \@@_parse_exponent:Nw #2 \fi: @@ -1465,7 +1493,7 @@ \if:w . \exp_not:N #2 \exp_after:wN \@@_parse_small_round:NN \exp_after:wN #1 - \tex_romannumeral:D + \exp:w \else: \@@_parse_exponent:Nw #2 \fi: @@ -1479,7 +1507,7 @@ \if:w . \exp_not:N #3 + \c_zero * \__int_eval:w \c_zero \exp_after:wN \@@_parse_round_loop:N - \tex_romannumeral:D \exp_after:wN \@@_parse_expand:w + \exp:w \exp_after:wN \@@_parse_expand:w \else: \exp_after:wN ; \exp_after:wN \c_zero @@ -1548,7 +1576,7 @@ { \if:w e \exp_not:N #1 \exp_after:wN \@@_parse_exponent_aux:N - \tex_romannumeral:D + \exp:w \else: 0 \@@_parse_return_semicolon:w #1 \fi: @@ -1574,7 +1602,7 @@ { \if:w + \if:w - \exp_not:N #1 + \fi: \token_to_str:N #1 \exp_after:wN \@@_parse_exponent_sign:N - \tex_romannumeral:D \exp_after:wN \@@_parse_expand:w + \exp:w \exp_after:wN \@@_parse_expand:w \else: \exp_after:wN \@@_parse_exponent_body:N \exp_after:wN #1 @@ -1592,13 +1620,13 @@ \if_int_compare:w \c_nine < 1 \token_to_str:N #1 \exp_stop_f: \token_to_str:N #1 \exp_after:wN \@@_parse_exponent_digits:N - \tex_romannumeral:D + \exp:w \else: \@@_parse_exponent_keep:NTF #1 { \@@_parse_return_semicolon:w #1 } { \exp_after:wN ; - \tex_romannumeral:D + \exp:w } \fi: \@@_parse_expand:w @@ -1619,7 +1647,7 @@ \if_int_compare:w \c_nine < 1 \token_to_str:N #1 \exp_stop_f: \token_to_str:N #1 \exp_after:wN \@@_parse_exponent_digits:N - \tex_romannumeral:D + \exp:w \else: \@@_parse_return_semicolon:w #1 \fi: @@ -1697,12 +1725,12 @@ % after the calculation, |#4| is the operand, and |#5| is a % |\__fp_parse_infix_...:N| function. We feed the data~|#2|, and the % argument~|#4|, to the function~|#3|, which expands -% \cs{tex_romannumeral:D} thus the \texttt{infix} function~|#5|. +% \cs{exp:w} thus the \texttt{infix} function~|#5|. % \begin{macrocode} \cs_new:Npn \@@_parse_apply_unary:NNNwN #1#2#3#4@#5 { #3 #2 #4 @ - \tex_romannumeral:D -`0 #5 #1 + \exp:w \exp_end_continue_f:w #5 #1 } % \end{macrocode} % \end{macro} @@ -1722,7 +1750,7 @@ \exp_after:wN ##1 \exp_after:wN #4 \exp_after:wN #3 - \tex_romannumeral:D + \exp:w \if_int_compare:w #2 < ##1 \@@_parse_operand:Nw ##1 \else: @@ -1748,7 +1776,7 @@ { \exp_after:wN \@@_parse_infix_after_operand:NwN \exp_after:wN #1 - \tex_romannumeral:D -`0 + \exp:w \exp_end_continue_f:w \exp_after:wN \@@_sanitize:wN \int_use:N \__int_eval:w \c_zero \@@_parse_strim_zeros:N } @@ -1774,7 +1802,7 @@ { \exp_after:wN \@@_parse_lparen_after:NwN \exp_after:wN #1 - \tex_romannumeral:D + \exp:w \if_int_compare:w #1 = \c_sixteen \@@_parse_operand:Nw \c_one \else: @@ -1789,7 +1817,7 @@ \@@_exp_after_array_f:w #2 \s_@@_stop \exp_after:wN \@@_parse_infix:NN \exp_after:wN #1 - \tex_romannumeral:D \@@_parse_expand:w + \exp:w \@@_parse_expand:w } { \__msg_kernel_expandable_error:nnn @@ -1816,7 +1844,7 @@ \cs_set_protected:Npn \@@_tmp:w #1 #2 { \cs_new_nopar:cpn { @@_parse_word_#1:N } - { \exp_after:wN #2 \tex_romannumeral:D -`0 \@@_parse_infix:NN } + { \exp_after:wN #2 \exp:w \exp_end_continue_f:w \@@_parse_infix:NN } } \@@_tmp:w { inf } \c_inf_fp \@@_tmp:w { nan } \c_nan_fp @@ -1871,7 +1899,7 @@ \exp_after:wN \@@_from_dim_test:ww \exp_after:wN 0 \exp_after:wN , \__int_value:w \__dim_eval:w 1 #1 \exp_after:wN ; - \tex_romannumeral:D -`0 \@@_parse_infix:NN + \exp:w \exp_end_continue_f:w \@@_parse_infix:NN } } % \end{macrocode} @@ -1895,7 +1923,7 @@ \exp_after:wN #3 \exp_after:wN #2 \cs:w @@_#1_o:w \exp_after:wN \cs_end: - \tex_romannumeral:D + \exp:w \@@_parse_operand:Nw \c_fifteen \@@_parse_expand:w } \cs_new:Npn \@@_parse_function:NNN #1#2#3 @@ -1904,7 +1932,7 @@ \exp_after:wN #3 \exp_after:wN #2 \exp_after:wN #1 - \tex_romannumeral:D + \exp:w \@@_parse_operand:Nw \c_sixteen \@@_parse_expand:w } % \end{macrocode} @@ -2037,7 +2065,7 @@ % % \begin{macro}[int, EXP]{\@@_parse:n} % \begin{macro}[aux, EXP]{\@@_parse_after:ww} -% Start a \tn{romannumeral} expansion so that \cs{@@_parse:n} expands +% Start an \cs{exp:w} expansion so that \cs{@@_parse:n} expands % in two steps. The \cs{@@_parse_operand:Nw} function will perform % computations until reaching an operation with precedence % \cs{c_minus_one} or less, namely, the end of the expression. The @@ -2045,13 +2073,13 @@ % parsed version of an infix operator, and \cs{@@_parse_infix_end:N} % has infinitely negative precedence. Finally, clean up a % (well-defined) set of extra tokens and stop the initial expansion -% with \cs{c_zero}. +% with \cs{exp_end:}. % \begin{macrocode} \cs_new:Npn \@@_parse:n #1 { - \tex_romannumeral:D + \exp:w \exp_after:wN \@@_parse_after:ww - \tex_romannumeral:D + \exp:w \@@_parse_operand:Nw \c_minus_one \@@_parse_expand:w #1 \s_@@_mark \@@_parse_infix_end:N @@ -2059,7 +2087,7 @@ } \cs_new:Npn \@@_parse_after:ww #1@ \@@_parse_infix_end:N \s_@@_stop - { \c_zero #1 } + { \exp_end: #1 } % \end{macrocode} % \end{macro} % \end{macro} @@ -2069,18 +2097,18 @@ % The \cs{@@_parse_operand} % This is just a shorthand which sets up both \cs{@@_parse_continue} % and \cs{@@_parse_one} with the same precedence. Note the -% trailing \cs{tex_romannumeral:D}. This function should be +% trailing \cs{exp:w}. This function should be % used with much care. % \begin{macrocode} \cs_new:Npn \@@_parse_operand:Nw #1 { - -`0 + \exp_end_continue_f:w \exp_after:wN \@@_parse_continue:NwN \exp_after:wN #1 - \tex_romannumeral:D -`0 + \exp:w \exp_end_continue_f:w \exp_after:wN \@@_parse_one:Nw \exp_after:wN #1 - \tex_romannumeral:D + \exp:w } \cs_new:Npn \@@_parse_continue:NwN #1 #2 @ #3 { #3 #1 #2 @ } % \end{macrocode} @@ -2096,8 +2124,8 @@ { \exp_after:wN \@@_parse_continue:NwN \exp_after:wN #1 - \tex_romannumeral:D -`0 \cs:w @@_#3_o:ww \cs_end: #2 #4 - \tex_romannumeral:D -`0 #5 #1 + \exp:w \exp_end_continue_f:w \cs:w @@_#3_o:ww \cs_end: #2 #4 + \exp:w \exp_end_continue_f:w #5 #1 } % \end{macrocode} % \end{macro} @@ -2155,7 +2183,7 @@ \else: \exp_after:wN #1 \exp_after:wN #2 - \tex_romannumeral:D \exp_after:wN \@@_parse_expand:w + \exp:w \exp_after:wN \@@_parse_expand:w \fi: } \group_end: @@ -2196,7 +2224,7 @@ \__msg_kernel_expandable_error:nnn { kernel } { fp-extra } { ) } \exp_after:wN \@@_parse_infix:NN \exp_after:wN #1 - \tex_romannumeral:D \exp_after:wN \@@_parse_expand:w + \exp:w \exp_after:wN \@@_parse_expand:w \else: \exp_after:wN @ \exp_after:wN \use_none:n @@ -2220,10 +2248,10 @@ \else: \if_int_compare:w #1 = \c_one \exp_after:wN \@@_parse_infix_comma:w - \tex_romannumeral:D + \exp:w \else: \exp_after:wN \@@_parse_infix_comma_gobble:w - \tex_romannumeral:D + \exp:w \fi: \@@_parse_operand:Nw \c_one \exp_after:wN \@@_parse_expand:w @@ -2250,7 +2278,7 @@ % } % \begin{macro}[aux, EXP]+\@@_parse_infix_^:N+ As described in the % \enquote{work plan}, each infix operator has an associated -% \cs{infix} function, a computing function, and precedence, given as +% |\..._infix_...| function, a computing function, and precedence, given as % arguments to \cs{@@_tmp:w}. Using the general mechanism for % arithmetic operations. The power operation must be associative in % the opposite order from all others. For this, we use two distinct @@ -2277,7 +2305,7 @@ \exp_after:wN @ \exp_after:wN \@@_parse_apply_binary:NwNwN \exp_after:wN #2 - \tex_romannumeral:D + \exp:w \@@_parse_operand:Nw #4 \exp_after:wN \@@_parse_expand:w \else: @@ -2326,7 +2354,7 @@ \if_int_compare:w #1 < \c_ten \exp_after:wN @ \exp_after:wN \@@_parse_apply_juxtapose:NwwN - \tex_romannumeral:D + \exp:w \@@_parse_operand:Nw \c_ten \exp_after:wN \@@_parse_expand:w \else: @@ -2381,7 +2409,7 @@ \if:w | \exp_not:N #2 \exp_after:wN \@@_parse_infix_|:N \exp_after:wN #1 - \tex_romannumeral:D \exp_after:wN \@@_parse_expand:w + \exp:w \exp_after:wN \@@_parse_expand:w \else: \exp_after:wN \@@_parse_infix_or:N \exp_after:wN #1 @@ -2393,7 +2421,7 @@ \if:w & \exp_not:N #2 \exp_after:wN \@@_parse_infix_&:N \exp_after:wN #1 - \tex_romannumeral:D \exp_after:wN \@@_parse_expand:w + \exp:w \exp_after:wN \@@_parse_expand:w \else: \exp_after:wN \@@_parse_infix_and:N \exp_after:wN #1 @@ -2416,7 +2444,7 @@ \if_int_compare:w #1 < \c_three \exp_after:wN @ \exp_after:wN \@@_ternary:NwwN - \tex_romannumeral:D + \exp:w \@@_parse_operand:Nw \c_three \exp_after:wN \@@_parse_expand:w \else: @@ -2432,7 +2460,7 @@ { kernel } { fp-missing } { ? } { ~for~?: } \exp_after:wN @ \exp_after:wN \@@_ternary_auxii:NwwN - \tex_romannumeral:D + \exp:w \@@_parse_operand:Nw \c_two \exp_after:wN \@@_parse_expand:w \else: @@ -2527,7 +2555,7 @@ \exp_after:wN #3 \exp_after:wN #4 \exp_after:wN #5 - \tex_romannumeral:D \exp_after:wN \@@_parse_expand:w + \exp:w \exp_after:wN \@@_parse_expand:w } \cs_new:Npn \@@_parse_compare_end:NNNNw #1#2#3#4#5 \fi: { @@ -2539,7 +2567,7 @@ \exp_after:wN #2 \exp_after:wN #3 \exp_after:wN #4 - \tex_romannumeral:D + \exp:w \@@_parse_operand:Nw \c_seven \@@_parse_expand:w #5 } \cs_new:Npn \@@_parse_apply_compare:NwNNNNNwN @@ -2567,15 +2595,15 @@ \exp_after:wN \@@_parse_continue_compare:NNwNN \exp_after:wN #1 \exp_after:wN #2 - \tex_romannumeral:D -`0 + \exp:w \exp_end_continue_f:w \@@_exp_after_o:w #3; - \tex_romannumeral:D -`0 + \exp:w \exp_end_continue_f:w \else: \exp_after:wN \@@_parse_continue:NwN \exp_after:wN #2 - \tex_romannumeral:D -`0 + \exp:w \exp_end_continue_f:w \exp_after:wN #1 - \tex_romannumeral:D -`0 + \exp:w \exp_end_continue_f:w \fi: #4 #2 } @@ -2596,7 +2624,7 @@ { \exp_after:wN \@@_function_apply:nw \exp_after:wN #1 - \tex_romannumeral:D + \exp:w \@@_parse_operand:Nw \c_sixteen \@@_parse_expand:w } % \end{macrocode} @@ -2632,7 +2660,7 @@ \exp_after:wN #2 \__int_value:w #3 \exp_after:wN ; \exp_after:wN } - \tex_romannumeral:D + \exp:w \@@_parse_operand:Nw \c_sixteen \@@_parse_expand:w } \cs_new:Npn #2 #4 {#5} @@ -2715,6 +2743,13 @@ { Unexpected~comma:~extra~arguments~ignored. } \__msg_kernel_new:nnn { kernel } { fp-num-args } { #1~expects~between~#2~and~#3~arguments. } +%<*package> +\cs_if_exist:cT { @unexpandable@protect } + { + \__msg_kernel_new:nnn { kernel } { fp-robust-cmd } + { Robust~command~#1 invalid~in~fp~expression! } + } +%</package> % \end{macrocode} % % \begin{macrocode} |