summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/xint/xintexpr.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-02-19 22:11:40 +0000
committerKarl Berry <karl@freefriends.org>2020-02-19 22:11:40 +0000
commit4701e1a772599af5699534ae4090999a79e04ecf (patch)
tree5454e5ee585903dcb6ebe8724e674d53039e4e02 /Master/texmf-dist/tex/generic/xint/xintexpr.sty
parentf7fa7c5e6558b4fdff8eebb64a21cdf138d96929 (diff)
xint (19feb20)
git-svn-id: svn://tug.org/texlive/trunk@53846 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/xint/xintexpr.sty')
-rw-r--r--Master/texmf-dist/tex/generic/xint/xintexpr.sty74
1 files changed, 51 insertions, 23 deletions
diff --git a/Master/texmf-dist/tex/generic/xint/xintexpr.sty b/Master/texmf-dist/tex/generic/xint/xintexpr.sty
index fe24c68ad9c..2d8a4df7af5 100644
--- a/Master/texmf-dist/tex/generic/xint/xintexpr.sty
+++ b/Master/texmf-dist/tex/generic/xint/xintexpr.sty
@@ -21,7 +21,7 @@
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%% ---------------------------------------------------------------
-%% The xint bundle 1.4 2020/01/31
+%% The xint bundle 1.4a 2020/02/19
%% Copyright (C) 2013-2020 by Jean-Francois Burnol
%% xintexpr: Expandable expression parser
%% ---------------------------------------------------------------
@@ -82,7 +82,7 @@
\XINTsetupcatcodes%
\XINT_providespackage
\ProvidesPackage{xintexpr}%
- [2020/01/31 v1.4 Expandable expression parser (JFB)]%
+ [2020/02/19 v1.4a Expandable expression parser (JFB)]%
\catcode`! 11
\let\XINT_Cmp \xintiiCmp
\def\XINTfstop{\noexpand\XINTfstop}%
@@ -123,17 +123,17 @@
\catcode`& 4
\protected\def\xintexpralignbegin {\halign\bgroup\tabskip2ex\hfil##&&##\hfil\cr}%
\protected\def\xintexpralignend {\crcr\egroup}%
-\protected\def\xintexpraligncr {\cr}%
+\protected\def\xintexpralignlinesep {,\cr}%
\protected\def\xintexpralignleftbracket {[}%
\protected\def\xintexpralignrightbracket{]}%
-\protected\def\xintexpraligninnercomma {,}%
-\protected\def\xintexpralignoutercomma {,}%
-\protected\def\xintexpraligntab {&}%
+\protected\def\xintexpralignleftsep {&}%
+\protected\def\xintexpralignrightsep {&}%
+\protected\def\xintexpraligninnersep {,&}%
\catcode`& 7
\def\XINT:expr:toalignwith#1#2%
{%
{\expandafter\XINT:expr:toalign_checkempty
- \expanded{\noexpand#1!\expandafter}\detokenize{#2}^}%
+ \expanded{\noexpand#1!\expandafter}\detokenize{#2}^\expandafter}%
\xintexpralignend
}%
\def\XINT:expr:toalign_checkempty #1!#2%
@@ -145,23 +145,27 @@
\def\XINT:expr:toalign_a #1{#2%
<%
\if{#2\xint_dothis<\xintexpralignleftbracket\XINT:expr:toalign_a>\fi
- \xint_orthat\XINT:expr:toalign_b #1#2%
+ \xint_orthat<\xintexpralignleftsep\XINT:expr:toalign_b>#1#2%
>%
\def\XINT:expr:toalign_b #1!#2}%
<%
- \xintexpraligntab
\if\relax#2\relax\xintexprEmptyItem\else#1<#2>\fi\XINT:expr:toalign_c #1!}%
>%
\def\XINT:expr:toalign_c #1}#2%
<%
\if ^#2\xint_dothis<\xint_gob_til_^>\fi
- \if {#2\xint_dothis<\xintexpraligninnercomma\XINT:expr:toalign_a>\fi
- \xint_orthat<\xintexpraligntab\xintexpralignrightbracket\XINT:expr:toalign_C>#1#2%
+ \if {#2\xint_dothis<\xintexpraligninnersep\XINT:expr:toalign_A>\fi
+ \xint_orthat<\xintexpralignrightsep\xintexpralignrightbracket\XINT:expr:toalign_C>#1#2%
+>%
+\def\XINT:expr:toalign_A #1{#2%
+<%
+ \if{#2\xint_dothis<\xintexpralignleftbracket\XINT:expr:toalign_A>\fi
+ \xint_orthat\XINT:expr:toalign_b #1#2%
>%
\def\XINT:expr:toalign_C #1}#2%
<%
\if ^#2\xint_dothis<\xint_gob_til_^>\fi
- \if {#2\xint_dothis<\xintexpralignoutercomma\xintexpraligncr\XINT:expr:toalign_a>\fi
+ \if {#2\xint_dothis<\xintexpralignlinesep\XINT:expr:toalign_a>\fi
\xint_orthat<\xintexpralignrightbracket\XINT:expr:toalign_C>#1#2%
>%
\catcode`{ 1 \catcode`} 2 \catcode`< 12 \catcode`> 12
@@ -281,7 +285,7 @@
{\XINT:NEhook:x:toblist\XINT:expr:toblistwith\xintboolexprPrintOne}%
\def\xintboolexprPrintOne#1{\xintiiifNotZero{#1}{True}{False}}%
\def\xintthe #1{\expanded\expandafter\xint_gobble_i\romannumeral`&&@#1}%
-\def\xintthealign #1{\xintexpralignbegin
+\def\xintthealign #1{\expandafter\xintexpralignbegin
\expanded\expandafter\XINT:expr:toalignwith
\romannumeral0\expandafter\expandafter\expandafter\expandafter
\expandafter\expandafter\expandafter\xint_gob_andstop_ii
@@ -341,6 +345,15 @@
\def\XINT_thecoords_b #1#2,#3#4,%
{\xint_gob_til_! #3\XINT_thecoords_c ! (#1#2, #3#4)\XINT_thecoords_b }%
\def\XINT_thecoords_c #1^{}%
+\def\xintthespaceseparated#1%
+ {\romannumeral`&&@\expandafter\xintthespaceseparated_a\romannumeral0#1}%
+\def\xintthespaceseparated_a #1#2.#3%
+ {\expanded{\expandafter\xintthespaceseparated_b\expanded#2.{#3},!,!,!,!,!,!,!,!,!,^}}%
+\def\xintthespaceseparated_b #1,#2,#3,#4,#5,#6,#7,#8,#9,%
+ {\xint_gob_til_! #9\xintthespaceseparated_c !%
+ #1#2#3#4#5#6#7#8#9%
+ \xintthespaceseparated_b}%
+\def\xintthespaceseparated_c !#1!#2^{#1}%
\def\XINT:NEhook:unpack{\xint_stop_atfirstofone}%
\let\XINT:NEhook:f:one:from:one\expandafter
\let\XINT:NEhook:f:one:from:one:direct\empty
@@ -2203,10 +2216,10 @@
\def\XINT_expr_iter:_Goon_a #1#2#3~#4{\XINT_expr_iter:_Cb #3~{#1}}%
\def\XINT_expr_onliteral_add
{\expandafter\XINT_allexpr_add_f\romannumeral`&&@\XINT_expr_fetch_E_comma_V_equal_E_a {}}%
-\def\XINT_allexpr_add_f #1#2{\xint_c_ii^v `{opx}#2)\relax #1{+@}{0}}%
+\def\XINT_allexpr_add_f #1#2{\xint_c_ii^v `{opx}#2)\relax #1{+}{0}}%
\def\XINT_expr_onliteral_mul
{\expandafter\XINT_allexpr_mul_f\romannumeral`&&@\XINT_expr_fetch_E_comma_V_equal_E_a {}}%
-\def\XINT_allexpr_mul_f #1#2{\xint_c_ii^v `{opx}#2)\relax #1{*@}{1}}%
+\def\XINT_allexpr_mul_f #1#2{\xint_c_ii^v `{opx}#2)\relax #1{*}{1}}%
\def\XINT_expr_func_opx {\XINT:NEhook:opx \XINT_allexpr_opx \xintbareeval }%
\def\XINT_flexpr_func_opx {\XINT:NEhook:opx \XINT_allexpr_opx \xintbarefloateval}%
\def\XINT_iiexpr_func_opx {\XINT:NEhook:opx \XINT_allexpr_opx \xintbareiieval }%
@@ -2214,7 +2227,20 @@
{%
\expandafter\XINT_expr_put_op_first
\expanded \bgroup {\iffalse}\fi
- \XINT_expr_iter:_b {#1(#6)#7\relax !#5}#4^~{{#8}}\XINT_expr_cb_and_getop
+ \XINT_expr_iter:_b {#1%
+ \expandafter\XINT_allexpr_opx_ifnotomitted
+ \romannumeral0#1#6\relax#7@\relax !#5}#4^~{{#8}}\XINT_expr_cb_and_getop
+}%
+\def\XINT_allexpr_opx_ifnotomitted #1%
+{%
+ \ifx !#1\xint_dothis{@\relax}\fi
+ \ifx ^#1\xint_dothis{\XINTfstop. ^\relax}\fi
+ \if ?\xintFirstItem{#1}\xint_dothis{\XINT_allexpr_opx_break{#1}}\fi
+ \xint_orthat{\XINTfstop.{#1}}%
+}%
+\def\XINT_allexpr_opx_break #1#2\relax
+{%
+ break(\expandafter\XINTfstop\expandafter.\expandafter{\xint_gobble_i#1}#2)\relax
}%
\def\XINT_expr_func_rseq {\XINT_allexpr_rseq \xintbareeval }%
\def\XINT_flexpr_func_rseq {\XINT_allexpr_rseq \xintbarefloateval }%
@@ -3552,12 +3578,12 @@
\xint_dothis\XINT:NE:f:one:and:opt_a\fi
\xint_orthat\XINT:NE:f:tacitzeroifone_b ##1&&A%
}}\expandafter\XINT:NE:f:tacitzeroifone:direct\string#%
-\def\XINT:NE:f:tacitzeroifone:direct\XINT:expr:f:tacizeroifone #1#2#3&&A#4#5%
+\def\XINT:NE:f:tacitzeroifone_b\XINT:expr:f:tacitzeroifone #1#2#3&&A#4#5%
{%
\if\relax#3\relax\expandafter\xint_firstoftwo\else
\expandafter\xint_secondoftwo\fi
- {\XINT:NE:f:one:from:two#4{0}}%
- {\expandafter\XINT:NE:f:one:from:two\expandafter#5%
+ {\XINT:NE:f:one:from:two:direct#4{0}}%
+ {\expandafter\XINT:NE:f:one:from:two:direct\expandafter#5%
\expanded{{\XINT:NE:f:one:from:one:direct\xintNum{#2}}}}%
{#1}%
}%
@@ -3573,12 +3599,12 @@
{%
\detokenize{\romannumeral`-0\expandafter#1\expanded{#2}$XINT_expr_exclam#3}%$
}%
-\def\XINT:NE:f:iitacitzeroifone:direct\XINT:expr:f:iitacizeroifone #1#2#3&&A#4%
+\def\XINT:NE:f:iitacitzeroifone_b\XINT:expr:f:iitacitzeroifone #1#2#3&&A#4%
{%
\if\relax#3\relax\expandafter\xint_firstoftwo\else
\expandafter\xint_secondoftwo\fi
- {\XINT:NE:f:one:from:two#4{0}}%
- {\XINT:NE:f:one:from:two#4{#2}}%
+ {\XINT:NE:f:one:from:two:direct#4{0}}%
+ {\XINT:NE:f:one:from:two:direct#4{#2}}%
{#1}%
}%
\def\XINT:NE:x:one:from:two #1#2#3{\XINT:NE:x:one:from:two_fork #2&&A#3&&A#1{#2}{#3}}%
@@ -3780,7 +3806,9 @@
\detokenize
{%
\expanded\bgroup
- \expanded{\unexpanded{\XINT_expr_iter:_b{#1(#6)#7\relax $XINT_expr_exclam #5}}%
+ \expanded{\unexpanded{\XINT_expr_iter:_b
+ {#1\expandafter\XINT_allexpr_opx_ifnotomitted
+ \romannumeral0#1#6\relax#7@\relax $XINT_expr_exclam #5}}%
#4$XINT_expr_caret$XINT_expr_tilde{{#8}}}%$
}%
}%