diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/xint/xintexpr.sty')
-rw-r--r-- | Master/texmf-dist/tex/generic/xint/xintexpr.sty | 766 |
1 files changed, 525 insertions, 241 deletions
diff --git a/Master/texmf-dist/tex/generic/xint/xintexpr.sty b/Master/texmf-dist/tex/generic/xint/xintexpr.sty index 13bbb335437..8ed1191fb8a 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.3d 2019/01/06 +%% The xint bundle 1.3e 2019/04/05 %% Copyright (C) 2013-2019 by Jean-Francois Burnol %% xintexpr: Expandable expression parser %% --------------------------------------------------------------- @@ -81,142 +81,154 @@ \XINTsetupcatcodes% \XINT_providespackage \ProvidesPackage{xintexpr}% - [2019/01/06 1.3d Expandable expression parser (JFB)]% + [2019/04/05 1.3e Expandable expression parser (JFB)]% \catcode`! 11 \let\XINT_Cmp \xintiiCmp -\def\xint_gob_til_! #1!{}% ! with catcode 11 -\def\XINT_expr_lockscan#1{% not used for decimal numbers in xintexpr 1.2 -\def\XINT_expr_lockscan##1!{\expandafter#1\csname .=##1\endcsname}% -}\XINT_expr_lockscan{ }% -\def\XINT_expr_lockit#1{% -\def\XINT_expr_lockit##1{\expandafter#1\csname .=##1\endcsname}% -}\XINT_expr_lockit{ }% -\def\XINT_expr_unlock_hex_in #1% expanded inside \csname..\endcsname - {\expandafter\XINT_expr_inhex\romannumeral`&&@\XINT_expr_unlock#1;}% -\def\XINT_expr_inhex #1.#2#3;% expanded inside \csname..\endcsname -{% - \if#2>% - \xintHexToDec{#1}% - \else - \xintiiMul{\xintiiPow{625}{\xintLength{#3}}}{\xintHexToDec{#1#3}}% - [\the\numexpr-4*\xintLength{#3}]% - \fi -}% -\def\XINT_expr_unlock {\expandafter\XINT_expr_unlock_a\string }% -\def\XINT_expr_unlock_a #1.={}% -\def\XINT_expr_unexpectedtoken {\xintError:ignored }% -\let\XINT_expr_done\space -\def\XINT_expr_wrap { !\XINT_expr_usethe\XINT_protectii\XINT_expr_print }% -\def\XINT_iiexpr_wrap { !\XINT_expr_usethe\XINT_protectii\XINT_iiexpr_print }% -\def\XINT_protectii #1{\noexpand\XINT_protectii\noexpand #1\noexpand }% -\protected\def\XINT_expr_usethe\XINT_protectii {\xintError:missing_xintthe!}% -\def\XINT_expr_print #1{\xintSPRaw::csv {\XINT_expr_unlock #1}}% -\def\XINT_iiexpr_print #1{\xintCSV::csv {\XINT_expr_unlock #1}}% -\def\XINT_boolexpr_print #1{\xintIsTrue::csv {\XINT_expr_unlock #1}}% \def\xintexpr {\romannumeral0\xintexpro }% \def\xintiexpr {\romannumeral0\xintiexpro }% \def\xintfloatexpr {\romannumeral0\xintfloatexpro }% \def\xintiiexpr {\romannumeral0\xintiiexpro }% -\def\xinttheexpr - {\romannumeral`&&@\expandafter\XINT_expr_print\romannumeral0\xintbareeval}% -\def\xinttheiexpr - {\romannumeral`&&@\expandafter\xint_gobble_iii\romannumeral`&&@\xintiexpr}% -\def\xintthefloatexpr - {\romannumeral`&&@\expandafter\xint_gobble_iii\romannumeral`&&@\xintfloatexpr}% -\def\xinttheiiexpr - {\romannumeral`&&@\expandafter\XINT_iiexpr_print\romannumeral0\xintbareiieval}% -\def\xinteval #1% - {\romannumeral`&&@\expandafter\XINT_expr_print\romannumeral0\xintbareeval#1\relax}% -\def\xintieval #1% - {\romannumeral`&&@\expandafter\xint_gobble_iii\romannumeral`&&@\xintiexpr#1\relax}% -\def\xintfloateval #1% - {\romannumeral`&&@\expandafter\xint_gobble_iii\romannumeral`&&@\xintfloatexpr#1\relax}% -\def\xintiieval #1% - {\romannumeral`&&@\expandafter\XINT_iiexpr_print\romannumeral0\xintbareiieval#1\relax}% -\def\xintthe #1{\romannumeral`&&@\expandafter\xint_gobble_iii\romannumeral`&&@#1}% -\def\xintthe_o #1{\expandafter\xint_gobble_iii\romannumeral`&&@#1}% -\let\thexintexpr \xinttheexpr -\let\thexintiexpr \xinttheiexpr -\let\thexintfloatexpr\xintthefloatexpr -\let\thexintiiexpr \xinttheiiexpr -\def\xintthecoords #1{\romannumeral`&&@\expandafter\expandafter\expandafter - \XINT_thecoords_a - \expandafter\xint_gobble_iii\romannumeral0#1}% -\def\XINT_thecoords_a #1#2% #1=print macro, indispensible for scientific notation - {\expandafter\XINT_expr_unlock\csname.=\expandafter\XINT_thecoords_b - \romannumeral`&&@#1#2,!,!,^\endcsname }% -\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\xintbareeval - {\expandafter\XINT_expr_until_end_a\romannumeral`&&@\XINT_expr_getnext }% -\def\xintbarefloateval - {\expandafter\XINT_flexpr_until_end_a\romannumeral`&&@\XINT_expr_getnext }% -\def\xintbareiieval - {\expandafter\XINT_iiexpr_until_end_a\romannumeral`&&@\XINT_expr_getnext }% -\def\xintthebareeval {\expandafter\XINT_expr_unlock\romannumeral0\xintbareeval}% -\def\xintthebarefloateval {\expandafter\XINT_expr_unlock\romannumeral0\xintbarefloateval}% -\def\xintthebareiieval {\expandafter\XINT_expr_unlock\romannumeral0\xintbareiieval}% \def\xintexpro {\expandafter\XINT_expr_wrap\romannumeral0\xintbareeval }% \def\xintiiexpro {\expandafter\XINT_iiexpr_wrap\romannumeral0\xintbareiieval }% \def\xintiexpro #1% - {\ifx [#1\expandafter\XINT_iexpr_withopt\else\expandafter\XINT_iexpr_noopt \fi #1}% +{% + \ifx [#1\expandafter\XINT_iexpr_withopt\else\expandafter\XINT_iexpr_noopt + \fi #1% +}% \def\XINT_iexpr_noopt - {\expandafter\XINT_iexpr_wrap \expandafter 0\romannumeral0\xintbareeval }% +{% + \expandafter\XINT_iexpr_preprint\expandafter 0% + \romannumeral0\xintbareeval +}% \def\XINT_iexpr_withopt [#1]% {% - \expandafter\XINT_iexpr_wrap\expandafter + \expandafter\XINT_iexpr_preprint\expandafter {\the\numexpr \xint_zapspaces #1 \xint_gobble_i\expandafter}% \romannumeral0\xintbareeval }% -\def\XINT_iexpr_wrap #1#2% +\def\XINT_iexpr_preprint #1#2% {% \expandafter\XINT_expr_wrap \csname .=\xintRound::csv {#1}{\XINT_expr_unlock #2}\endcsname }% \def\xintfloatexpro #1% {% - \ifx [#1\expandafter\XINT_flexpr_withopt_a\else\expandafter\XINT_flexpr_noopt + \ifx [#1\expandafter\XINT_flexpr_withopt\else\expandafter\XINT_flexpr_noopt \fi #1% }% \def\XINT_flexpr_noopt {% - \expandafter\XINT_flexpr_withopt_b\expandafter\xinttheDigits - \romannumeral0\xintbarefloateval + \expandafter\XINT_flexpr_preprint\expandafter\xinttheDigits + \romannumeral0\xintbarefloateval }% -\def\XINT_flexpr_withopt_a [#1]% +\def\XINT_flexpr_withopt [#1]% {% - \expandafter\XINT_flexpr_withopt_b\expandafter + \expandafter\XINT_flexpr_preprint\expandafter {\the\numexpr\xint_zapspaces #1 \xint_gobble_i\expandafter}% \romannumeral0\xintbarefloateval }% -\def\XINT_flexpr_withopt_b #1#2% +\def\XINT_flexpr_preprint #1#2% {% - \expandafter\XINT_flexpr_wrap\csname .;#1.=% ; and not : as before b'cause NewExpr - \XINTinFloat::csv {#1}{\XINT_expr_unlock #2}\endcsname + \expandafter\XINT_flexpr_wrap + \csname .;#1.=\XINTinFloat::csv {#1}{\XINT_expr_unlock #2}\endcsname }% -\def\XINT_flexpr_wrap { !\XINT_expr_usethe\XINT_protectii\XINT_flexpr_print }% +\def\XINT_expr_wrap {!\XINT_expr_usethe\XINT_protectii\XINT_expr_print}% +\def\XINT_iiexpr_wrap {!\XINT_expr_usethe\XINT_protectii\XINT_iiexpr_print}% +\def\XINT_flexpr_wrap {!\XINT_expr_usethe\XINT_protectii\XINT_flexpr_print}% +\def\XINT_protectii #1{\noexpand\XINT_protectii\noexpand #1\noexpand }% +\protected\def\XINT_expr_usethe\XINT_protectii {\xintError:missing_xintthe!}% +\def\XINT_expr_print #1{\xintSPRaw::csv {\XINT_expr_unlock #1}}% +\def\XINT_iiexpr_print #1{\xintCSV::csv {\XINT_expr_unlock #1}}% \def\XINT_flexpr_print #1% {% \expandafter\xintPFloat::csv \romannumeral`&&@\expandafter\XINT_expr_unlock_sp\string #1!% }% \def\XINT_expr_unlock_sp #1.;#2.=#3!{{#2}{#3}}% -\def\xintboolexpr {\romannumeral0\expandafter\expandafter\expandafter - \XINT_boolexpr_done \expandafter\xint_gobble_iv\romannumeral0\xintexpro }% -\def\xinttheboolexpr {\romannumeral`&&@\expandafter\expandafter\expandafter - \XINT_boolexpr_print\expandafter\xint_gobble_iv\romannumeral0\xintexpro }% +\def\xinttheexpr + {\romannumeral`&&@\expandafter\XINT_expr_print\romannumeral0\xintbareeval}% +\def\xinttheiexpr + {\romannumeral`&&@\expandafter\xint_gobble_iii\romannumeral`&&@\xintiexpr}% +\def\xintthefloatexpr + {\romannumeral`&&@\expandafter\xint_gobble_iii\romannumeral`&&@\xintfloatexpr}% +\def\xinttheiiexpr + {\romannumeral`&&@\expandafter\XINT_iiexpr_print\romannumeral0\xintbareiieval}% +\let\thexintexpr \xinttheexpr +\let\thexintiexpr \xinttheiexpr +\let\thexintfloatexpr\xintthefloatexpr +\let\thexintiiexpr \xinttheiiexpr +\def\xinteval #1% + {\romannumeral`&&@\expandafter\XINT_expr_print\romannumeral0\xintbareeval#1\relax}% +\def\xintieval #1% + {\romannumeral`&&@\expandafter\xint_gobble_iii\romannumeral`&&@\xintiexpr#1\relax}% +\def\xintfloateval #1% + {\romannumeral`&&@\expandafter\xint_gobble_iii\romannumeral`&&@\xintfloatexpr#1\relax}% +\def\xintiieval #1% + {\romannumeral`&&@\expandafter\XINT_iiexpr_print\romannumeral0\xintbareiieval#1\relax}% +\def\xintthe #1{\romannumeral`&&@\expandafter\xint_gobble_iii\romannumeral`&&@#1}% +\def\xintbareeval + {\expandafter\XINT_expr_until_end_a\romannumeral`&&@\XINT_expr_getnext }% +\def\xintbarefloateval + {\expandafter\XINT_flexpr_until_end_a\romannumeral`&&@\XINT_expr_getnext }% +\def\xintbareiieval + {\expandafter\XINT_iiexpr_until_end_a\romannumeral`&&@\XINT_expr_getnext }% +\def\xintthebareeval {\expandafter\XINT_expr_unlock\romannumeral0\xintbareeval}% +\def\xintthebarefloateval {\expandafter\XINT_expr_unlock\romannumeral0\xintbarefloateval}% +\def\xintthebareiieval {\expandafter\XINT_expr_unlock\romannumeral0\xintbareiieval}% +\def\xintboolexpr +{% + \romannumeral0\expandafter\expandafter\expandafter + \XINT_boolexpr_done\expandafter\xint_gobble_iv\romannumeral0\xintexpro +}% +\def\XINT_boolexpr_done {!\XINT_expr_usethe\XINT_protectii\XINT_boolexpr_print}% +\def\XINT_boolexpr_print #1{\xintIsTrue::csv {\XINT_expr_unlock #1}}% +\def\xinttheboolexpr +{% + \romannumeral`&&@\expandafter\expandafter\expandafter + \XINT_boolexpr_print\expandafter\xint_gobble_iv\romannumeral0\xintexpro +}% \let\thexintboolexpr\xinttheboolexpr -\def\XINT_boolexpr_done { !\XINT_expr_usethe\XINT_protectii\XINT_boolexpr_print }% \def\xintifboolexpr #1{\romannumeral0\xintiiifnotzero {\xinttheexpr #1\relax}}% \def\xintifboolfloatexpr #1{\romannumeral0\xintiiifnotzero {\xintthefloatexpr #1\relax}}% \def\xintifbooliiexpr #1{\romannumeral0\xintiiifnotzero {\xinttheiiexpr #1\relax}}% \def\xintifsgnexpr #1{\romannumeral0\xintiiifsgn {\xinttheexpr #1\relax}}% \def\xintifsgnfloatexpr #1{\romannumeral0\xintiiifsgn {\xintthefloatexpr #1\relax}}% \def\xintifsgniiexpr #1{\romannumeral0\xintiiifsgn {\xinttheiiexpr #1\relax}}% -\let\XINT:NEhook:two\empty +\def\xintthecoords #1{\romannumeral`&&@\expandafter\expandafter\expandafter + \XINT_thecoords_a + \expandafter\xint_gobble_iii\romannumeral0#1}% +\def\XINT_thecoords_a #1#2% #1=print macro, indispensible for scientific notation + {\expandafter\XINT_expr_unlock\csname.=\expandafter\XINT_thecoords_b + \romannumeral`&&@#1#2,!,!,^\endcsname }% +\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\xint_gob_til_! #1!{}% ! with catcode 11 +\def\XINT_expr_lockscan#1{% not used for decimal numbers in xintexpr 1.2 +\def\XINT_expr_lockscan##1!{\expandafter#1\csname .=##1\endcsname}% +}\XINT_expr_lockscan{ }% +\def\XINT_expr_lockit#1{% +\def\XINT_expr_lockit##1{\expandafter#1\csname .=##1\endcsname}% +}\XINT_expr_lockit{ }% +\def\XINT_expr_unlock_hex_in #1% expanded inside \csname..\endcsname + {\expandafter\XINT_expr_inhex\romannumeral`&&@\XINT_expr_unlock#1;}% +\def\XINT_expr_inhex #1.#2#3;% expanded inside \csname..\endcsname +{% + \if#2>% + \xintHexToDec{#1}% + \else + \xintiiMul{\xintiiPow{625}{\xintLength{#3}}}{\xintHexToDec{#1#3}}% + [\the\numexpr-4*\xintLength{#3}]% + \fi +}% +\def\XINT_expr_unlock {\expandafter\XINT_expr_unlock_a\string }% +\def\XINT_expr_unlock_a #1.={}% +\def\XINT_expr_unexpectedtoken {\xintError:ignored }% +\let\XINT_expr_done\space \let\XINT:NEhook:one\empty +\let\XINT:NEhook:two\empty \let\XINT:NEhook:csv\empty +\def\XINT:NEhook:twosp #1,#2,!#3{#3{#1}{#2}}% \def\XINT_::_end #1,#2{\xint_gobble_i #2}% \def\xintCSV::csv #1{\expandafter\XINT_csv::_a\romannumeral`&&@#1,^,}% \def\XINT_csv::_a {\XINT_csv::_b {}}% @@ -245,34 +257,39 @@ \def\XINT_istrue::_d #1,{\expandafter\XINT_istrue::_e\romannumeral0\xintisnotzero {#1},}% \def\XINT_istrue::_e #1,#2{\XINT_istrue::_b {#2, #1}}% \def\XINT_:::_end #1,#2#3{\xint_gobble_i #3}% -\def\xintRound::csv #1#2{\romannumeral0\expandafter\XINT_round::_b\expandafter - {\the\numexpr#1\expandafter}\expandafter{\expandafter}\romannumeral`&&@#2,^,}% -\def\XINT_round::_b #1#2#3,{\expandafter\XINT_round::_c \romannumeral`&&@#3,{#1}{#2}}% +\def\xintRound::csv #1#2{\romannumeral0\expandafter\XINT_round::_a + \the\numexpr#1\expandafter.\romannumeral`&&@#2,^,}% +\def\XINT_round::_a #1.{\XINT_round::_b #1.{}}% +\def\XINT_round::_b #1.#2#3,{\expandafter\XINT_round::_c \romannumeral`&&@#3,{#1}{#2}}% \def\XINT_round::_c #1{\if ,#1\xint_dothis\XINT_round::_e\fi \if ^#1\xint_dothis\XINT_:::_end\fi \xint_orthat\XINT_round::_d #1}% \def\XINT_round::_d #1,#2{% \expandafter\XINT_round::_e\romannumeral0\ifnum#2>\xint_c_ \expandafter\xintround\else\expandafter\xintiround\fi {#2}{#1},{#2}}% -\def\XINT_round::_e #1,#2#3{\XINT_round::_b {#2}{#3, #1}}% -\def\XINTinFloat::csv #1#2{\romannumeral0\expandafter\XINT_infloat::_b\expandafter - {\the\numexpr #1\expandafter}\expandafter{\expandafter}\romannumeral`&&@#2,^,}% -\def\XINT_infloat::_b #1#2#3,{\XINT_infloat::_c #3,{#1}{#2}}% +\def\XINT_round::_e #1,#2#3{\XINT_round::_b #2.{#3, #1}}% +\def\XINTinFloat::csv #1#2{\romannumeral0\expandafter\XINT_infloat::_a + \the\numexpr #1\expandafter.\romannumeral`&&@#2,^,}% +\def\XINT_infloat::_a #1#2.% + {\expandafter\XINT_infloat::_b\the\numexpr\if#1-\XINTdigits\fi#1#2.{}}% +\def\XINT_infloat::_b #1.#2#3,{\XINT_infloat::_c #3,{#1}{#2}}% \def\XINT_infloat::_c #1{\if ,#1\xint_dothis\XINT_infloat::_e\fi \if ^#1\xint_dothis\XINT_:::_end\fi \xint_orthat\XINT_infloat::_d #1}% \def\XINT_infloat::_d #1,#2% {\expandafter\XINT_infloat::_e\romannumeral0\XINTinfloat [#2]{#1},{#2}}% -\def\XINT_infloat::_e #1,#2#3{\XINT_infloat::_b {#2}{#3, #1}}% -\def\xintPFloat::csv #1#2{\romannumeral0\expandafter\XINT_pfloat::_b\expandafter - {\the\numexpr #1\expandafter}\expandafter{\expandafter}\romannumeral`&&@#2,^,}% -\def\XINT_pfloat::_b #1#2#3,{\expandafter\XINT_pfloat::_c \romannumeral`&&@#3,{#1}{#2}}% +\def\XINT_infloat::_e #1,#2#3{\XINT_infloat::_b #2.{#3, #1}}% +\def\xintPFloat::csv #1#2{\romannumeral0\expandafter\XINT_pfloat::_a + \the\numexpr #1\expandafter.\romannumeral`&&@#2,^,}% +\def\XINT_pfloat::_a #1#2.% + {\expandafter\XINT_pfloat::_b\the\numexpr\if#1-\XINTdigits\fi#1#2.{}}% +\def\XINT_pfloat::_b #1.#2#3,{\expandafter\XINT_pfloat::_c \romannumeral`&&@#3,{#1}{#2}}% \def\XINT_pfloat::_c #1{\if ,#1\xint_dothis\XINT_pfloat::_e\fi \if ^#1\xint_dothis\XINT_:::_end\fi \xint_orthat\XINT_pfloat::_d #1}% \def\XINT_pfloat::_d #1,#2% {\expandafter\XINT_pfloat::_e\romannumeral0\XINT_pfloat_opt [\xint:#2]{#1},{#2}}% -\def\XINT_pfloat::_e #1,#2#3{\XINT_pfloat::_b {#2}{#3, #1}}% +\def\XINT_pfloat::_e #1,#2#3{\XINT_pfloat::_b #2.{#3, #1}}% \def\XINT_expr_getnext #1% {% \expandafter\XINT_expr_getnext_a\romannumeral`&&@#1% @@ -1446,7 +1463,7 @@ \def\XINT_expr_onliteral_qfrac #1)% {\expandafter\XINT_expr_getop\csname .=\xintRaw{#1}\endcsname }% \def\XINT_expr_onliteral_qfloat #1)% - {\expandafter\XINT_expr_getop\csname .=\XINTinFloatdigits{#1}\endcsname }% + {\expandafter\XINT_expr_getop\csname .=\XINTinFloatSdigits{#1}\endcsname }% \def\XINT_expr_onliteral_qraw #1)% {\expandafter\XINT_expr_getop\csname .=#1\endcsname }% \def\XINT_expr_onliteral_random #1)% @@ -1486,44 +1503,44 @@ \catcode`~ 13 \catcode`: 12 \def\XINT_expr_defvar_getname #1:#2~{\endgroup - \def\XINT_expr_tmpa{#1}\edef\XINT_expr_tmpc{\xintCSVLength{#1}}}% + \def\XINT_defvar_tmpa{#1}\edef\XINT_defvar_tmpc{\xintCSVLength{#1}}}% \def\XINT_expr_defvar #1#2#3;% {% \xintexprRestoreCatcodes \begingroup\lccode`~`: \lowercase{\let~}\empty - \edef\XINT_expr_tmpa{#2}% - \edef\XINT_expr_tmpa{\xint_zapspaces_o\XINT_expr_tmpa}% + \edef\XINT_defvar_tmpa{#2}% + \edef\XINT_defvar_tmpa{\xint_zapspaces_o\XINT_defvar_tmpa}% \expandafter\XINT_expr_defvar_getname - \detokenize\expandafter{\XINT_expr_tmpa}:~% - \ifcase\XINT_expr_tmpc + \detokenize\expandafter{\XINT_defvar_tmpa}:~% + \ifcase\XINT_defvar_tmpc\space \xintMessage {xintexpr}{Warning} {Aborting: not allowed to declare variable with empty name.}% \or - \edef\XINT_expr_tmpb{\romannumeral0#1#3\relax}% - \XINT_expr_defvar_one\XINT_expr_tmpa\XINT_expr_tmpb + \edef\XINT_defvar_tmpb{\romannumeral0#1#3\relax}% + \XINT_expr_defvar_one\XINT_defvar_tmpa\XINT_defvar_tmpb \else - \edef\XINT_expr_tmpb + \edef\XINT_defvar_tmpb {\expandafter\XINT_expr_unlock\romannumeral0#1#3\relax}% - \edef\XINT_expr_tmpd{\xintCSVLength{\XINT_expr_tmpb}}% - \ifnum\XINT_expr_tmpc=\XINT_expr_tmpd\space - \xintAssignArray\xintCSVtoList\XINT_expr_tmpa\to\XINT_expr_tmpvar + \edef\XINT_defvar_tmpd{\xintCSVLength{\XINT_defvar_tmpb}}% + \ifnum\XINT_defvar_tmpc=\XINT_defvar_tmpd\space + \xintAssignArray\xintCSVtoList\XINT_defvar_tmpa\to\XINT_defvar_tmpvar \xintAssignArray - \xintApply\XINT_expr_lockit{\xintCSVtoList\XINT_expr_tmpb}% - \to\XINT_expr_tmpval - \def\XINT_expr_tmpd{1}% + \xintApply\XINT_expr_lockit{\xintCSVtoList\XINT_defvar_tmpb}% + \to\XINT_defvar_tmpval + \def\XINT_defvar_tmpd{1}% \xintloop \expandafter\XINT_expr_defvar_one - \csname XINT_expr_tmpvar\XINT_expr_tmpd\expandafter\endcsname - \csname XINT_expr_tmpval\XINT_expr_tmpd\endcsname - \ifnum\XINT_expr_tmpd<\XINT_expr_tmpc\space - \edef\XINT_expr_tmpd{\the\numexpr\XINT_expr_tmpd+1}% + \csname XINT_defvar_tmpvar\XINT_defvar_tmpd\expandafter\endcsname + \csname XINT_defvar_tmpval\XINT_defvar_tmpd\endcsname + \ifnum\XINT_defvar_tmpd<\XINT_defvar_tmpc\space + \edef\XINT_defvar_tmpd{\the\numexpr\XINT_defvar_tmpd+1}% \repeat - \xintRelaxArray\XINT_expr_tmpvar - \xintRelaxArray\XINT_expr_tmpval + \xintRelaxArray\XINT_defvar_tmpvar + \xintRelaxArray\XINT_defvar_tmpval \else \xintMessage {xintexpr}{Warning} - {Aborting: mismatch between number of variables (\XINT_expr_tmpc) - and number of values (\XINT_expr_tmpd).}% + {Aborting: mismatch between number of variables (\XINT_defvar_tmpc) + and number of values (\XINT_defvar_tmpd).}% \fi \fi }% @@ -1536,29 +1553,39 @@ \def\xintdefiivar_a #1={\XINT_expr_defvar\xintbareiieval {#1}}% \def\xintdeffloatvar_a #1={\XINT_expr_defvar\xintbarefloateval {#1}}% \def\xintunassignvar #1{% - \edef\XINT_expr_tmpa{#1}% - \edef\XINT_expr_tmpa {\xint_zapspaces_o\XINT_expr_tmpa}% - \ifcsname XINT_expr_var_\XINT_expr_tmpa\endcsname - \ifnum\expandafter\xintLength\expandafter{\XINT_expr_tmpa}=\@ne - \expandafter\xintnewdummy\XINT_expr_tmpa + \edef\XINT_unvar_tmpa{#1}% + \edef\XINT_unvar_tmpa {\xint_zapspaces_o\XINT_unvar_tmpa}% + \ifcsname XINT_expr_var_\XINT_unvar_tmpa\endcsname + \ifnum\expandafter\xintLength\expandafter{\XINT_unvar_tmpa}=\@ne + \expandafter\xintnewdummy\XINT_unvar_tmpa \else \XINT_global\expandafter - \let\csname XINT_expr_var_\XINT_expr_tmpa\endcsname\xint_undefined + \let\csname XINT_expr_var_\XINT_unvar_tmpa\endcsname\xint_undefined \XINT_global\expandafter - \let\csname XINT_expr_onliteral_\XINT_expr_tmpa\endcsname\xint_undefined + \let\csname XINT_expr_onliteral_\XINT_unvar_tmpa\endcsname\xint_undefined \ifxintverbose\xintMessage {xintexpr}{Info} - {Variable \XINT_expr_tmpa\space has been + {Variable \XINT_unvar_tmpa\space has been \ifxintglobaldefs globally \fi ``unassigned''.}% \fi \fi \else \xintMessage {xintexpr}{Warning} - {Error: there was no such variable \XINT_expr_tmpa\space to unassign.}% + {Error: there was no such variable \XINT_unvar_tmpa\space to unassign.}% \fi }% \catcode`* 11 \def\XINT_expr_makedummy #1% {% + \ifcsname XINT_expr_var_#1\endcsname + \XINT_global + \expandafter\let\csname XINT_expr_var_#1/old\expandafter\endcsname + \csname XINT_expr_var_#1\expandafter\endcsname + \fi + \ifcsname XINT_expr_onliteral_#1\endcsname + \XINT_global + \expandafter\let\csname XINT_expr_onliteral_#1/old\expandafter\endcsname + \csname XINT_expr_onliteral_#1\expandafter\endcsname + \fi \XINT_global \expandafter\def\csname XINT_expr_var_#1\endcsname ##1\relax !#1##2% {##2##1\relax !#1##2}% @@ -1579,6 +1606,30 @@ \edef\XINT_expr_onliteral_nil {\XINT_expr_precedence_*** *\expandafter\noexpand\csname .= \endcsname (}% \catcode`* 12 +\def\xintensuredummy #1{% + \XINT_expr_makedummy{#1}% + \ifxintverbose\xintMessage {xintexpr}{Info}% + {#1 (with letter catcode) now + \ifxintglobaldefs globally \fi usable as dummy variable.&&J + Use \string\xintrestoredummy{#1} to restore it to its former meaning.}% + \fi +}% +\def\xintrestorelettervar #1{% + \ifcsname XINT_expr_var_#1/old\endcsname + \XINT_global + \expandafter\let\csname XINT_expr_var_#1\expandafter\endcsname + \csname XINT_expr_var_#1/old\expandafter\endcsname + \fi + \ifcsname XINT_expr_onliteral_#1/old\endcsname + \XINT_global + \expandafter\let\csname XINT_expr_onliteral_#1\expandafter\endcsname + \csname XINT_expr_onliteral_#1/old\expandafter\endcsname + \fi + \ifxintverbose\xintMessage {xintexpr}{Info}% + {Character #1 (with letter catcode) + \ifxintglobaldefs globally \fi restored to its earlier status, if any.}% + \fi +}% \edef\XINT_expr_var_omit #1\relax !{1\string !?!\relax !}% \edef\XINT_expr_var_abort #1\relax !{1\string !?^\relax !}% \def\XINT_expr_op_!? #1#2\relax {\expandafter\XINT_expr_foundend\csname .=#2\endcsname}% @@ -2114,16 +2165,18 @@ \def\xintiiLCMof:csv #1{\expandafter\XINT_oncsv:_a\expandafter\xintiilcm \expandafter\xint_firstofone\romannumeral`&&@#1,^,0}% \def\XINTinFloatdigits {\XINTinFloat [\XINTdigits]}% +\def\XINTinFloatSdigits {\XINTinFloatS [\XINTdigits]}% \def\XINTinFloatSqrtdigits {\XINTinFloatSqrt[\XINTdigits]}% \def\XINTinFloatFacdigits {\XINTinFloatFac [\XINTdigits]}% +\def\XINTFloatiLogTendigits{\XINTFloatiLogTen[\XINTdigits]}% \def\XINTinFloatMaxof:csv #1{\expandafter\XINT_oncsv:_a\expandafter\xintmax - \expandafter\XINTinFloatdigits\romannumeral`&&@#1,^,{0[0]}}% + \expandafter\XINTinFloatSdigits\romannumeral`&&@#1,^,{0[0]}}% \def\XINTinFloatMinof:csv #1{\expandafter\XINT_oncsv:_a\expandafter\xintmin - \expandafter\XINTinFloatdigits\romannumeral`&&@#1,^,{0[0]}}% + \expandafter\XINTinFloatSdigits\romannumeral`&&@#1,^,{0[0]}}% \def\XINTinFloatSum:csv #1{\expandafter\XINT_oncsv:_a\expandafter\XINTinfloatadd - \expandafter\XINTinFloatdigits\romannumeral`&&@#1,^,{0[0]}}% + \expandafter\XINTinFloatSdigits\romannumeral`&&@#1,^,{0[0]}}% \def\XINTinFloatPrd:csv #1{\expandafter\XINT_oncsv:_a\expandafter\XINTinfloatmul - \expandafter\XINTinFloatdigits\romannumeral`&&@#1,^,{1[0]}}% + \expandafter\XINTinFloatSdigits\romannumeral`&&@#1,^,{1[0]}}% \def\XINT:expr:one:and:opt #1,#2,#3!#4#5% {% \if\relax#3\relax\expandafter\xint_firstoftwo\else @@ -2145,18 +2198,10 @@ \def\XINT:expr:totwo #1#2{#1,#2}% \def\XINT:expr:two:to:two #1,#2,!#3% {% - \expandafter\XINT:expr:totwo\romannumeral`&&@% - #3{#1}{#2}% + \expandafter\XINT:expr:totwo\romannumeral`&&@#3{#1}{#2}% }% -\def\XINT:expr:two:to:one #1,#2,!#3% -{% - #3{#1}{#2}% -}% -\def\XINT:flexpr:two:to:one #1,#2,!#3% -{% - #3{#1}{#2}% -}% -\let\XINT:flexpr:two:to:two\XINT:flexpr:two:to:one +\let\XINT:flexpr:two:to:two\XINT:expr:two:to:two +\let\XINT:iiexpr:two:to:two\XINT:expr:two:to:two \def\XINT_expr_func_num #1#2#3% {% \expandafter #1\expandafter #2\csname.=% @@ -2352,6 +2397,16 @@ \expandafter #1\expandafter #2\csname.=% \XINT:NEhook:one\xintiiSqrtR{\XINT_expr_unlock #3}\endcsname }% +\def\XINT_expr_func_inv #1#2#3% +{% + \expandafter #1\expandafter #2\csname.=% + \XINT:NEhook:one\xintInv{\XINT_expr_unlock #3}\endcsname +}% +\def\XINT_flexpr_func_inv #1#2#3% +{% + \expandafter #1\expandafter #2\csname.=% + \XINT:NEhook:one\XINTinFloatInv{\XINT_expr_unlock #3}\endcsname +}% \def\XINT_expr_func_round #1#2#3% {% \expandafter #1\expandafter #2\csname.=% @@ -2390,6 +2445,33 @@ \endcsname }% \let\XINT_flexpr_func_float\XINT_expr_func_float +\def\XINT_expr_func_sfloat #1#2#3% +{% + \expandafter #1\expandafter #2\csname.=% + \expandafter\XINT:expr:one:and:opt + \romannumeral`&&@\XINT_expr_unlock #3,,!\XINTinFloatSdigits\XINTinFloatS + \endcsname +}% +\let\XINT_flexpr_func_sfloat\XINT_expr_func_sfloat +\expandafter\def\csname XINT_expr_func_ilog10\endcsname #1#2#3% +{% + \expandafter #1\expandafter #2\csname.=% + \expandafter\XINT:expr:one:and:opt + \romannumeral`&&@\XINT_expr_unlock #3,,!\xintiLogTen\XINTFloatiLogTen + \endcsname +}% +\expandafter\def\csname XINT_flexpr_func_ilog10\endcsname #1#2#3% +{% + \expandafter #1\expandafter #2\csname.=% + \expandafter\XINT:expr:one:and:opt + \romannumeral`&&@\XINT_expr_unlock #3,,!\XINTFloatiLogTendigits\XINTFloatiLogTen + \endcsname +}% +\expandafter\def\csname XINT_iiexpr_func_ilog10\endcsname #1#2#3% +{% + \expandafter #1\expandafter #2\csname.=% + \XINT:NEhook:one\xintiiLogTen{\XINT_expr_unlock #3}\endcsname +}% \def\XINT_expr_func_divmod #1#2#3% {% \expandafter #1\expandafter #2\csname.=% @@ -2400,7 +2482,7 @@ \def\XINT_flexpr_func_divmod #1#2#3% {% \expandafter #1\expandafter #2\csname.=% - \expandafter\XINT:flexpr:two:to:two + \expandafter\XINT:NEhook:twosp \romannumeral`&&@\XINT_expr_unlock #3,!\XINTinFloatDivMod \endcsname }% @@ -2414,63 +2496,63 @@ \def\XINT_expr_func_mod #1#2#3% {% \expandafter #1\expandafter #2\csname.=% - \expandafter\XINT:expr:two:to:one + \expandafter\XINT:NEhook:twosp \romannumeral`&&@\XINT_expr_unlock #3,!\xintMod \endcsname }% \def\XINT_flexpr_func_mod #1#2#3% {% \expandafter #1\expandafter #2\csname.=% - \expandafter\XINT:flexpr:two:to:one + \expandafter\XINT:NEhook:twosp \romannumeral`&&@\XINT_expr_unlock #3,!\XINTinFloatMod \endcsname }% \def\XINT_iiexpr_func_mod #1#2#3% {% \expandafter #1\expandafter #2\csname.=% - \expandafter\XINT:expr:two:to:one + \expandafter\XINT:NEhook:twosp \romannumeral`&&@\XINT_expr_unlock #3,!\xintiiMod \endcsname }% \def\XINT_expr_func_binomial #1#2#3% {% \expandafter #1\expandafter #2\csname.=% - \expandafter\XINT:expr:two:to:one + \expandafter\XINT:NEhook:twosp \romannumeral`&&@\XINT_expr_unlock #3,!\xintBinomial \endcsname }% \def\XINT_flexpr_func_binomial #1#2#3% {% \expandafter #1\expandafter #2\csname.=% - \expandafter\XINT:flexpr:two:to:one + \expandafter\XINT:NEhook:twosp \romannumeral`&&@\XINT_expr_unlock #3,!\XINTinFloatBinomial \endcsname }% \def\XINT_iiexpr_func_binomial #1#2#3% {% \expandafter #1\expandafter #2\csname.=% - \expandafter\XINT:expr:two:to:one + \expandafter\XINT:NEhook:twosp \romannumeral`&&@\XINT_expr_unlock #3,!\xintiiBinomial \endcsname }% \def\XINT_expr_func_pfactorial #1#2#3% {% \expandafter #1\expandafter #2\csname.=% - \expandafter\XINT:expr:two:to:one + \expandafter\XINT:NEhook:twosp \romannumeral`&&@\XINT_expr_unlock #3,!\xintPFactorial \endcsname }% \def\XINT_flexpr_func_pfactorial #1#2#3% {% \expandafter #1\expandafter #2\csname.=% - \expandafter\XINT:flexpr:two:to:one + \expandafter\XINT:NEhook:twosp \romannumeral`&&@\XINT_expr_unlock #3,!\XINTinFloatPFactorial \endcsname }% \def\XINT_iiexpr_func_pfactorial #1#2#3% {% \expandafter #1\expandafter #2\csname.=% - \expandafter\XINT:expr:two:to:one + \expandafter\XINT:NEhook:twosp \romannumeral`&&@\XINT_expr_unlock #3,!\xintiiPFactorial \endcsname }% @@ -2506,7 +2588,7 @@ \def\XINT_expr_func_quo #1#2#3% {% \expandafter #1\expandafter #2\csname.=% - \expandafter\XINT:expr:two:to:one + \expandafter\XINT:NEhook:twosp \romannumeral`&&@\XINT_expr_unlock #3,!\xintiQuo \endcsname }% @@ -2514,14 +2596,14 @@ \def\XINT_iiexpr_func_quo #1#2#3% {% \expandafter #1\expandafter #2\csname.=% - \expandafter\XINT:expr:two:to:one + \expandafter\XINT:NEhook:twosp \romannumeral`&&@\XINT_expr_unlock #3,!\xintiiQuo \endcsname }% \def\XINT_expr_func_rem #1#2#3% {% \expandafter #1\expandafter #2\csname.=% - \expandafter\XINT:expr:two:to:one + \expandafter\XINT:NEhook:twosp \romannumeral`&&@\XINT_expr_unlock #3,!\xintiRem \endcsname }% @@ -2529,7 +2611,7 @@ \def\XINT_iiexpr_func_rem #1#2#3% {% \expandafter #1\expandafter #2\csname.=% - \expandafter\XINT:expr:two:to:one + \expandafter\XINT:NEhook:twosp \romannumeral`&&@\XINT_expr_unlock #3,!\xintiiRem \endcsname }% @@ -2806,25 +2888,32 @@ \def\XINT_tmpa #1#2#3#4% {% \def #1##1(##2)##3=##4;{% - \edef\XINT_expr_tmpa {##1}% - \edef\XINT_expr_tmpa {\xint_zapspaces_o \XINT_expr_tmpa}% - \def\XINT_expr_tmpb {0}% - \def\XINT_expr_tmpc {(##4)}% - \xintFor ####1 in {##2} \do - {\edef\XINT_expr_tmpb {\the\numexpr\XINT_expr_tmpb+\xint_c_i}% - \edef\XINT_expr_tmpc {subs(\unexpanded\expandafter{\XINT_expr_tmpc},% - ####1=################\XINT_expr_tmpb)}% + \edef\XINT_deffunc_tmpa {##1}% + \edef\XINT_deffunc_tmpa {\xint_zapspaces_o \XINT_deffunc_tmpa}% + \def\XINT_deffunc_tmpb {0}% + \def\XINT_deffunc_tmpc {(##4)}% + \edef\XINT_deffunc_tmpd {##2}% + \ifnum\xintLength:f:csv{\XINT_deffunc_tmpd}>\xint_c_ + \xintFor ####1 in {\XINT_deffunc_tmpd}\do + {\edef\XINT_deffunc_tmpb {\the\numexpr\XINT_deffunc_tmpb+\xint_c_i}% + \edef\XINT_deffunc_tmpc {subs(\unexpanded\expandafter{\XINT_deffunc_tmpc},% + ####1=################\XINT_deffunc_tmpb)}% }% - \expandafter\XINT_expr_defuserfunc - \csname XINT_#2_func_\XINT_expr_tmpa\expandafter\endcsname - \expandafter{\XINT_expr_tmpa}{#2}% - \expandafter#3\csname XINT_#2_userfunc_\XINT_expr_tmpa\endcsname - [\XINT_expr_tmpb]{\XINT_expr_tmpc}% + \fi + \ifnum\XINT_deffunc_tmpb=\xint_c_ + \expandafter\XINT_expr_defuserfunc_none\csname + \else + \expandafter\XINT_expr_defuserfunc\csname + \fi + XINT_#2_func_\XINT_deffunc_tmpa\expandafter\endcsname + \expandafter{\XINT_deffunc_tmpa}{#2}% + \expandafter#3\csname XINT_#2_userfunc_\XINT_deffunc_tmpa\endcsname + [\XINT_deffunc_tmpb]{\XINT_deffunc_tmpc}% \ifxintverbose\xintMessage {xintexpr}{Info} - {Function \XINT_expr_tmpa\space for \string\xint #4 parser - associated to \string\XINT_#2_userfunc_\XINT_expr_tmpa\space + {Function \XINT_deffunc_tmpa\space for \string\xint #4 parser + associated to \string\XINT_#2_userfunc_\XINT_deffunc_tmpa\space with \ifxintglobaldefs global \fi meaning \expandafter\meaning - \csname XINT_#2_userfunc_\XINT_expr_tmpa\endcsname}% + \csname XINT_#2_userfunc_\XINT_deffunc_tmpa\endcsname}% \fi \xintexprRestoreCatcodes }% @@ -2839,34 +2928,157 @@ {% \XINT_global \def #1##1##2##3{\expandafter ##1\expandafter ##2% - \csname .=\XINT:expr:userfunc{#3}{#2}{\XINT_expr_unlock ##3}\endcsname + \csname.=\XINT:expr:userfunc{#3}{#2}{\XINT_expr_unlock ##3}\endcsname }% }% \def\XINT:expr:userfunc #1#2#3% - {\csname XINT_#1_userfunc_#2\expandafter\endcsname - \romannumeral0\xintcsvtolistnonstripped{#3}}% -\catcode`~ 12 -\def\XINT:newexpr:userfunc #1#2#3% - {~xintExpandArgs{XINT_#1_userfunc_#2}{\xintCSVtoListNonStripped{#3}}}% -\catcode`~ 3 +{% + \csname XINT_#1_userfunc_#2\expandafter\endcsname + \romannumeral0\xintcsvtolistnonstripped{#3}% +}% +\def\XINT_expr_defuserfunc_none #1#2#3% +{% + \XINT_global + \def #1##1##2##3{\expandafter ##1\expandafter ##2% + \csname.=\XINT:expr:userfunc:none{#3}{#2}\endcsname + }% +}% +\def\XINT:expr:userfunc:none #1#2{\csname XINT_#1_userfunc_#2\endcsname}% +\def\XINT_tmpa #1#2#3#4% +{% + \def #1##1(##2)##3=##4;{% + \edef\XINT_defefunc_tmpa {##1}% + \edef\XINT_defefunc_tmpa {\xint_zapspaces_o \XINT_defefunc_tmpa}% + \def\XINT_defefunc_tmpb {0}% + \def\XINT_defefunc_tmpc {(##4)}% + \edef\XINT_defefunc_tmpd {##2}% + \ifnum\xintLength:f:csv{\XINT_defefunc_tmpd}>\xint_c_ + \xintFor ####1 in {\XINT_defefunc_tmpd}\do + {\edef\XINT_defefunc_tmpb {\the\numexpr\XINT_defefunc_tmpb+\xint_c_i}% + \edef\XINT_defefunc_tmpc {subs(\unexpanded\expandafter{\XINT_defefunc_tmpc},% + ####1=################\XINT_defefunc_tmpb)}% + }% + \fi + \expandafter#3\csname XINT_#2_userefunc_\XINT_defefunc_tmpa\endcsname + [\XINT_defefunc_tmpb]{\XINT_defefunc_tmpc}% + \edef\XINT_defefunc_tmpd{\xintLength:f:csv + {\expandafter\meaning\csname + XINT_#2_userfunc_\XINT_defefunc_tmpa\endcsname}}% + \ifcase\XINT_defefunc_tmpb\space + \expandafter\XINT_expr_defuserefunc_none\csname + \or + \expandafter\XINT_expr_defuserefunc_one\csname + \or + \expandafter\XINT_expr_defuserefunc_two\csname + \else + \expandafter\XINT_expr_defuserefunc_many\csname + \fi + XINT_#2_func_\XINT_defefunc_tmpa\expandafter\endcsname + \expandafter{\XINT_defefunc_tmpa}{#2}% + \ifxintverbose\xintMessage {xintexpr}{Info} + {Function \XINT_defefunc_tmpa\space for \string\xint #4 parser + associated to \string\XINT_#2_userefunc_\XINT_defefunc_tmpa\space + with \ifxintglobaldefs global \fi meaning \expandafter\meaning + \csname XINT_#2_userefunc_\XINT_defefunc_tmpa\endcsname}% + \fi + \xintexprRestoreCatcodes + }% +}% +\def\xintdefefunc {\xintexprSafeCatcodes\xintdefefunc_a}% +\def\xintdefiiefunc {\xintexprSafeCatcodes\xintdefiiefunc_a}% +\def\xintdeffloatefunc {\xintexprSafeCatcodes\xintdeffloatefunc_a}% +\XINT_tmpa\xintdefefunc_a {expr} \XINT_NewFunc {expr}% +\XINT_tmpa\xintdefiiefunc_a {iiexpr}\XINT_NewIIFunc {iiexpr}% +\XINT_tmpa\xintdeffloatefunc_a{flexpr}\XINT_NewFloatFunc{floatexpr}% +\def\XINT_expr_defuserefunc_none #1#2#3% +{% + \expandafter\XINT_expr_defuserefunc_none_a + \csname XINT_#3_userefunc_#2\endcsname +}% +\def\XINT_expr_defuserefunc_none_a #1#2% +{% + \XINT_global + \def #2##1##2##3{\expandafter ##1\expandafter ##2\csname.=#1\endcsname}% +}% +\def\XINT_expr_defuserefunc_one #1#2#3% +{% + \expandafter\XINT_expr_defuserefunc_one_a + \csname XINT_#3_userefunc_#2\expandafter\endcsname + \csname XINT_#3_userefunc:f_#2\endcsname #1{#2}{#3}% +}% +\def\XINT_expr_defuserefunc_one_a #1#2#3#4#5% +{% + \XINT_global + \def #2##1{\expandafter#1\expandafter{\romannumeral`&&@##1}}% + \XINT_global + \def #3##1##2##3% + {% + \expandafter ##1\expandafter ##2% + \csname.=\XINT:expr:userefunc:one{#5}{#4}{\XINT_expr_unlock##3}\endcsname + }% +}% +\def\XINT:expr:userefunc:one #1#2#3% +{% + \csname XINT_#1_userefunc_#2\expandafter\endcsname\expandafter + {\romannumeral`&&@#3}% +}% +\def\XINT_expr_defuserefunc_two #1#2#3% +{% + \expandafter\XINT_expr_defuserefunc_two_a + \csname XINT_#3_userefunc:f_#2\endcsname #1{#2}{#3}% +}% +\def\XINT_expr_defuserefunc_two_a #1#2#3#4% +{% + \XINT_global + \def #1##1##2{\xintExpandArgs{XINT_#4_userefunc_#3}{{##1}{##2}}}% + \XINT_global + \def #2##1##2##3% + {% + \expandafter ##1\expandafter ##2% + \csname.=\XINT:expr:userefunc:two{#4}{#3}{\XINT_expr_unlock##3}\endcsname + }% +}% +\def\XINT:expr:userefunc:two #1#2#3% +{% + \expandafter\XINT:expr:userefunc:two_a + \csname XINT_#1_userefunc_#2\expandafter\endcsname + \romannumeral`&&@#3,% +}% +\def\XINT:expr:userefunc:two_a #1#2,#3,{#1{#2}{#3}}% +\def\XINT_expr_defuserefunc_many #1#2#3% +{% + \XINT_global + \def #1##1##2##3% + {% + \expandafter ##1\expandafter ##2% + \csname.=\XINT:expr:userefunc{#3}{#2}{\XINT_expr_unlock##3}\endcsname + }% +}% +\def\XINT:expr:userefunc #1#2#3% +{% + \csname XINT_#1_userefunc_#2\expandafter\endcsname + \romannumeral0\xintcsvtolistnonstripped{#3}% +}% \def\XINT_tmpa #1{\expandafter\def\csname xintunassign#1func\endcsname ##1{% - \edef\XINT_expr_tmpa{##1}% - \edef\XINT_expr_tmpa {\xint_zapspaces_o\XINT_expr_tmpa}% + \edef\XINT_unfunc_tmpa{##1}% + \edef\XINT_unfunc_tmpa {\xint_zapspaces_o\XINT_unfunc_tmpa}% + \XINT_global\expandafter + \let\csname XINT_#1_func_\XINT_unfunc_tmpa\endcsname\xint_undefined \XINT_global\expandafter - \let\csname XINT_#1_func_\XINT_expr_tmpa\endcsname\xint_undefined + \let\csname XINT_#1_userfunc_\XINT_unfunc_tmpa\endcsname\xint_undefined \XINT_global\expandafter - \let\csname XINT_#1_userfunc_\XINT_expr_tmpa\endcsname\xint_undefined + \let\csname XINT_#1_userefunc_\XINT_unfunc_tmpa\endcsname\xint_undefined \ifxintverbose\xintMessage {xintexpr}{Info} - {Function \XINT_expr_tmpa\space for \string\xint #1 parser now + {Function \XINT_unfunc_tmpa\space for \string\xint #1 parser now \ifxintglobaldefs globally \fi undefined.}% \fi}}% \XINT_tmpa{expr}\XINT_tmpa{iiexpr}\XINT_tmpa{floatexpr}% \def\XINT_expr_wrapit #1{\expandafter\XINT_expr_wrap\csname.=#1\endcsname}% \def\xintNewFunction #1#2[#3]#4% {% - \edef\XINT_expr_tmpa {#1}% - \edef\XINT_expr_tmpa {\xint_zapspaces_o \XINT_expr_tmpa}% - \def\XINT_expr_tmpb ##1##2##3##4##5##6##7##8##9{#4}% + \edef\XINT_newfunc_tmpa {#1}% + \edef\XINT_newfunc_tmpa {\xint_zapspaces_o \XINT_newfunc_tmpa}% + \def\XINT_newfunc_tmpb ##1##2##3##4##5##6##7##8##9{#4}% \begingroup \ifcase #3\relax \toks0{}% @@ -2883,26 +3095,26 @@ \expandafter \endgroup\expandafter \XINT_global\expandafter - \def\csname XINT_expr_macrofunc_\XINT_expr_tmpa\expandafter\endcsname - \the\toks0\expandafter{\XINT_expr_tmpb + \def\csname XINT_expr_macrofunc_\XINT_newfunc_tmpa\expandafter\endcsname + \the\toks0\expandafter{\XINT_newfunc_tmpb {\XINT_expr_wrapit{##1}}{\XINT_expr_wrapit{##2}}{\XINT_expr_wrapit{##3}}% {\XINT_expr_wrapit{##4}}{\XINT_expr_wrapit{##5}}{\XINT_expr_wrapit{##6}}% {\XINT_expr_wrapit{##7}}{\XINT_expr_wrapit{##8}}{\XINT_expr_wrapit{##9}}}% \expandafter\XINT_expr_newfunction - \csname XINT_expr_func_\XINT_expr_tmpa\expandafter\endcsname - \expandafter{\XINT_expr_tmpa}{eval}\xintbareeval + \csname XINT_expr_func_\XINT_newfunc_tmpa\expandafter\endcsname + \expandafter{\XINT_newfunc_tmpa}{eval}\xintbareeval \expandafter\XINT_expr_newfunction - \csname XINT_iiexpr_func_\XINT_expr_tmpa\expandafter\endcsname - \expandafter{\XINT_expr_tmpa}{iieval}\xintbareiieval + \csname XINT_iiexpr_func_\XINT_newfunc_tmpa\expandafter\endcsname + \expandafter{\XINT_newfunc_tmpa}{iieval}\xintbareiieval \expandafter\XINT_expr_newfunction - \csname XINT_flexpr_func_\XINT_expr_tmpa\expandafter\endcsname - \expandafter{\XINT_expr_tmpa}{floateval}\xintbarefloateval + \csname XINT_flexpr_func_\XINT_newfunc_tmpa\expandafter\endcsname + \expandafter{\XINT_newfunc_tmpa}{floateval}\xintbarefloateval \ifxintverbose \xintMessage {xintexpr}{Info} - {Function \XINT_expr_tmpa\space for the expression parsers is - associated to \string\XINT_expr_macrofunc_\XINT_expr_tmpa\space + {Function \XINT_newfunc_tmpa\space for the expression parsers is + associated to \string\XINT_expr_macrofunc_\XINT_newfunc_tmpa\space with \ifxintglobaldefs global \fi meaning \expandafter\meaning - \csname XINT_expr_macrofunc_\XINT_expr_tmpa\endcsname}% + \csname XINT_expr_macrofunc_\XINT_newfunc_tmpa\endcsname}% \fi }% \def\XINT_expr_newfunction #1#2#3#4% @@ -2953,6 +3165,7 @@ \def\XINT_applyon:::_end #1,#2#3#4{\xint_secondoftwo #4}% \catcode`~ 12 \catcode`$ 12 % $ +\def\xint_dfork #1$#2#3\krof {#2}% $ \def\xint_ddfork #1$$#2#3\krof {#2}% $$ \def\XINT:NE:RApply::csv #1#2#3#4% {~xintApply::csv{~expandafter #2~xint_exchangetwo_keepbraces{#4}}{#3}}% @@ -2979,13 +3192,75 @@ \if #2~\xint_dothis{#4}\fi \xint_orthat{#3}% }% +\def\XINT:NE:twosp#1#2,#3#4,!#5% +{% + \XINT:NE:two_fork_dd#1#3{#5}{\detokenize{#5}}{#1#2}{#3#4}% +}% \def\XINT:NE:one#1#2{\expandafter\XINT:NE:one_a\romannumeral`&&@#2!#1}% -\def\XINT:NE:one_a#1#2!#3{% +\def\XINT:NE:one_a#1#2!#3% +{% \if ###1\xint_dothis {\detokenize{#3}}\fi \if ~#1\xint_dothis {\detokenize{#3}}\fi \if $#1\xint_dothis {~xintApply::csv{\detokenize{#3}}}\fi %$ \xint_orthat #3{#1#2}% }% +\def\XINT:NE:userfunc #1#2#3% + {~xintExpandArgs{XINT_#1_userfunc_#2}{\xintCSVtoListNonStripped{#3}}}% +\def\XINT:NE:userfunc:none #1#2{~!{XINT_#1_userfunc_#2}}% +\def\XINT:NE:userefunc:one#1#2#3% + {\expandafter\XINT:NE:userefunc:one_a\romannumeral`&&@#3!{#1}{#2}}% +\def\XINT:NE:userefunc:one_a#1#2!#3#4% +{% + \if ###1\xint_dothis {~!{XINT_#3_userefunc:f_#4}}\fi + \if ~#1\xint_dothis {~!{XINT_#3_userefunc:f_#4}}\fi + \if $#1\xint_dothis {~xintApply::csv~!{XINT_#3_userefunc:f_#4}}\fi %$ + \xint_orthat {\csname XINT_#3_userefunc_#4\endcsname}% + {#1#2}% +}% +\def\XINT:NE:twosp#1#2,#3#4,!#5% +{% + \XINT:NE:two_fork_dd#1#3{#5}{\detokenize{#5}}{#1#2}{#3#4}% +}% +\def\XINT:NE:userefunc:two#1#2#3% + {\expandafter\XINT:NE:userefunc:two_a\romannumeral`&&@#3,!{#1}{#2}}% +\def\XINT:NE:userefunc:two_a#1#2,#3#4,!#5#6% +{% + \XINT:NE:two_fork_dd#1#3{\csname XINT_#5_userefunc_#6\endcsname}% + {~!{XINT_#5_userefunc:f_#6}}% + {#1#2}{#3#4}% +}% +\def\XINT:NE:userefunc#1#2#3% +{% + \expandafter\XINT:NE:userefunc_a\romannumeral`&&@#3,2,3,4,5,6,7,8,9,!% + {#1}{#2}{#3}% +}% +\def\XINT:NE:userefunc_a#1#2,#3#4,#5#6,#7#8,#9% +{% + \XINT:NE:userefunc_b{#1#3#5#7#9}% +}% +\def\XINT:NE:userefunc_b#1#2,#3#4,#5#6,#7#8,#9% +{% + \XINT:NE:userefunc_c{#1#3#5#7#9}% +}% +\def\XINT:NE:iftilde #1~#2#3\relax{\unless\if !#21\fi}% +\def\XINT:NE:ifdollar #1$#2#3\relax{\unless\if !#21\fi}%$ +\def\XINT:NE:ifhash#1{% +\def\XINT:NE:ifhash##1#1##2##3\relax{\unless\if !##21\fi}% +}\expandafter\XINT:NE:ifhash\string#% +\def\XINT:NE:userefunc_c#1#2!% +{% + \if0\XINT:NE:iftilde #1~!\relax\XINT:NE:ifdollar #1$!\relax%$ + \XINT:NE:ifhash #1##!\relax 0% + \expandafter\XINT:NE:userefunc_x + \else + \expandafter\XINT:NE:userefunc_p + \fi +}% +\def\XINT:NE:userefunc_x#1#2% + {\csname XINT_#1_userefunc_#2\expandafter\endcsname + \romannumeral0\xintcsvtolistnonstripped}% +\def\XINT:NE:userefunc_p #1#2#3% + {~xintExpandArgs{XINT_#1_userefunc_#2}{\xintCSVtoListNonStripped{#3}}}% \def\XINT:NE:oneopt#1[#2]#3% {\expandafter\XINT:NE:oneopt_a\romannumeral`&&@#3!{#2}#1}% \def\XINT:NE:oneopt_a#1#2!#3#4% @@ -3032,11 +3307,6 @@ {\expandafter\XINT:newexpr:insertdollar\detokenize{#3}}% {#1}{#2}% }% -\def\XINT:newexpr:two:to:one #1,#2,!#3% -{% - \XINT:NE:two#3{#1}{#2}% -}% -\let\XINT:newflexpr:two:to:one\XINT:newexpr:two:to:one \def\xintiiifNotZeroNE:#1#2,#3,#4,% {% \if1\if###11\else\if~#11\else\if$#11\else0%$ @@ -3086,20 +3356,23 @@ {#1#2}{#3}{#4}{#5}% }% \def\XINT_expr_redefinemacros {% - \let\XINT:NEhook:one\XINT:NE:one - \let\XINT:NEhook:two\XINT:NE:two - \let\XINT:NEhook:csv\XINT:NE:csv + \let\XINT:NEhook:one \XINT:NE:one + \let\XINT:NEhook:two \XINT:NE:two + \let\XINT:NEhook:csv \XINT:NE:csv + \let\XINT:NEhook:twosp\XINT:NE:twosp + \let\XINT:expr:userfunc \XINT:NE:userfunc + \let\XINT:expr:userfunc:none \XINT:NE:userfunc:none + \let\XINT:expr:userefunc \XINT:NE:userefunc + \let\XINT:expr:userefunc:one \XINT:NE:userefunc:one + \let\XINT:expr:userefunc:two \XINT:NE:userefunc:two + \let\XINT:expr:macrofunc \XINT:newexpr:macrofunc \let\XINT:expr:one:and:opt \XINT:newexpr:one:and:opt \let\XINT:expr:one:or:two:nums \XINT:newexpr:one:or:two:nums \let\XINT:iiexpr:one:or:two: \XINT:newiiexpr:one:or:two: \let\XINT:expr:tacitzeroifonearg \XINT:newexpr:tacitzeroifonearg \let\XINT:iiexpr:tacitzeroifonearg \XINT:newiiexpr:tacitzeroifonearg - \let\XINT:expr:two:to:two \XINT:newexpr:two:to:two - \let\XINT:expr:two:to:one \XINT:newexpr:two:to:one - \let\XINT:flexpr:two:to:one \XINT:newflexpr:two:to:one - \let\XINT:expr:two:to:one \XINT:newexpr:two:to:one - \let\XINT:flexpr:two:to:two \XINT:newflexpr:two:to:two - \let\XINT:flexpr:two:to:one \XINT:newflexpr:two:to:one + \let\XINT:expr:two:to:two \XINT:newexpr:two:to:two + \let\XINT:flexpr:two:to:two \XINT:newflexpr:two:to:two \let\xintiiifNotZero: \xintiiifNotZeroNE: \let\xintifInt: \xintifIntNE: \let\xintifFloatInt: \xintifFloatIntNE: @@ -3125,8 +3398,6 @@ \def\XINTinFloatSeqB::csv {\XINT:NE:two_\XINTinFloatSeqBNumeric::csv{$noexpand$XINTinFloatSeqB:f:csv}}% \def\xintListSel:x:csv {~xintListSel:f:csv }% - \let\XINT:expr:userfunc \XINT:newexpr:userfunc - \let\XINT:expr:macrofunc\XINT:newexpr:macrofunc \def\XINTinRandomFloatSdigits{~XINTinRandomFloatSdigits }% \def\XINTinRandomFloatSixteen{~XINTinRandomFloatSixteen }% \def\xintiiRandRange{~xintiiRandRange }% @@ -3135,21 +3406,26 @@ \def\XINT_expr_redefineprints {% \def\XINT_flexpr_noopt - {\expandafter\XINT_flexpr_withopt_b\expandafter-\romannumeral0\xintbarefloateval }% - \def\XINT_flexpr_withopt_b ##1##2% - {\expandafter\XINT_flexpr_wrap\csname .;##1.=\XINT_expr_unlock ##2\endcsname }% + {% + \expandafter + \XINT_flexpr_preprint\expandafter-\romannumeral0\xintbarefloateval + }% + \def\XINT_flexpr_preprint ##1##2% + {% + \expandafter\XINT_flexpr_wrap + \csname .;##1.=\XINT_expr_unlock##2\endcsname + }% \def\XINT_expr_unlock_sp ##1.;##2##3.=##4!% - {\if -##2\expandafter\xint_firstoftwo\else\expandafter\xint_secondoftwo\fi - \XINTdigits{{##2##3}}{##4}}% - \def\XINT_expr_print ##1% - {\expandafter\xintSPRaw::csv\expandafter - {\romannumeral`&&@\XINT_expr_unlock ##1}}% - \def\XINT_iiexpr_print ##1% - {\expandafter\xintCSV::csv\expandafter - {\romannumeral`&&@\XINT_expr_unlock ##1}}% - \def\XINT_boolexpr_print ##1% - {\expandafter\xintIsTrue::csv\expandafter - {\romannumeral`&&@\XINT_expr_unlock ##1}}% + {% + \if -##2\expandafter\xint_firstoftwo\else\expandafter\xint_secondoftwo\fi + \XINTdigits{{##2##3}}{##4}% + }% + \def\XINT_expr_print ##1{\expandafter + \xintSPRaw::csv\expandafter{\romannumeral`&&@\XINT_expr_unlock ##1}}% + \def\XINT_iiexpr_print ##1{\expandafter + \xintCSV::csv\expandafter{\romannumeral`&&@\XINT_expr_unlock ##1}}% + \def\XINT_boolexpr_print ##1{\expandafter + \xintIsTrue::csv\expandafter{\romannumeral`&&@\XINT_expr_unlock ##1}}% \def\xintCSV::csv {~xintCSV::csv }% \def\xintSPRaw::csv {~xintSPRaw::csv }% \def\xintPFloat::csv {~xintPFloat::csv }% @@ -3168,11 +3444,11 @@ \xinttheboolexpr\XINT_newexpr_clean}% \def\XINT_newexpr_clean #1>{\noexpand\romannumeral`&&@}% \def\XINT_NewFunc - {\XINT_NewExpr{}\xint_gobble_i\xintthebareeval\XINT_newfunc_clean}% + {\XINT_NewExpr\XINT_expr_redefineprints\xint_gobble_i\xintthebareeval\XINT_newfunc_clean}% \def\XINT_NewFloatFunc - {\XINT_NewExpr{}\xint_gobble_i\xintthebarefloateval\XINT_newfunc_clean}% + {\XINT_NewExpr\XINT_expr_redefineprints\xint_gobble_i\xintthebarefloateval\XINT_newfunc_clean}% \def\XINT_NewIIFunc - {\XINT_NewExpr{}\xint_gobble_i\xintthebareiieval\XINT_newfunc_clean}% + {\XINT_NewExpr\XINT_expr_redefineprints\xint_gobble_i\xintthebareiieval\XINT_newfunc_clean}% \def\XINT_newfunc_clean #1>{}% \def\XINT_NewExpr #1#2#3#4#5#6[#7]% {% @@ -3198,7 +3474,7 @@ \def\XINT_NewExpr_a %1%2%3%4%5@ {@ \def\XINT_tmpa %%1%%2%%3%%4%%5%%6%%7%%8%%9{%5}@ - \def~{$noexpand$}@ + \def~%%1{\if !%%1\noexpand~\else $noexpand$%%1\fi}@ \catcode`: 11 \catcode`_ 11 \catcode`# 12 \catcode`~ 13 \escapechar 126 \endlinechar -1 \everyeof {\noexpand }@ @@ -3207,6 +3483,7 @@ %2\XINT_tmpa{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9}\relax}@ }@ \escapechar 92 \catcode`# 6 \catcode`$ 0 @ $ + \def~%%1{\expandafter\noexpand\csname %%1\endcsname}@ \edef\XINT_tmpa %%1%%2%%3%%4%%5%%6%%7%%8%%9@ {\scantokens\expandafter{\expandafter%3\meaning\XINT_tmpb}}@ \the\toks0\expandafter @@ -3218,6 +3495,7 @@ \fi}@ }@ \catcode`% 14 +\XINT_setcatcodes % clean up to avoid surprises if something changes \newif\ifxintexprsafecatcodes \let\xintexprRestoreCatcodes\empty \def\xintexprSafeCatcodes @@ -3277,7 +3555,13 @@ \catcode96=12 % ` \catcode32=10 % space }% -\let\XINT_tmpa\relax \let\XINT_tmpb\relax \let\XINT_tmpc\relax +\let\XINT_tmpa\undefined \let\XINT_tmpb\undefined \let\XINT_tmpc\undefined +\ifdefined\RequirePackage\expandafter\xint_firstoftwo\else\expandafter\xint_secondoftwo\fi +{\RequirePackage{xinttrig}% +\RequirePackage{xintlog}}% +{\input xinttrig.sty +\input xintlog.sty +}% \XINT_restorecatcodes_endinput% \endinput %% |