[latex3-commits] [git/LaTeX3-latex3-latex3] master: Fixed precedence of juxtaposition in l3fp to make 3cm/1cm=3 (c333896)

Bruno Le Floch bruno at le-floch.fr
Thu May 23 10:25:06 CEST 2019


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/c3338963191fc8aa9cb2ad32a3ef4df8f1a4f562

>---------------------------------------------------------------

commit c3338963191fc8aa9cb2ad32a3ef4df8f1a4f562
Author: Bruno Le Floch <bruno at le-floch.fr>
Date:   Thu May 23 10:25:06 2019 +0200

    Fixed precedence of juxtaposition in l3fp to make 3cm/1cm=3


>---------------------------------------------------------------

c3338963191fc8aa9cb2ad32a3ef4df8f1a4f562
 l3kernel/CHANGELOG.md                   |    4 ++++
 l3kernel/l3fp-parse.dtx                 |   16 +++++++++++-----
 l3kernel/l3fp.dtx                       |    8 +++++---
 l3kernel/testfiles/m3expl001.luatex.tlg |    2 ++
 l3kernel/testfiles/m3expl001.ptex.tlg   |    2 ++
 l3kernel/testfiles/m3expl001.tlg        |    2 ++
 l3kernel/testfiles/m3expl001.uptex.tlg  |    2 ++
 l3kernel/testfiles/m3expl001.xetex.tlg  |    2 ++
 l3kernel/testfiles/m3expl003.luatex.tlg |    2 ++
 l3kernel/testfiles/m3expl003.ptex.tlg   |    2 ++
 l3kernel/testfiles/m3expl003.tlg        |    2 ++
 l3kernel/testfiles/m3expl003.uptex.tlg  |    2 ++
 l3kernel/testfiles/m3expl003.xetex.tlg  |    2 ++
 l3kernel/testfiles/m3fp-parse001.tlg    |    2 +-
 l3kernel/testfiles/m3fp-parse002.tlg    |    2 +-
 15 files changed, 42 insertions(+), 10 deletions(-)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 1f98fc6..e243dfe 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -11,6 +11,10 @@ this project uses date-based 'snapshot' version identifiers.
 
 - Experimental `\file_timestamp_compare:nNn(TF)`
 
+### Fixed
+
+- Precedence of juxtaposition (implicit multiplication) in l3fp
+
 ## [2019-05-09]
 
 ### Added
diff --git a/l3kernel/l3fp-parse.dtx b/l3kernel/l3fp-parse.dtx
index 15227cc..f3c14b0 100644
--- a/l3kernel/l3fp-parse.dtx
+++ b/l3kernel/l3fp-parse.dtx
@@ -96,6 +96,7 @@
 %     \c_@@_prec_hatii_int,
 %     \c_@@_prec_hat_int,
 %     \c_@@_prec_not_int,
+%     \c_@@_prec_juxt_int,
 %     \c_@@_prec_times_int,
 %     \c_@@_prec_plus_int,
 %     \c_@@_prec_comp_int,
@@ -118,7 +119,8 @@
 %     \item[16] Function calls.
 %     \item[13/14] Binary |**| and~|^| (right to left).
 %     \item[12] Unary |+|, |-|, |!| (right to left).
-%     \item[10] Binary |*|, |/|, and juxtaposition (implicit~|*|).
+%     \item[11] Juxtaposition (implicit~|*|).
+%     \item[10] Binary |*| and~|/|.
 %     \item[9] Binary |+| and~|-|.
 %     \item[7] Comparisons.
 %     \item[6] Logical \texttt{and}, denoted by~|&&|.
@@ -134,6 +136,7 @@
 \int_const:Nn \c_@@_prec_hatii_int  { 14 }
 \int_const:Nn \c_@@_prec_hat_int    { 13 }
 \int_const:Nn \c_@@_prec_not_int    { 12 }
