diff options
author | Karl Berry <karl@freefriends.org> | 2012-08-31 17:58:55 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-08-31 17:58:55 +0000 |
commit | 3301423440393adfdbbcfa0d8471e4b4c63df1e6 (patch) | |
tree | 6aa86f66a252f654a2bd2f28ee7b680fdac1b0a3 /Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx | |
parent | a511edd7e6a05e250f2b2d8062a470734e3af33d (diff) |
l3kernel 3160 (31aug12)
git-svn-id: svn://tug.org/texlive/trunk@27559 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 | 115 |
1 files changed, 60 insertions, 55 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-parse.dtx index f74c2cf0a92..bb9c792adff 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> \RequirePackage{l3bootstrap} -\GetIdInfo$Id: l3fp-parse.dtx 4081 2012-08-12 11:06:18Z bruno $ +\GetIdInfo$Id: l3fp-parse.dtx 4159 2012-08-29 13:21:59Z bruno $ {L3 Floating-point expression parsing} \documentclass[full]{l3doc} \begin{document} @@ -119,7 +119,6 @@ % \item[-1] Start and end of the expression. % \end{itemize} % -% ^^A todo: change 'mantissa' => 'significand' everywhere. % ^^A todo: ask SO when sNaN can arise. % % \section{Evaluating an expression} @@ -754,7 +753,7 @@ % %^^A end[todo] % -% \begin{macro}[rEXP, aux]{\@@_parse_expand:w} +% \begin{macro}[aux, rEXP]{\@@_parse_expand:w} % \begin{syntax} % \cs{tex_romannumeral:D} \cs{@@_parse_expand:w} \meta{tokens} % \end{syntax} @@ -767,7 +766,7 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[EXP, aux]{\@@_parse_return_semicolon:w} +% \begin{macro}[aux, EXP]{\@@_parse_return_semicolon:w} % This very odd function swaps its position with the following % \cs{fi:} and removes \cs{@@_parse_expand:w} normally responsible for % expansion. That turns out to be useful. @@ -779,13 +778,13 @@ % % \subsection{Fp object type} % -% \begin{macro}[EXP, int]{\@@_type_from_scan:N} +% \begin{macro}[aux, EXP]{\@@_type_from_scan:N, \@@_type_from_scan:w} % \begin{syntax} % \cs{@@_type_from_scan:N} \meta{token} % \end{syntax} % Grabs the pieces of the stringified \meta{token} which lies after % the first |s__fp|. If the \meta{token} does not contain that -% string, the result is empty. +% string, the result is |_?|. % \begin{macrocode} \group_begin: \char_set_catcode_other:N \S @@ -798,7 +797,7 @@ \cs_new:Npn \@@_type_from_scan:N #1 { \exp_after:wN \@@_type_from_scan:w - \token_to_str:N #1 \q_mark S--FP \q_mark \q_stop + \token_to_str:N #1 \q_mark S--FP-? \q_mark \q_stop } \cs_new:Npn \@@_type_from_scan:w #1 S--FP #2 \q_mark #3 \q_stop {#2} } @@ -955,47 +954,50 @@ % \end{macro} % % \begin{macro}[aux, EXP] -% {\@@_parse_operand_relax:NN, \@@_parse_operand_relax_aux:wwnw} The -% argument is a token equal to \cs{tex_relax:D}. This can be -% \cs{s_@@}, \cs{s_@@_mark}, or a badly initialized register. We make -% sure that the last argument of \cs{@@_parse_infix:NN} is +% { +% \@@_parse_operand_relax:NN, +% \@@_exp_after_mark_f:nw, +% \@@_exp_after_?_f:nw +% } +% The second argument is a control sequence equal to \cs{tex_relax:D}. +% There are three cases, dispatched using \cs{@@_type_from_scan:N}. +% \begin{itemize} +% \item \cs{s_@@} starts a floating point number, and we call +% \cs{@@_exp_after_f:nw}. +% \item \cs{s_@@_mark} is a premature end, we call +% \cs{@@_exp_after_mark_f:nw}, which triggers the appropriate +% error. +% \item For a control sequence not containing |\s__fp|, we call +% \cs{@@_exp_after_?_f:nw}, causing a |bad-variable| error. +% \end{itemize} +% This scheme is extensible: additional types can be added by starting +% the variables with a scan mark of the form |\s__fp_|\meta{type} and +% defining |\__fp_exp_after_|\meta{type}|_f:nw|. In all cases, we +% make sure that the last argument of \cs{@@_parse_infix:NN} is % correctly expanded. % \begin{macrocode} \cs_new:Npn \@@_parse_operand_relax:NN #1#2 { - \@@_parse_operand_relax_aux:wwnw - #2 \s_@@_mark - { - \@@_exp_after_o:nw - { - \tex_romannumeral:D -`0 - \exp_after:wN \@@_parse_infix:NN - \exp_after:wN #1 \tex_romannumeral:D \@@_parse_expand:w - } - \s_@@ - } - \s_@@ #2 - { - \__msg_kernel_expandable_error:nn { kernel } { fp-early-end } - \exp_after:wN \c_nan_fp - \tex_romannumeral:D -`0 - \@@_parse_infix:NN #1 - \s_@@_mark - } - \s_@@_mark - { - \__msg_kernel_expandable_error:nnn - { kernel } { bad-variable } {#2} - \exp_after:wN \c_nan_fp - \tex_romannumeral:D -`0 - \exp_after:wN \@@_parse_infix:NN - \exp_after:wN #1 - \tex_romannumeral:D \@@_parse_expand:w - } - \s_@@_mark \s_@@_stop - } -\cs_new:Npn \@@_parse_operand_relax_aux:wwnw - #1 \s_@@ #2 \s_@@_mark #3 #4 \s_@@_mark \s_@@_stop { #3 } + \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 + } + #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 + } +\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 + } % \end{macrocode} % \end{macro} % @@ -1356,9 +1358,9 @@ % shift as its first argument, which we add to the exponent found in % the |e...| syntax. If the trailing digits cause a carry, the % integer expression for the leading digits is incremented (|+ \c_one| -% in the code below). If the leading digits propagte this carry all +% in the code below). If the leading digits propagate this carry all % the way up, the function \cs{@@_parse_pack_carry:w} increments the -% exponent, and changes the mantissa from |0000...| to |1000...|: this +% exponent, and changes the significand from |0000...| to |1000...|: this % is simple because such a carry can only occur to give rise to a % power of $10$. % \begin{macrocode} @@ -1998,8 +2000,9 @@ \cs:w @@ \@@_type_from_scan:N #2 + _ #4 \@@_type_from_scan:N #5 - _ #4 _o:ww + _o:ww \cs_end: #2#3 #5#6 \tex_romannumeral:D -`0 #7 #1 @@ -2092,15 +2095,18 @@ % \@@_parse_word_abs:N , % \@@_parse_word_cos:N , % \@@_parse_word_cot:N , +% \@@_parse_word_csc:N , % \@@_parse_word_exp:N , % \@@_parse_word_ln:N , +% \@@_parse_word_sec:N , % \@@_parse_word_sin:N , % \@@_parse_word_tan:N , % } % Unary functions, which are applied to all of their arguments when % receiving an array. % \begin{macrocode} -\tl_map_inline:nn { {abs} {cos} {cot} {exp} {ln} {sin} {tan} } +\tl_map_inline:nn + { {abs} {cos} {cot} {csc} {exp} {ln} {sec} {sin} {tan} } { \cs_new:cpn { @@_parse_word_#1:N } ##1 { @@ -2234,7 +2240,7 @@ { \token_if_eq_meaning:NNTF #3 \@@_parse_infix_):N { - \@@_parse_exp_after_array:wf #2 \s_@@_stop + \@@_exp_after_array_f:w #2 \s_@@_stop \exp_after:wN \@@_parse_infix:NN \exp_after:wN #1 \tex_romannumeral:D \@@_parse_expand:w @@ -2248,16 +2254,15 @@ % \end{macrocode} % \end{macro} % -%^^A todo: rename to exp_after_array_f:w -% \begin{macro}[int, EXP]{\@@_parse_exp_after_array:wf} +% \begin{macro}[int, EXP]{\@@_exp_after_array_f:w} % \begin{macrocode} -\cs_new:Npn \@@_parse_exp_after_array:wf #1 +\cs_new:Npn \@@_exp_after_array_f:w #1 { - \cs:w @@ \@@_type_from_scan:N #1 _exp_after_f:nw \cs_end: - { \@@_parse_exp_after_array:wf } + \cs:w @@_exp_after \@@_type_from_scan:N #1 _f:nw \cs_end: + { \@@_exp_after_array_f:w } #1 } -\cs_new:Npn \@@_stop_exp_after_f:nw #1#2 { } +\cs_new:Npn \@@_exp_after_stop_f:nw #1#2 { } % \end{macrocode} % \end{macro} % |