diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx | 64 |
1 files changed, 60 insertions, 4 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx index d3dbf085569..339595c6d2e 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx @@ -36,7 +36,7 @@ % %<*driver> \documentclass[full]{l3doc} -\GetIdInfo$Id: l3fp-parse.dtx 6685 2016-08-19 16:26:52Z bruno $ +\GetIdInfo$Id: l3fp-parse.dtx 6750 2016-11-21 01:24:26Z bruno $ {L3 Floating-point expression parsing} \begin{document} \DocInput{\jobname.dtx} @@ -91,6 +91,8 @@ % in the input stream as an internal floating point number. This % function forms the basis of almost all public \pkg{l3fp} functions. % During evaluation, each token is fully \texttt{f}-expanded. +% +% \cs{@@_parse_o:n} does the same but expands once after its result. % \begin{texnote} % Registers (integers, toks, etc.) are automatically unpacked, % without requiring a function such as \cs{int_use:N}. Invalid @@ -821,7 +823,7 @@ % integer registers from dimensions/skips from muskips, according to % the presence of a period and/or of |pt|. For integers, simply % convert \meta{value}|e|\meta{exponent} to a floating point number -% with \cs{fp_parse:n} (this is somewhat wasteful). For other +% with \cs{@@_parse:n} (this is somewhat wasteful). For other % registers, the decimal rounding provided by \TeX{} does not % accurately represent the binary value that it manipulates, so we % extract this binary value as a number of scaled points with @@ -1783,8 +1785,8 @@ % {\@@_parse_prefix_(:Nw, \@@_parse_lparen_after:NwN} % The left parenthesis is treated as a unary prefix operator because % it appears in exactly the same settings. Commas will be allowed if -% the previous precedence is $16$ (function with multiple arguments) -% or $13$ (unary boolean \enquote{not}). In this case, find an +% the previous precedence is $16$ (function with multiple arguments). +% In this case, find an % operand using the precedence~$1$; otherwise the precedence~$0$. % Once the operand is found, the \texttt{lparen_after} auxiliary makes % sure that there was a closing parenthesis (otherwise it complains), @@ -1825,6 +1827,42 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}[aux, EXP, verb]{\@@_parse_prefix_,:Nw} +% \begin{macro}[aux, EXP]{\@@_parse_prefix_):Nw} +% The right parenthesis and the comma can appear as unary prefixes +% when an argument of a multi-argument function is missing (for +% instance the first and last ones in |max(,1,2,)| or in |rand()|). +% In single-argument functions (precedence~$0$ rather than~$1$) forbid +% this. +% \begin{macrocode} +\cs_new:cpn { @@_parse_prefix_,:Nw } #1 + { + \if_int_compare:w #1 = \c_one + \exp_after:wN \@@_parse_one:Nw + \exp_after:wN #1 + \else: + \__msg_kernel_expandable_error:nnn + { kernel } { fp-missing-number } { , } + \exp_after:wN \c_nan_fp \exp:w \exp_end_continue_f:w + \exp_after:wN \@@_parse_infix:NN + \exp_after:wN #1 + \exp_after:wN , + \fi: + } +\cs_new:cpn { @@_parse_prefix_):Nw } #1 + { + \if_int_compare:w #1 = \c_one + \else: + \__msg_kernel_expandable_error:nnn + { kernel } { fp-missing-number } { ) } + \exp_after:wN \c_nan_fp \exp:w \exp_end_continue_f:w + \fi: + \@@_parse_infix:NN #1 ) + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% % \subsubsection{Constants} % % \begin{macro}[aux, EXP] @@ -1939,9 +1977,11 @@ % \@@_parse_word_acot:N , \@@_parse_word_acotd:N, % \@@_parse_word_atan:N , \@@_parse_word_atand:N, % \@@_parse_word_max:N , \@@_parse_word_min:N , +% \@@_parse_word_rand:N , \@@_parse_word_randint:N, % } % Those functions are also unary (not binary), but may receive a % variable number of arguments. +% For |randint| we don't use the first argument~|?|. % \begin{macrocode} \cs_new:Npn \@@_parse_word_acot:N { \@@_parse_function:NNN \@@_acot_o:Nw \use_i:nn } @@ -1955,6 +1995,10 @@ { \@@_parse_function:NNN \@@_minmax_o:Nw 2 } \cs_new:Npn \@@_parse_word_min:N { \@@_parse_function:NNN \@@_minmax_o:Nw 0 } +\cs_new:Npn \@@_parse_word_rand:N + { \@@_parse_function:NNN \@@_rand_o:Nw ? } +\cs_new:Npn \@@_parse_word_randint:N + { \@@_parse_function:NNN \@@_randint_o:Nw ? } % \end{macrocode} % \end{macro} % @@ -2088,6 +2132,18 @@ % \end{macro} % \end{macro} % +% \begin{macro}[int, EXP]{\@@_parse_o:n} +% ^^A todo: optimize, comment, make it work for arrays. +% \begin{macrocode} +\cs_new:Npn \@@_parse_o:n #1 + { + \exp_after:wN \exp_after:wN + \exp_after:wN \@@_exp_after_o:w + \@@_parse:n {#1} + } +% \end{macrocode} +% \end{macro} +% % \begin{macro}[aux, EXP]{\@@_parse_operand:Nw} % \begin{macro}[aux, EXP]{\@@_parse_continue:NwN} % The \cs{@@_parse_operand} |