+\int_const:Nn \c_@@_prec_juxt_int   { 11 }
 \int_const:Nn \c_@@_prec_times_int  { 10 }
 \int_const:Nn \c_@@_prec_plus_int   { 9 }
 \int_const:Nn \c_@@_prec_comp_int   { 7 }
@@ -2268,7 +2271,7 @@
         \exp_after:wN \@@_parse_infix_mark:NNN
       \else:
         \exp_after:wN \exp_after:wN
-        \exp_after:wN \@@_parse_infix_mul:N
+        \exp_after:wN \@@_parse_infix_juxt:N
       \fi:
     \else:
       \if_int_compare:w
@@ -2276,7 +2279,7 @@
             ( `#2 \if_int_compare:w `#2 > `Z - 32 \fi: ) / 26
           = 3 \exp_stop_f:
         \exp_after:wN \exp_after:wN
-        \exp_after:wN \@@_parse_infix_mul:N
+        \exp_after:wN \@@_parse_infix_juxt:N
       \else:
         \exp_after:wN \@@_parse_infix_check:NNN
         \cs:w
@@ -2411,6 +2414,7 @@
 % \begin{macro}[EXP]
 %   {
 %     \@@_parse_infix_+:N, \@@_parse_infix_-:N,
+%     \@@_parse_infix_juxt:N,
 %     \@@_parse_infix_/:N, \@@_parse_infix_mul:N,
 %     \@@_parse_infix_and:N, \@@_parse_infix_or:N,
 %   }
@@ -2442,6 +2446,8 @@
   }
 \exp_args:Nc \@@_tmp:w { @@_parse_infix_^:N }   ^
   \c_@@_prec_hatii_int \c_@@_prec_hat_int
+\exp_args:Nc \@@_tmp:w { @@_parse_infix_juxt:N } *
+  \c_@@_prec_juxt_int \c_@@_prec_juxt_int
 \exp_args:Nc \@@_tmp:w { @@_parse_infix_/:N }   /
   \c_@@_prec_times_int \c_@@_prec_times_int
 \exp_args:Nc \@@_tmp:w { @@_parse_infix_mul:N } *
@@ -2463,10 +2469,10 @@
 % \begin{macro}[EXP]+\@@_parse_infix_(:N+
 %   When an opening parenthesis appears where we expect an infix
 %   operator, we compute the product of the previous operand and the
-%   contents of the parentheses using \cs{@@_parse_infix_mul:N}.
+%   contents of the parentheses using \cs{@@_parse_infix_juxt:N}.
 %    \begin{macrocode}
 \cs_new:cpn { @@_parse_infix_(:N } #1
-  { \@@_parse_infix_mul:N #1 ( }
+  { \@@_parse_infix_juxt:N #1 ( }
 %    \end{macrocode}
 % \end{macro}
 %
diff --git a/l3kernel/l3fp.dtx b/l3kernel/l3fp.dtx
index 1893a78..d74cc5b 100644
--- a/l3kernel/l3fp.dtx
+++ b/l3kernel/l3fp.dtx
@@ -858,8 +858,9 @@
 %   \item Function calls (\texttt{sin}, \texttt{ln}, \emph{etc}).
 %   \item Binary |**| and |^| (right associative).
 %   \item Unary |+|, |-|, |!|.
-%   \item Binary |*|, |/|, and implicit multiplication by juxtaposition
+%   \item Implicit multiplication by juxtaposition
 %     (\texttt{2pi}, \texttt{3(4+5)}, \emph{etc}).
+%   \item Binary |*| and |/|.
 %   \item Binary |+| and |-|.
 %   \item Comparisons |>=|, |!=|, |<?|, \emph{etc}.
 %   \item Logical \texttt{and}, denoted by |&&|.
@@ -870,8 +871,9 @@
 % The precedence of operations can be overridden using parentheses.
 % In particular, those precedences imply that
 % \begin{align*}
-%   \mathtt{sin 2pi} & = \sin(2)\pi != 0, \\
-%   \mathtt{2\char`\^2max(3,5)} & = 2^2 \max(3,5) = 20.
+%   \mathtt{sin 2pi} & = \sin(2)\pi \neq 0, \\
+%   \mathtt{2\char`\^2max(3,5)} & = 2^2 \max(3,5) = 20, \\
+%   \mathtt{1in/1cm} & = (1in)/(1cm) = 2.54 .
 % \end{align*}
 % Functions are called on the value of their argument, contrarily to
 % \TeX{} macros.
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index c58d71e..47db6ae 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -3716,6 +3716,7 @@ Defining \c__fp_prec_func_int on line ...
 Defining \c__fp_prec_hatii_int on line ...
 Defining \c__fp_prec_hat_int on line ...
 Defining \c__fp_prec_not_int on line ...
+Defining \c__fp_prec_juxt_int on line ...
 Defining \c__fp_prec_times_int on line ...
 Defining \c__fp_prec_plus_int on line ...
 Defining \c__fp_prec_comp_int on line ...
@@ -3841,6 +3842,7 @@ Defining \__fp_parse_infix_,:N on line ...
 Defining \__fp_parse_infix_comma:w on line ...
 Defining \__fp_parse_apply_comma:NwNwN on line ...
 Defining \__fp_parse_infix_^:N on line ...
+Defining \__fp_parse_infix_juxt:N on line ...
 Defining \__fp_parse_infix_/:N on line ...
 Defining \__fp_parse_infix_mul:N on line ...
 Defining \__fp_parse_infix_-:N on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index 9626c61..2242e94 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -3970,6 +3970,7 @@ Defining \c__fp_prec_func_int on line ...
 Defining \c__fp_prec_hatii_int on line ...
 Defining \c__fp_prec_hat_int on line ...
 Defining \c__fp_prec_not_int on line ...
+Defining \c__fp_prec_juxt_int on line ...
 Defining \c__fp_prec_times_int on line ...
 Defining \c__fp_prec_plus_int on line ...
 Defining \c__fp_prec_comp_int on line ...
@@ -4095,6 +4096,7 @@ Defining \__fp_parse_infix_,:N on line ...
 Defining \__fp_parse_infix_comma:w on line ...
 Defining \__fp_parse_apply_comma:NwNwN on line ...
 Defining \__fp_parse_infix_^:N on line ...
+Defining \__fp_parse_infix_juxt:N on line ...
 Defining \__fp_parse_infix_/:N on line ...
 Defining \__fp_parse_infix_mul:N on line ...
 Defining \__fp_parse_infix_-:N on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index 1a4c217..36a6f3a 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -3970,6 +3970,7 @@ Defining \c__fp_prec_func_int on line ...
 Defining \c__fp_prec_hatii_int on line ...
 Defining \c__fp_prec_hat_int on line ...
 Defining \c__fp_prec_not_int on line ...
+Defining \c__fp_prec_juxt_int on line ...
 Defining \c__fp_prec_times_int on line ...
 Defining \c__fp_prec_plus_int on line ...
 Defining \c__fp_prec_comp_int on line ...
@@ -4095,6 +4096,7 @@ Defining \__fp_parse_infix_,:N on line ...
 Defining \__fp_parse_infix_comma:w on line ...
 Defining \__fp_parse_apply_comma:NwNwN on line ...
 Defining \__fp_parse_infix_^:N on line ...
+Defining \__fp_parse_infix_juxt:N on line ...
 Defining \__fp_parse_infix_/:N on line ...
 Defining \__fp_parse_infix_mul:N on line ...
 Defining \__fp_parse_infix_-:N on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index 46d8be0..638d1bd 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -3970,6 +3970,7 @@ Defining \c__fp_prec_func_int on line ...
 Defining \c__fp_prec_hatii_int on line ...
 Defining \c__fp_prec_hat_int on line ...
 Defining \c__fp_prec_not_int on line ...
+Defining \c__fp_prec_juxt_int on line ...
 Defining \c__fp_prec_times_int on line ...
 Defining \c__fp_prec_plus_int on line ...
 Defining \c__fp_prec_comp_int on line ...
@@ -4095,6 +4096,7 @@ Defining \__fp_parse_infix_,:N on line ...
 Defining \__fp_parse_infix_comma:w on line ...
 Defining \__fp_parse_apply_comma:NwNwN on line ...
 Defining \__fp_parse_infix_^:N on line ...
+Defining \__fp_parse_infix_juxt:N on line ...
 Defining \__fp_parse_infix_/:N on line ...
 Defining \__fp_parse_infix_mul:N on line ...
 Defining \__fp_parse_infix_-:N on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index 4db45b8..7ec458d 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -3714,6 +3714,7 @@ Defining \c__fp_prec_func_int on line ...
 Defining \c__fp_prec_hatii_int on line ...
 Defining \c__fp_prec_hat_int on line ...
 Defining \c__fp_prec_not_int on line ...
+Defining \c__fp_prec_juxt_int on line ...
 Defining \c__fp_prec_times_int on line ...
 Defining \c__fp_prec_plus_int on line ...
 Defining \c__fp_prec_comp_int on line ...
@@ -3839,6 +3840,7 @@ Defining \__fp_parse_infix_,:N on line ...
 Defining \__fp_parse_infix_comma:w on line ...
 Defining \__fp_parse_apply_comma:NwNwN on line ...
 Defining \__fp_parse_infix_^:N on line ...
+Defining \__fp_parse_infix_juxt:N on line ...
 Defining \__fp_parse_infix_/:N on line ...
 Defining \__fp_parse_infix_mul:N on line ...
 Defining \__fp_parse_infix_-:N on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index c58d71e..47db6ae 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -3716,6 +3716,7 @@ Defining \c__fp_prec_func_int on line ...
 Defining \c__fp_prec_hatii_int on line ...
 Defining \c__fp_prec_hat_int on line ...
 Defining \c__fp_prec_not_int on line ...
+Defining \c__fp_prec_juxt_int on line ...
 Defining \c__fp_prec_times_int on line ...
 Defining \c__fp_prec_plus_int on line ...
 Defining \c__fp_prec_comp_int on line ...
@@ -3841,6 +3842,7 @@ Defining \__fp_parse_infix_,:N on line ...
 Defining \__fp_parse_infix_comma:w on line ...
 Defining \__fp_parse_apply_comma:NwNwN on line ...
 Defining \__fp_parse_infix_^:N on line ...
+Defining \__fp_parse_infix_juxt:N on line ...
 Defining \__fp_parse_infix_/:N on line ...
 Defining \__fp_parse_infix_mul:N on line ...
 Defining \__fp_parse_infix_-:N on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index 9626c61..2242e94 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -3970,6 +3970,7 @@ Defining \c__fp_prec_func_int on line ...
 Defining \c__fp_prec_hatii_int on line ...
 Defining \c__fp_prec_hat_int on line ...
 Defining \c__fp_prec_not_int on line ...
+Defining \c__fp_prec_juxt_int on line ...
 Defining \c__fp_prec_times_int on line ...
 Defining \c__fp_prec_plus_int on line ...
 Defining \c__fp_prec_comp_int on line ...
@@ -4095,6 +4096,7 @@ Defining \__fp_parse_infix_,:N on line ...
 Defining \__fp_parse_infix_comma:w on line ...
 Defining \__fp_parse_apply_comma:NwNwN on line ...
 Defining \__fp_parse_infix_^:N on line ...
+Defining \__fp_parse_infix_juxt:N on line ...
 Defining \__fp_parse_infix_/:N on line ...
 Defining \__fp_parse_infix_mul:N on line ...
 Defining \__fp_parse_infix_-:N on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index 1a4c217..36a6f3a 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -3970,6 +3970,7 @@ Defining \c__fp_prec_func_int on line ...
 Defining \c__fp_prec_hatii_int on line ...
 Defining \c__fp_prec_hat_int on line ...
 Defining \c__fp_prec_not_int on line ...
+Defining \c__fp_prec_juxt_int on line ...
 Defining \c__fp_prec_times_int on line ...
 Defining \c__fp_prec_plus_int on line ...
 Defining \c__fp_prec_comp_int on line ...
@@ -4095,6 +4096,7 @@ Defining \__fp_parse_infix_,:N on line ...
 Defining \__fp_parse_infix_comma:w on line ...
 Defining \__fp_parse_apply_comma:NwNwN on line ...
 Defining \__fp_parse_infix_^:N on line ...
+Defining \__fp_parse_infix_juxt:N on line ...
 Defining \__fp_parse_infix_/:N on line ...
 Defining \__fp_parse_infix_mul:N on line ...
 Defining \__fp_parse_infix_-:N on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index 46d8be0..638d1bd 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -3970,6 +3970,7 @@ Defining \c__fp_prec_func_int on line ...
 Defining \c__fp_prec_hatii_int on line ...
 Defining \c__fp_prec_hat_int on line ...
 Defining \c__fp_prec_not_int on line ...
+Defining \c__fp_prec_juxt_int on line ...
 Defining \c__fp_prec_times_int on line ...
 Defining \c__fp_prec_plus_int on line ...
 Defining \c__fp_prec_comp_int on line ...
@@ -4095,6 +4096,7 @@ Defining \__fp_parse_infix_,:N on line ...
 Defining \__fp_parse_infix_comma:w on line ...
 Defining \__fp_parse_apply_comma:NwNwN on line ...
 Defining \__fp_parse_infix_^:N on line ...
+Defining \__fp_parse_infix_juxt:N on line ...
 Defining \__fp_parse_infix_/:N on line ...
 Defining \__fp_parse_infix_mul:N on line ...
 Defining \__fp_parse_infix_-:N on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index 4db45b8..7ec458d 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -3714,6 +3714,7 @@ Defining \c__fp_prec_func_int on line ...
 Defining \c__fp_prec_hatii_int on line ...
 Defining \c__fp_prec_hat_int on line ...
 Defining \c__fp_prec_not_int on line ...
+Defining \c__fp_prec_juxt_int on line ...
 Defining \c__fp_prec_times_int on line ...
 Defining \c__fp_prec_plus_int on line ...
 Defining \c__fp_prec_comp_int on line ...
@@ -3839,6 +3840,7 @@ Defining \__fp_parse_infix_,:N on line ...
 Defining \__fp_parse_infix_comma:w on line ...
 Defining \__fp_parse_apply_comma:NwNwN on line ...
 Defining \__fp_parse_infix_^:N on line ...
+Defining \__fp_parse_infix_juxt:N on line ...
 Defining \__fp_parse_infix_/:N on line ...
 Defining \__fp_parse_infix_mul:N on line ...
 Defining \__fp_parse_infix_-:N on line ...
diff --git a/l3kernel/testfiles/m3fp-parse001.tlg b/l3kernel/testfiles/m3fp-parse001.tlg
index 79beaa6..853dd0b 100644
--- a/l3kernel/testfiles/m3fp-parse001.tlg
+++ b/l3kernel/testfiles/m3fp-parse001.tlg
@@ -333,5 +333,5 @@ TEST 10: Juxtaposition and precedence
 2.856642116043664
 2.856642116043664
 16
-2
+0.125
 ============================================================
diff --git a/l3kernel/testfiles/m3fp-parse002.tlg b/l3kernel/testfiles/m3fp-parse002.tlg
index 9cb2740..80c7c9b 100644
--- a/l3kernel/testfiles/m3fp-parse002.tlg
+++ b/l3kernel/testfiles/m3fp-parse002.tlg
@@ -349,7 +349,7 @@ spelling (e.g., `I\hbox'). Otherwise just continue,
 and I'll forget about whatever was undefined.
 ! Undefined control sequence.
 <argument> \LaTeX3 error: 
-                           Invalid operation ((0,))*((2,))
+                           Invalid operation ((1,))*((0,))
 l. ...  }
 The control sequence at the end of the top line
 of your error message was never \def'ed. If you have





More information about the latex3-commits mailing list