diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/xint/xintexpr.sty')
-rw-r--r-- | Master/texmf-dist/tex/generic/xint/xintexpr.sty | 670 |
1 files changed, 397 insertions, 273 deletions
diff --git a/Master/texmf-dist/tex/generic/xint/xintexpr.sty b/Master/texmf-dist/tex/generic/xint/xintexpr.sty index 409b7c83fe5..0565e1d0212 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 (version 1.09h of November 28, 2013) +%% The xint bundle (version 1.09i of December 18, 2013) %% xintexpr: Expandable expression parser %% Copyright (C) 2013 by Jean-Francois Burnol %%---------------------------------------------------------------- @@ -103,109 +103,123 @@ \XINTsetupcatcodes% \XINT_providespackage \ProvidesPackage{xintexpr}% - [2013/11/28 v1.09h Expandable expression parser (jfB)]% -\def\xint_gob_til_dot #1.{}% -\def\xint_gob_til_dot_andstop #1.{ }% -\def\xint_gob_til_! #1!{}% nota bene: ! is of catcode 11 + [2013/12/18 v1.09i Expandable expression parser (jfB)]% +\def\xint_gob_til_! #1!{}% nota bene: ! is of catcode 11 +\edef\XINT_expr_lock #1!% + {\noexpand\expandafter\space\noexpand\csname .=#1\noexpand\endcsname }% +\def\XINT_expr_unlock {\expandafter\XINT_expr_unlock_a\string }% +\def\XINT_expr_unlock_a #1.={}% \def\XINT_expr_unexpectedtoken {\xintError:ignored }% -\def\XINT_newexpr_stripprefix #1>{\noexpand\romannumeral-`0}% -\def\XINT_expr_lock #1!{\expandafter\space\csname .#1\endcsname }% -\def\XINT_expr_unlock {\expandafter\xint_gob_til_dot\string }% -\def\XINT_expr_usethe {use_xintthe!\xintError:use_xintthe! }% +\def\XINT_newexpr_setprefix #1>{\noexpand\romannumeral-`0}% +\def\xint_UDxintrelaxfork #1\xint_relax #2#3\krof {#2}% \def\XINT_expr_done {!\XINT_expr_usethe\XINT_expr_print }% -\def\XINT_expr_print #1{\XINT_expr_unlock #1}% -\def\XINT_flexpr_done {!\XINT_expr_usethe\XINT_flexpr_print }% -\def\XINT_flexpr_print #1{\xintFloat:csv{\XINT_expr_unlock #1}}% -\def\XINT_numexpr_print #1{\xintRound:csv{\XINT_expr_unlock #1}}% +\let\XINT_iiexpr_done \XINT_expr_done +\def\XINT_iexpr_done {!\XINT_expr_usethe\XINT_iexpr_print }% +\def\XINT_flexpr_done {!\XINT_expr_usethe\XINT_flexpr_print }% +\def\XINT_boolexpr_done{!\XINT_expr_usethe\XINT_boolexpr_print }% +\def\XINT_expr_usethe {use_xintthe!\xintError:use_xintthe! }% +\def\xintthe #1{\romannumeral-`0\expandafter\xint_gobble_ii\romannumeral-`0#1}% +\let\XINT_expr_print \XINT_expr_unlock +\def\XINT_iexpr_print #1{\xintRound:csv {\XINT_expr_unlock #1}}% +\def\XINT_flexpr_print #1{\xintFloat:csv {\XINT_expr_unlock #1}}% \def\XINT_boolexpr_print #1{\xintIsTrue:csv{\XINT_expr_unlock #1}}% -\def\xintifboolexpr #1{\romannumeral0\xintifnotzero {\xinttheexpr #1\relax}}% -\def\xintifboolfloatexpr #1{\romannumeral0\xintifnotzero - {\xintthefloatexpr #1\relax}}% -\def\xintexpr {\romannumeral0\xinteval }% +\def\xintexpr {\romannumeral0\xinteval }% +\def\xintfloatexpr {\romannumeral0\xintfloateval }% +\def\xintiiexpr {\romannumeral0\xintiieval }% \def\xinteval -{% - \expandafter\XINT_expr_until_end_a \romannumeral-`0\XINT_expr_getnext -}% -\def\xinttheeval {\expandafter\xint_gobble_ii\romannumeral0\xinteval }% -\def\xinttheexpr {\romannumeral-`0\xinttheeval }% -\def\XINT_numexpr_post !\XINT_expr_usethe\XINT_expr_print% - { !\XINT_expr_usethe\XINT_numexpr_print }% -\def\xintnumexpr {\romannumeral0\expandafter\XINT_numexpr_post - \romannumeral0\xinteval }% -\def\xintthenumexpr {\romannumeral-`0\xintthe\xintnumexpr }% -\def\XINT_boolexpr_post !\XINT_expr_usethe\XINT_expr_print% - { !\XINT_expr_usethe\XINT_boolexpr_print }% -\def\xintboolexpr {\romannumeral0\expandafter\XINT_boolexpr_post - \romannumeral0\xinteval }% -\def\xinttheboolexpr {\romannumeral-`0\xintthe\xintboolexpr }% -\def\xintfloatexpr {\romannumeral0\xintfloateval }% + {\expandafter\XINT_expr_until_end_a \romannumeral-`0\XINT_expr_getnext }% \def\xintfloateval -{% - \expandafter\XINT_flexpr_until_end_a \romannumeral-`0\XINT_expr_getnext -}% -\def\xintthefloatexpr {\romannumeral-`0\xintthe\xintfloatexpr }% -\def\xintthe #1{\romannumeral-`0\expandafter\xint_gobble_ii\romannumeral-`0#1}% + {\expandafter\XINT_flexpr_until_end_a\romannumeral-`0\XINT_expr_getnext }% +\def\xintiieval + {\expandafter\XINT_iiexpr_until_end_a\romannumeral-`0\XINT_expr_getnext }% +\def\xinttheexpr + {\romannumeral-`0\expandafter\xint_gobble_ii\romannumeral0\xinteval }% +\def\xintthefloatexpr + {\romannumeral-`0\expandafter\xint_gobble_ii\romannumeral0\xintfloateval }% +\def\xinttheiiexpr + {\romannumeral-`0\expandafter\xint_gobble_ii\romannumeral0\xintiieval }% +\def\xintiexpr {\romannumeral0\expandafter\expandafter\expandafter + \XINT_iexpr_done \expandafter\xint_gobble_iii\romannumeral0\xinteval }% +\def\xinttheiexpr {\romannumeral-`0\expandafter\expandafter\expandafter + \XINT_iexpr_print\expandafter\xint_gobble_iii\romannumeral0\xinteval }% +\def\xintboolexpr {\romannumeral0\expandafter\expandafter\expandafter + \XINT_boolexpr_done \expandafter\xint_gobble_iii\romannumeral0\xinteval }% +\def\xinttheboolexpr {\romannumeral-`0\expandafter\expandafter\expandafter + \XINT_boolexpr_print\expandafter\xint_gobble_iii\romannumeral0\xinteval }% +\let\xintnumexpr \xintiexpr % deprecated +\let\xintthenumexpr\xinttheiexpr % deprecated +\def\xintifboolexpr #1% + {\romannumeral0\xintifnotzero {\xinttheexpr #1\relax}}% +\def\xintifboolfloatexpr #1% + {\romannumeral0\xintifnotzero {\xintthefloatexpr #1\relax}}% +\def\xintifbooliiexpr #1% + {\romannumeral0\xintifnotzero {\xinttheiiexpr #1\relax}}% \def\XINT_expr_getnext {% \expandafter\XINT_expr_getnext_checkforbraced_a \romannumeral-`0\romannumeral-`0% }% -\def\XINT_expr_getnext_checkforbraced_a #1% +\def\XINT_expr_getnext_checkforbraced_a #1% was done later in <1.09i {% - \XINT_expr_getnext_checkforbraced_b #1\W\Z {#1}% -}% -\def\XINT_expr_getnext_checkforbraced_b #1#2% -{% - \xint_UDwfork - #1\dummy \XINT_expr_getnext_emptybracepair - #2\dummy \XINT_expr_getnext_onetoken_perhaps - \W\dummy \XINT_expr_getnext_gotbracedstuff - \krof -}% -\def\XINT_expr_getnext_onetoken_perhaps\Z #1% -{% - \expandafter\XINT_expr_getnext_checkforbraced_c\expandafter + \expandafter\XINT_expr_getnext_checkforbraced_b\expandafter {\romannumeral-`0#1}% }% -\def\XINT_expr_getnext_checkforbraced_c #1% +\def\XINT_expr_getnext_checkforbraced_b #1% {% - \XINT_expr_getnext_checkforbraced_d #1\W\Z {#1}% + \XINT_expr_getnext_checkforbraced_c #1\xint_relax\Z {#1}% }% -\def\XINT_expr_getnext_checkforbraced_d #1#2% +\def\XINT_expr_getnext_checkforbraced_c #1#2% {% - \xint_UDwfork - #1\dummy \XINT_expr_getnext_emptybracepair - #2\dummy \XINT_expr_getnext_onetoken_wehope - \W\dummy \XINT_expr_getnext_gotbracedstuff + \xint_UDxintrelaxfork + #1\XINT_expr_getnext_wasemptyorspace + #2\XINT_expr_getnext_gotonetoken_wehope + \xint_relax\XINT_expr_getnext_gotbracedstuff \krof }% doubly braced things are not acceptable, will cause errors. -\def\XINT_expr_getnext_emptybracepair #1{\XINT_expr_getnext }% -\def\XINT_expr_getnext_gotbracedstuff #1\W\Z #2% {..} -> number/fraction +\def\XINT_expr_getnext_wasemptyorspace #1{\XINT_expr_getnext }% +\def\XINT_expr_getnext_gotbracedstuff #1\xint_relax\Z #2% {% - \expandafter\XINT_expr_getop\csname .#2\endcsname + \expandafter\XINT_expr_getop\csname .=#2\endcsname }% -\def\XINT_expr_getnext_onetoken_wehope\Z #1% #1 isn't a control sequence! -{% +\def\XINT_expr_getnext_gotonetoken_wehope\Z #1% +{% screens out sub-expressions and \count or \dimen registers/variables \xint_gob_til_! #1\XINT_expr_subexpr !% - \expandafter\XINT_expr_getnext_onetoken_fork\string #1% -}% after this #1 should be now a catcode 12 token. -\def\XINT_expr_subexpr !#1!{\expandafter\XINT_expr_getop\xint_gobble_ii }% + \ifcat\relax#1% \count or \numexpr etc... token or count, dimen, skip cs + \expandafter\XINT_expr_countdimenetc_fork + \else + \expandafter\expandafter\expandafter + \XINT_expr_getnext_onetoken_fork\expandafter\string + \fi + #1% +}% +\def\XINT_expr_subexpr !#1\fi {\expandafter\XINT_expr_getop\xint_gobble_iii }% +\def\XINT_expr_countdimenetc_fork #1% +{% + \ifx\count#1\else\ifx#1\dimen\else\ifx#1\numexpr\else\ifx#1\dimexpr\else + \ifx\skip#1\else\ifx\glueexpr#1\else + \XINT_expr_unpackvariable + \fi\fi\fi\fi\fi\fi + \expandafter\XINT_expr_getnext\number #1% +}% +\def\XINT_expr_unpackvariable\fi\fi\fi\fi\fi\fi\expandafter\XINT_expr_getnext + \number #1{\fi\fi\fi\fi\fi\fi + \expandafter\XINT_expr_getop\csname .=\number#1\endcsname }% \begingroup \lccode`*=`# \lowercase{\endgroup -\def\XINT_expr_sixwayfork #1(-.+*\dummy #2#3\krof {#2}% +\def\XINT_expr_sixwayfork #1(-.+*#2#3\krof {#2}% \def\XINT_expr_getnext_onetoken_fork #1% -{% The * is in truth catcode 12 #. For (clever!) use with \xintNewExpr. +{% The * is in truth catcode 12 #. For (hacking) use with \xintNewExpr. \XINT_expr_sixwayfork - #1-.+*\dummy {\xint_c_xviii ({}}% back to until to trigger oparen - (#1.+*\dummy -% - (-#1+*\dummy {\XINT_expr_scandec_II.}% - (-.#1*\dummy \XINT_expr_getnext% - (-.+#1\dummy {\XINT_expr_scandec_II}% - (-.+*\dummy {\XINT_expr_scan_dec_or_func #1}% + #1-.+*{\xint_c_xviii ({}}% back to until for oparen triggering + (#1.+*-% + (-#1+*{\XINT_expr_scandec_II.}% + (-.#1*\XINT_expr_getnext% + (-.+#1{\XINT_expr_scandec_II}% + (-.+*{\XINT_expr_scan_dec_or_func #1}% \krof }}% -\def\XINT_expr_scan_dec_or_func #1% this #1 of catcode 12 +\def\XINT_expr_scan_dec_or_func #1% this #1 has necessarily here catcode 12 {% \ifnum \xint_c_ix<1#1 \expandafter\XINT_expr_scandec_I @@ -230,18 +244,17 @@ \xint_afterfi{\expandafter\XINT_expr_scanfunc_b \string #1}% \fi }% +\def\xint_UDparenfork #1()#2#3\krof {#2}% \def\XINT_expr_scanfunc_b #1% {% - \if #1(\expandafter \xint_gobble_iii\fi - \xint_firstofone - {% added in 1.09c for bool and togl - \if #1)\expandafter \xint_gobble_i - \else \expandafter \xint_firstoftwo - \fi }% - {\XINT_expr_scanfunc_c #1}(% + \xint_UDparenfork + #1){(}% and then \XINT_expr_func + (#1{(}% and then \XINT_expr_func (this is for bool/toggle names) + (){\XINT_expr_scanfunc_c #1}% + \krof }% \def\XINT_expr_scanfunc_panic {\xintError:bigtroubleahead(0\relax }% -\def\XINT_expr_func #1(% common to expr and flexpr +\def\XINT_expr_func #1(% common to expr and flexpr and iiexpr {% \xint_c_xviii @{#1}% functions have the highest priority. }% @@ -255,17 +268,24 @@ \expandafter\XINT_expr_getop\romannumeral-`0\expandafter \XINT_expr_lock\romannumeral-`0\XINT_expr_scanfracpart_b }% -\def\XINT_expr_scanintpart_a #1% +\def\XINT_expr_scanintpart_a #1% Please no braced material: 123{FORBIDDEN} +{% + \ifcat #1\relax + \expandafter !% + \else \expandafter\expandafter\expandafter + \XINT_expr_scanintpart_aa\expandafter\string + \fi #1% +}% +\def\XINT_expr_scanintpart_aa #1% {% - \ifnum \xint_c_ix<1\string#1 - \expandafter\expandafter\expandafter\XINT_expr_scanintpart_b - \expandafter\string + \ifnum \xint_c_ix<1#1 + \expandafter\XINT_expr_scanintpart_b \else - \if #1.% + \if .#1% \expandafter\expandafter\expandafter \XINT_expr_scandec_transition - \else - \expandafter\expandafter\expandafter !% ! of catcode 11... + \else % gather what we got so far, leave catcode 12 #1 in stream + \expandafter\expandafter\expandafter !% ! of catcode 11 ... \fi \fi #1% @@ -282,9 +302,16 @@ }% \def\XINT_expr_scanfracpart_a #1% {% - \ifnum \xint_c_ix<1\string#1 - \expandafter\expandafter\expandafter\XINT_expr_scanfracpart_b - \expandafter\string + \ifcat #1\relax + \expandafter !% + \else \expandafter\expandafter\expandafter + \XINT_expr_scanfracpart_aa\expandafter\string + \fi #1% +}% +\def\XINT_expr_scanfracpart_aa #1% +{% + \ifnum \xint_c_ix<1#1 + \expandafter\XINT_expr_scanfracpart_b \else \expandafter !% \fi @@ -301,23 +328,18 @@ \romannumeral-`0\romannumeral-`0% }% \def\XINT_expr_getop_a #1#2% -{% if an un-expandable control sequence is found, must be the ending \relax - \ifcat #2\relax - \ifx #2\relax - \expandafter\expandafter\expandafter - \XINT_expr_foundend - \else - \XINT_expr_unexpectedtoken - \expandafter\expandafter\expandafter - \XINT_expr_getop - \fi - \else - \expandafter\XINT_expr_foundop\expandafter #2% +{% if a control sequence is found, must be either \relax or register|variable + \ifcat #2\relax\expandafter\xint_firstoftwo + \else \expandafter\xint_secondoftwo \fi - #1% + {\ifx #2\relax\expandafter\XINT_expr_foundend\expandafter#1% + \else + \xint_afterfi{\XINT_expr_foundop *#1#2}% + \fi }% + {\XINT_expr_foundop #2#1}% }% \def\XINT_expr_foundend {\xint_c_ \relax }% \relax is a place holder here. -\def\XINT_expr_foundop #1% then becomes <prec> <op> and is followed by <\.f> +\def\XINT_expr_foundop #1% then becomes <prec> <op> and is followed by <\.=f> {% 1.09a: no control sequence \XINT_expr_op_#1, code common to expr/flexpr \ifcsname XINT_expr_precedence_#1\endcsname \expandafter\xint_afterfi\expandafter @@ -332,43 +354,38 @@ \def#1##1% {% \xint_UDsignfork - ##1\dummy {\expandafter#1\romannumeral-`0#3}% - -\dummy {#2##1}% + ##1{\expandafter#1\romannumeral-`0#3}% + -{#2##1}% \krof }% \def#2##1##2% {% \ifcase ##1\expandafter #4% - \or \xint_afterfi{% - \XINT_expr_extra_closing_paren - \expandafter #1\romannumeral-`0\XINT_expr_getop - }% - \else \xint_afterfi{% - \expandafter#1\romannumeral-`0\csname XINT_#5_op_##2\endcsname - }% + \or\xint_afterfi{% + \XINT_expr_extra_closing_paren + \expandafter #1\romannumeral-`0\XINT_expr_getop + }% + \else + \xint_afterfi{\expandafter#1\romannumeral-`0\csname XINT_#5_op_##2\endcsname }% \fi }% }% +\xintFor #1 in {expr,flexpr,iiexpr} \do {% \expandafter\XINT_tmpa - \csname XINT_expr_until_end_a\expandafter\endcsname - \csname XINT_expr_until_end_b\expandafter\endcsname - \csname XINT_expr_op_-vi\expandafter\endcsname - \csname XINT_expr_done\endcsname - {expr}% -\expandafter\XINT_tmpa - \csname XINT_flexpr_until_end_a\expandafter\endcsname - \csname XINT_flexpr_until_end_b\expandafter\endcsname - \csname XINT_flexpr_op_-vi\expandafter\endcsname - \csname XINT_flexpr_done\endcsname - {flexpr}% + \csname XINT_#1_until_end_a\expandafter\endcsname + \csname XINT_#1_until_end_b\expandafter\endcsname + \csname XINT_#1_op_-vi\expandafter\endcsname + \csname XINT_#1_done\endcsname + {#1}% +}% \def\XINT_expr_extra_closing_paren {\xintError:removed }% \def\XINT_tmpa #1#2#3#4#5#6% {% \def #1{\expandafter #3\romannumeral-`0\XINT_expr_getnext }% \let #2#1% \def #3##1{\xint_UDsignfork - ##1\dummy {\expandafter #3\romannumeral-`0#5}% - -\dummy {#4##1}% + ##1{\expandafter #3\romannumeral-`0#5}% + -{#4##1}% \krof }% \def #4##1##2% {% @@ -379,26 +396,23 @@ \fi }% }% +\xintFor #1 in {expr,flexpr,iiexpr} \do {% \expandafter\XINT_tmpa - \csname XINT_expr_op_(\expandafter\endcsname - \csname XINT_expr_oparen\expandafter\endcsname - \csname XINT_expr_until_)_a\expandafter\endcsname - \csname XINT_expr_until_)_b\expandafter\endcsname - \csname XINT_expr_op_-vi\endcsname - {expr}% -\expandafter\XINT_tmpa - \csname XINT_flexpr_op_(\expandafter\endcsname - \csname XINT_flexpr_oparen\expandafter\endcsname - \csname XINT_flexpr_until_)_a\expandafter\endcsname - \csname XINT_flexpr_until_)_b\expandafter\endcsname - \csname XINT_flexpr_op_-vi\endcsname - {flexpr}% + \csname XINT_#1_op_(\expandafter\endcsname + \csname XINT_#1_oparen\expandafter\endcsname + \csname XINT_#1_until_)_a\expandafter\endcsname + \csname XINT_#1_until_)_b\expandafter\endcsname + \csname XINT_#1_op_-vi\endcsname + {#1}% +}% \def\XINT_expr_missing_cparen {\xintError:inserted \xint_c_ \XINT_expr_done }% -\expandafter\let\csname XINT_expr_precedence_)\endcsname \xint_c_i -\expandafter\let\csname XINT_expr_op_)\endcsname\XINT_expr_getop +\expandafter\let\csname XINT_expr_precedence_)\endcsname \xint_c_i \expandafter\let\csname XINT_flexpr_precedence_)\endcsname \xint_c_i +\expandafter\let\csname XINT_iiexpr_precedence_)\endcsname \xint_c_i +\expandafter\let\csname XINT_expr_op_)\endcsname \XINT_expr_getop \expandafter\let\csname XINT_flexpr_op_)\endcsname\XINT_expr_getop -\def\XINT_tmpb #1#2#3#4#5#6% +\expandafter\let\csname XINT_iiexpr_op_)\endcsname\XINT_expr_getop +\def\XINT_tmpb #1#2#3#4#5#6%#7% {% \expandafter\XINT_tmpc \csname XINT_#1_op_#3\expandafter\endcsname @@ -407,9 +421,9 @@ \csname XINT_#1_op_-#5\expandafter\endcsname \csname xint_c_#4\expandafter\endcsname \csname #2#6\expandafter\endcsname - \csname XINT_expr_precedence_#3\endcsname {#1}% + \csname XINT_expr_precedence_#3\endcsname {#1}%{#7}% }% -\def\XINT_tmpc #1#2#3#4#5#6#7#8% +\def\XINT_tmpc #1#2#3#4#5#6#7#8#9% {% \def #1##1% \XINT_expr_op_<op> {% keep value, get next number and operator, then do until @@ -418,8 +432,8 @@ }% \def #2##1##2% \XINT_expr_until_<op>_a {\xint_UDsignfork - ##2\dummy {\expandafter #2\expandafter ##1\romannumeral-`0#4}% - -\dummy {#3##1##2}% + ##2{\expandafter #2\expandafter ##1\romannumeral-`0#4}% + -{#3##1##2}% \krof }% \def #3##1##2##3##4% \XINT_expr_until_<op>_b {% either execute next operation now, or first do next (possibly unary) @@ -429,12 +443,12 @@ \else \xint_afterfi {\expandafter ##2\expandafter ##3% - \csname .#6{\XINT_expr_unlock ##1}{\XINT_expr_unlock ##4}\endcsname }% + \csname .=#6#9{\XINT_expr_unlock ##1}{\XINT_expr_unlock ##4}\endcsname }% \fi }% \let #7#5% }% -\def\XINT_tmpa #1{\XINT_tmpb {expr}{xint}#1}% +\def\XINT_tmpa #1{\XINT_tmpb {expr}{xint}#1{}}% \xintApplyInline {\XINT_tmpa }{% {|{iii}{vi}{OR}}% {&{iv}{vi}{AND}}% @@ -449,7 +463,7 @@ {e{ix}{ix}{fE}}% {E{ix}{ix}{fE}}% }% -\def\XINT_tmpa #1{\XINT_tmpb {flexpr}{xint}#1}% +\def\XINT_tmpa #1{\XINT_tmpb {flexpr}{xint}#1{}}% \xintApplyInline {\XINT_tmpa }{% {|{iii}{vi}{OR}}% {&{iv}{vi}{AND}}% @@ -457,7 +471,7 @@ {>{v}{vi}{Gt}}% {={v}{vi}{Eq}}% }% -\def\XINT_tmpa #1{\XINT_tmpb {flexpr}{XINTinFloat}#1}% +\def\XINT_tmpa #1{\XINT_tmpb {flexpr}{XINTinFloat}#1{[\XINTdigits]}}% \xintApplyInline {\XINT_tmpa }{% {+{vi}{vi}{Add}}% {-{vi}{vi}{Sub}}% @@ -467,6 +481,21 @@ {e{ix}{ix}{fE}}% {E{ix}{ix}{fE}}% }% +\def\XINT_tmpa #1{\XINT_tmpb {iiexpr}{xint}#1{}}% +\xintApplyInline {\XINT_tmpa }{% + {|{iii}{vi}{OR}}% + {&{iv}{vi}{AND}}% + {<{v}{vi}{Lt}}% + {>{v}{vi}{Gt}}% + {={v}{vi}{Eq}}% + {+{vi}{vi}{iiAdd}}% + {-{vi}{vi}{iiSub}}% + {*{vii}{vii}{iiMul}}% + {/{vii}{vii}{iiQuo}}% + {^{viii}{viii}{iiPow}}% + {e{ix}{ix}{iE}}% + {E{ix}{ix}{iE}}% +}% \def\XINT_tmpa #1#2#3#4#5#6% {% \def #1##1% \XINT_expr_op_,_a @@ -475,8 +504,8 @@ }% \def #2##1##2% \XINT_expr_until_,_a {\xint_UDsignfork - ##2\dummy {\expandafter #2\expandafter ##1\romannumeral-`0#4}% - -\dummy {#3##1##2}% + ##2{\expandafter #2\expandafter ##1\romannumeral-`0#4}% + -{#3##1##2}% \krof }% \def #3##1##2##3##4% \XINT_expr_until_,_b {% @@ -486,32 +515,28 @@ \else \xint_afterfi {\expandafter ##2\expandafter ##3% - \csname .\XINT_expr_unlock ##1,\XINT_expr_unlock ##4\endcsname }% + \csname .=\XINT_expr_unlock ##1,\XINT_expr_unlock ##4\endcsname }% \fi }% \let #5\xint_c_ii }% +\xintFor #1 in {expr,flexpr,iiexpr} \do {% \expandafter\XINT_tmpa - \csname XINT_expr_op_,\expandafter\endcsname - \csname XINT_expr_until_,_a\expandafter\endcsname - \csname XINT_expr_until_,_b\expandafter\endcsname - \csname XINT_expr_op_-vi\expandafter\endcsname - \csname XINT_expr_precedence_,\endcsname {expr}% -\expandafter\XINT_tmpa - \csname XINT_flexpr_op_,\expandafter\endcsname - \csname XINT_flexpr_until_,_a\expandafter\endcsname - \csname XINT_flexpr_until_,_b\expandafter\endcsname - \csname XINT_flexpr_op_-vi\expandafter\endcsname - \csname XINT_expr_precedence_,\endcsname {flexpr}% -\def\XINT_tmpa #1#2% + \csname XINT_#1_op_,\expandafter\endcsname + \csname XINT_#1_until_,_a\expandafter\endcsname + \csname XINT_#1_until_,_b\expandafter\endcsname + \csname XINT_#1_op_-vi\expandafter\endcsname + \csname XINT_expr_precedence_,\endcsname {#1}% +}% +\def\XINT_tmpa #1#2#3% {% \expandafter\XINT_tmpb - \csname XINT_#1_op_-#2\expandafter\endcsname - \csname XINT_#1_until_-#2_a\expandafter\endcsname - \csname XINT_#1_until_-#2_b\expandafter\endcsname - \csname xint_c_#2\endcsname {#1}% + \csname XINT_#1_op_-#3\expandafter\endcsname + \csname XINT_#1_until_-#3_a\expandafter\endcsname + \csname XINT_#1_until_-#3_b\expandafter\endcsname + \csname xint_c_#3\endcsname {#1}#2% }% -\def\XINT_tmpb #1#2#3#4#5% +\def\XINT_tmpb #1#2#3#4#5#6% {% \def #1% \XINT_expr_op_-<level> {% get next number+operator then switch to _until macro @@ -519,8 +544,8 @@ }% \def #2##1% \XINT_expr_until_-<l>_a {\xint_UDsignfork - ##1\dummy {\expandafter #2\romannumeral-`0#1}% - -\dummy {#3##1}% + ##1{\expandafter #2\romannumeral-`0#1}% + -{#3##1}% \krof }% \def #3##1##2##3% \XINT_expr_until_-<l>_b {% _until tests precedence level with next op, executes now or postpones @@ -529,12 +554,13 @@ \csname XINT_#5_op_##2\endcsname {##3}}% \else \xint_afterfi {\expandafter ##1\expandafter ##2% - \csname .\xintOpp{\XINT_expr_unlock ##3}\endcsname }% + \csname .=#6{\XINT_expr_unlock ##3}\endcsname }% \fi }% }% -\xintApplyInline{\XINT_tmpa {expr}}{{vi}{vii}{viii}{ix}}% -\xintApplyInline{\XINT_tmpa {flexpr}}{{vi}{vii}{viii}{ix}}% +\xintApplyInline{\XINT_tmpa {expr}\xintOpp}{{vi}{vii}{viii}{ix}}% +\xintApplyInline{\XINT_tmpa {flexpr}\xintOpp}{{vi}{vii}{viii}{ix}}% +\xintApplyInline{\XINT_tmpa {iiexpr}\xintiiOpp}{{vi}{vii}{viii}{ix}}% \let\XINT_expr_precedence_? \xint_c_x \def \XINT_expr_op_? #1#2#3% {% @@ -543,6 +569,7 @@ {\XINT_expr_getnext #2}% }% \let\XINT_flexpr_op_?\XINT_expr_op_? +\let\XINT_iiexpr_op_?\XINT_expr_op_? \let\XINT_expr_precedence_: \xint_c_x \def \XINT_expr_op_: #1#2#3#4% {% @@ -552,145 +579,198 @@ {\XINT_expr_getnext #4}% }% \let\XINT_flexpr_op_:\XINT_expr_op_: +\let\XINT_iiexpr_op_:\XINT_expr_op_: \let\XINT_expr_precedence_! \xint_c_x \def\XINT_expr_op_! #1{\expandafter\XINT_expr_getop - \csname .\xintFac{\XINT_expr_unlock #1}\endcsname }% [0] removed in 1.09c + \csname .=\xintFac{\XINT_expr_unlock #1}\endcsname }% \let\XINT_flexpr_op_!\XINT_expr_op_! -\def\XINT_expr_op_@ #1% -{% - \ifcsname XINT_expr_onlitteral_#1\endcsname - \expandafter\XINT_expr_funcoflitteral - \else - \expandafter\XINT_expr_op_@@ - \fi {#1}% +\def\XINT_iiexpr_op_! #1{\expandafter\XINT_expr_getop + \csname .=\xintiFac{\XINT_expr_unlock #1}\endcsname }% +\def\XINT_tmpa #1#2#3#4{% + \def #1##1% + {% + \ifcsname XINT_expr_onlitteral_##1\endcsname + \expandafter\XINT_expr_funcoflitteral + \else + \expandafter #2% + \fi {##1}% + }% + \def #2##1% + {% + \ifcsname XINT_#4_func_##1\endcsname + \xint_afterfi + {\expandafter\expandafter\csname XINT_#4_func_##1\endcsname}% + \else \csname xintError:unknown `##1\string'\endcsname + \xint_afterfi{\expandafter\XINT_expr_func_unknown}% + \fi + \romannumeral-`0#3% + }% }% -\def\XINT_flexpr_op_@ #1% -{% - \ifcsname XINT_expr_onlitteral_#1\endcsname - \expandafter\XINT_expr_funcoflitteral - \else - \expandafter\XINT_flexpr_op_@@ - \fi {#1}% +\xintFor #1 in {expr,flexpr,iiexpr} \do {% + \expandafter\XINT_tmpa + \csname XINT_#1_op_@\expandafter\endcsname + \csname XINT_#1_op_@@\expandafter\endcsname + \csname XINT_#1_oparen\endcsname {#1}% }% \def\XINT_expr_funcoflitteral #1% {% \expandafter\expandafter\csname XINT_expr_onlitteral_#1\endcsname \romannumeral-`0\XINT_expr_scanfunc }% -\def\XINT_expr_op_@@ #1% -{% - \ifcsname XINT_expr_func_#1\endcsname - \xint_afterfi{\expandafter\expandafter\csname XINT_expr_func_#1\endcsname}% - \else \xintError:unknownfunction - \xint_afterfi{\expandafter\XINT_expr_func_unknown}% - \fi - \romannumeral-`0\XINT_expr_oparen -}% -\def\XINT_flexpr_op_@@ #1% -{% - \ifcsname XINT_flexpr_func_#1\endcsname - \xint_afterfi{\expandafter\expandafter\csname XINT_flexpr_func_#1\endcsname}% - \else \xintError:unknownfunction - \xint_afterfi{\expandafter\XINT_expr_func_unknown}% - \fi - \romannumeral-`0\XINT_flexpr_oparen -}% \def\XINT_expr_onlitteral_bool #1#2#3{\expandafter\XINT_expr_getop - \csname .\xintBool{#3}\endcsname }% + \csname .=\xintBool{#3}\endcsname }% \def\XINT_expr_onlitteral_togl #1#2#3{\expandafter\XINT_expr_getop - \csname .\xintToggle{#3}\endcsname }% -\def\XINT_expr_func_unknown #1#2#3% -{% - \expandafter #1\expandafter #2\csname .0[0]\endcsname -}% + \csname .=\xintToggle{#3}\endcsname }% +\def\XINT_expr_func_unknown #1#2#3% 1.09i removes [0], because \xintiiexpr + {\expandafter #1\expandafter #2\csname .=0\endcsname }% \def\XINT_expr_func_reduce #1#2#3% {% \expandafter #1\expandafter #2\csname - .\xintIrr {\XINT_expr_unlock #3}\endcsname + .=\xintIrr {\XINT_expr_unlock #3}\endcsname }% \let\XINT_flexpr_func_reduce\XINT_expr_func_reduce +\def\XINT_expr_func_frac #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .=\xintTFrac {\XINT_expr_unlock #3}\endcsname +}% +\def\XINT_flexpr_func_frac #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .=\XINTinFloatFrac [\XINTdigits]{\XINT_expr_unlock #3}\endcsname +}% \def\XINT_expr_func_sqr #1#2#3% {% \expandafter #1\expandafter #2\csname - .\xintSqr {\XINT_expr_unlock #3}\endcsname + .=\xintSqr {\XINT_expr_unlock #3}\endcsname }% \def\XINT_flexpr_func_sqr #1#2#3% {% \expandafter #1\expandafter #2\csname - .\XINTinFloatMul {\XINT_expr_unlock #3}{\XINT_expr_unlock #3}\endcsname + .=\XINTinFloatMul [\XINTdigits]% + {\XINT_expr_unlock #3}{\XINT_expr_unlock #3}\endcsname +}% +\def\XINT_iiexpr_func_sqr #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .=\xintiiSqr {\XINT_expr_unlock #3}\endcsname }% \def\XINT_expr_func_abs #1#2#3% {% \expandafter #1\expandafter #2\csname - .\xintAbs {\XINT_expr_unlock #3}\endcsname + .=\xintAbs {\XINT_expr_unlock #3}\endcsname }% \let\XINT_flexpr_func_abs\XINT_expr_func_abs +\def\XINT_iiexpr_func_abs #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .=\xintiiAbs {\XINT_expr_unlock #3}\endcsname +}% \def\XINT_expr_func_sgn #1#2#3% {% \expandafter #1\expandafter #2\csname - .\xintSgn {\XINT_expr_unlock #3}\endcsname + .=\xintSgn {\XINT_expr_unlock #3}\endcsname }% \let\XINT_flexpr_func_sgn\XINT_expr_func_sgn +\def\XINT_iiexpr_func_sgn #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .=\xintiiSgn {\XINT_expr_unlock #3}\endcsname +}% \def\XINT_expr_func_floor #1#2#3% {% \expandafter #1\expandafter #2\csname - .\xintFloor {\XINT_expr_unlock #3}\endcsname + .=\xintFloor {\XINT_expr_unlock #3}\endcsname }% \let\XINT_flexpr_func_floor\XINT_expr_func_floor +\let\XINT_iiexpr_func_floor\XINT_expr_func_floor \def\XINT_expr_func_ceil #1#2#3% {% \expandafter #1\expandafter #2\csname - .\xintCeil {\XINT_expr_unlock #3}\endcsname + .=\xintCeil {\XINT_expr_unlock #3}\endcsname }% \let\XINT_flexpr_func_ceil\XINT_expr_func_ceil +\let\XINT_iiexpr_func_ceil\XINT_expr_func_ceil \def\XINT_expr_twoargs #1,#2,{{#1}{#2}}% \def\XINT_expr_func_quo #1#2#3% {% - \expandafter #1\expandafter #2\csname .% + \expandafter #1\expandafter #2\csname .=% \expandafter\expandafter\expandafter\xintQuo \expandafter\XINT_expr_twoargs \romannumeral-`0\XINT_expr_unlock #3,\endcsname }% \let\XINT_flexpr_func_quo\XINT_expr_func_quo +\def\XINT_iiexpr_func_quo #1#2#3% +{% + \expandafter #1\expandafter #2\csname .=% + \expandafter\expandafter\expandafter\xintiiQuo + \expandafter\XINT_expr_twoargs + \romannumeral-`0\XINT_expr_unlock #3,\endcsname +}% \def\XINT_expr_func_rem #1#2#3% {% - \expandafter #1\expandafter #2\csname .% + \expandafter #1\expandafter #2\csname .=% \expandafter\expandafter\expandafter\xintRem \expandafter\XINT_expr_twoargs \romannumeral-`0\XINT_expr_unlock #3,\endcsname }% \let\XINT_flexpr_func_rem\XINT_expr_func_rem +\def\XINT_iiexpr_func_rem #1#2#3% +{% + \expandafter #1\expandafter #2\csname .=% + \expandafter\expandafter\expandafter\xintiiRem + \expandafter\XINT_expr_twoargs + \romannumeral-`0\XINT_expr_unlock #3,\endcsname +}% \def\XINT_expr_oneortwo #1#2#3,#4,#5.% {% \if\relax#5\relax\expandafter\xint_firstoftwo\else \expandafter\xint_secondoftwo\fi - {#1{0}{#3}}{#2{\xintNum {#4}}{#3}}% + {#1{0}}{#2{\xintNum {#4}}}{#3}% }% \def\XINT_expr_func_round #1#2#3% {% - \expandafter #1\expandafter #2\csname .% + \expandafter #1\expandafter #2\csname .=% \expandafter\XINT_expr_oneortwo \expandafter\xintiRound\expandafter\xintRound \romannumeral-`0\XINT_expr_unlock #3,,.\endcsname }% \let\XINT_flexpr_func_round\XINT_expr_func_round +\def\XINT_iiexpr_oneortwo #1#2,#3,#4.% +{% + \if\relax#4\relax\expandafter\xint_firstoftwo\else + \expandafter\xint_secondoftwo\fi + {#1{0}}{#1{#3}}{#2}% +}% +\def\XINT_iiexpr_func_round #1#2#3% +{% + \expandafter #1\expandafter #2\csname .=% + \expandafter\XINT_iiexpr_oneortwo\expandafter\xintiRound + \romannumeral-`0\XINT_expr_unlock #3,,.\endcsname +}% \def\XINT_expr_func_trunc #1#2#3% {% - \expandafter #1\expandafter #2\csname .% + \expandafter #1\expandafter #2\csname .=% \expandafter\XINT_expr_oneortwo \expandafter\xintiTrunc\expandafter\xintTrunc \romannumeral-`0\XINT_expr_unlock #3,,.\endcsname }% \let\XINT_flexpr_func_trunc\XINT_expr_func_trunc +\def\XINT_iiexpr_func_trunc #1#2#3% +{% + \expandafter #1\expandafter #2\csname .=% + \expandafter\XINT_iiexpr_oneortwo\expandafter\xintiTrunc + \romannumeral-`0\XINT_expr_unlock #3,,.\endcsname +}% \def\XINT_expr_argandopt #1,#2,#3.% {% \if\relax#3\relax\expandafter\xint_firstoftwo\else \expandafter\xint_secondoftwo\fi - {[\XINTdigits]{#1}}{[\xintNum {#2}]{#1}}% + {[\XINTdigits]}{[\xintNum {#2}]}{#1}% }% \def\XINT_expr_func_float #1#2#3% {% - \expandafter #1\expandafter #2\csname .% + \expandafter #1\expandafter #2\csname .=% \expandafter\XINTinFloat \romannumeral-`0\expandafter\XINT_expr_argandopt \romannumeral-`0\XINT_expr_unlock #3,,.\endcsname @@ -698,127 +778,164 @@ \let\XINT_flexpr_func_float\XINT_expr_func_float \def\XINT_expr_func_sqrt #1#2#3% {% - \expandafter #1\expandafter #2\csname .% + \expandafter #1\expandafter #2\csname .=% \expandafter\XINTinFloatSqrt \romannumeral-`0\expandafter\XINT_expr_argandopt \romannumeral-`0\XINT_expr_unlock #3,,.\endcsname }% \let\XINT_flexpr_func_sqrt\XINT_expr_func_sqrt +\def\XINT_iiexpr_func_sqrt #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .=\xintiSqrt {\XINT_expr_unlock #3}\endcsname +}% \def\XINT_expr_func_gcd #1#2#3% {% \expandafter #1\expandafter #2\csname - .\xintGCDof:csv{\XINT_expr_unlock #3}\endcsname + .=\xintGCDof:csv{\XINT_expr_unlock #3}\endcsname }% \let\XINT_flexpr_func_gcd\XINT_expr_func_gcd +\let\XINT_iiexpr_func_gcd\XINT_expr_func_gcd \def\XINT_expr_func_lcm #1#2#3% {% \expandafter #1\expandafter #2\csname - .\xintLCMof:csv{\XINT_expr_unlock #3}\endcsname + .=\xintLCMof:csv{\XINT_expr_unlock #3}\endcsname }% \let\XINT_flexpr_func_lcm\XINT_expr_func_lcm +\let\XINT_iiexpr_func_lcm\XINT_expr_func_lcm \def\XINT_expr_func_max #1#2#3% {% \expandafter #1\expandafter #2\csname - .\xintMaxof:csv{\XINT_expr_unlock #3}\endcsname + .=\xintMaxof:csv{\XINT_expr_unlock #3}\endcsname +}% +\def\XINT_iiexpr_func_max #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .=\xintiMaxof:csv{\XINT_expr_unlock #3}\endcsname }% \def\XINT_flexpr_func_max #1#2#3% {% \expandafter #1\expandafter #2\csname - .\XINTinFloatMaxof:csv{\XINT_expr_unlock #3}\endcsname + .=\XINTinFloatMaxof:csv{\XINT_expr_unlock #3}\endcsname }% \def\XINT_expr_func_min #1#2#3% {% \expandafter #1\expandafter #2\csname - .\xintMinof:csv{\XINT_expr_unlock #3}\endcsname + .=\xintMinof:csv{\XINT_expr_unlock #3}\endcsname +}% +\def\XINT_iiexpr_func_min #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .=\xintiMinof:csv{\XINT_expr_unlock #3}\endcsname }% \def\XINT_flexpr_func_min #1#2#3% {% \expandafter #1\expandafter #2\csname - .\XINTinFloatMinof:csv{\XINT_expr_unlock #3}\endcsname + .=\XINTinFloatMinof:csv{\XINT_expr_unlock #3}\endcsname }% \def\XINT_expr_func_sum #1#2#3% {% \expandafter #1\expandafter #2\csname - .\xintSum:csv{\XINT_expr_unlock #3}\endcsname + .=\xintSum:csv{\XINT_expr_unlock #3}\endcsname }% \def\XINT_flexpr_func_sum #1#2#3% {% \expandafter #1\expandafter #2\csname - .\XINTinFloatSum:csv{\XINT_expr_unlock #3}\endcsname + .=\XINTinFloatSum:csv{\XINT_expr_unlock #3}\endcsname +}% +\def\XINT_iiexpr_func_sum #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .=\xintiiSum:csv{\XINT_expr_unlock #3}\endcsname }% \def\XINT_expr_func_prd #1#2#3% {% \expandafter #1\expandafter #2\csname - .\xintPrd:csv{\XINT_expr_unlock #3}\endcsname + .=\xintPrd:csv{\XINT_expr_unlock #3}\endcsname }% \def\XINT_flexpr_func_prd #1#2#3% {% \expandafter #1\expandafter #2\csname - .\XINTinFloatPrd:csv{\XINT_expr_unlock #3}\endcsname + .=\XINTinFloatPrd:csv{\XINT_expr_unlock #3}\endcsname +}% +\def\XINT_iiexpr_func_prd #1#2#3% +{% + \expandafter #1\expandafter #2\csname + .=\xintiiPrd:csv{\XINT_expr_unlock #3}\endcsname }% \let\XINT_expr_func_add\XINT_expr_func_sum \let\XINT_expr_func_mul\XINT_expr_func_prd \let\XINT_flexpr_func_add\XINT_flexpr_func_sum \let\XINT_flexpr_func_mul\XINT_flexpr_func_prd +\let\XINT_iiexpr_func_add\XINT_iiexpr_func_sum +\let\XINT_iiexpr_func_mul\XINT_iiexpr_func_prd \def\XINT_expr_func_? #1#2#3% {% \expandafter #1\expandafter #2\csname - .\xintIsNotZero {\XINT_expr_unlock #3}\endcsname + .=\xintIsNotZero {\XINT_expr_unlock #3}\endcsname }% \let\XINT_flexpr_func_? \XINT_expr_func_? +\let\XINT_iiexpr_func_? \XINT_expr_func_? \def\XINT_expr_func_! #1#2#3% {% \expandafter #1\expandafter #2\csname - .\xintIsZero {\XINT_expr_unlock #3}\endcsname + .=\xintIsZero {\XINT_expr_unlock #3}\endcsname }% \let\XINT_flexpr_func_! \XINT_expr_func_! +\let\XINT_iiexpr_func_! \XINT_expr_func_! \def\XINT_expr_func_not #1#2#3% {% \expandafter #1\expandafter #2\csname - .\xintIsZero {\XINT_expr_unlock #3}\endcsname + .=\xintIsZero {\XINT_expr_unlock #3}\endcsname }% \let\XINT_flexpr_func_not \XINT_expr_func_not +\let\XINT_iiexpr_func_not \XINT_expr_func_not \def\XINT_expr_func_all #1#2#3% {% \expandafter #1\expandafter #2\csname - .\xintANDof:csv{\XINT_expr_unlock #3}\endcsname + .=\xintANDof:csv{\XINT_expr_unlock #3}\endcsname }% \let\XINT_flexpr_func_all\XINT_expr_func_all +\let\XINT_iiexpr_func_all\XINT_expr_func_all \def\XINT_expr_func_any #1#2#3% {% \expandafter #1\expandafter #2\csname - .\xintORof:csv{\XINT_expr_unlock #3}\endcsname + .=\xintORof:csv{\XINT_expr_unlock #3}\endcsname }% \let\XINT_flexpr_func_any\XINT_expr_func_any +\let\XINT_iiexpr_func_any\XINT_expr_func_any \def\XINT_expr_func_xor #1#2#3% {% \expandafter #1\expandafter #2\csname - .\xintXORof:csv{\XINT_expr_unlock #3}\endcsname + .=\xintXORof:csv{\XINT_expr_unlock #3}\endcsname }% \let\XINT_flexpr_func_xor\XINT_expr_func_xor +\let\XINT_iiexpr_func_xor\XINT_expr_func_xor \def\xintifNotZero:: #1,#2,#3,{\xintifNotZero{#1}{#2}{#3}}% \def\XINT_expr_func_if #1#2#3% {% \expandafter #1\expandafter #2\csname - .\expandafter\xintifNotZero:: + .=\expandafter\xintifNotZero:: \romannumeral-`0\XINT_expr_unlock #3,\endcsname }% \let\XINT_flexpr_func_if\XINT_expr_func_if +\let\XINT_iiexpr_func_if\XINT_expr_func_if \def\xintifSgn:: #1,#2,#3,#4,{\xintifSgn{#1}{#2}{#3}{#4}}% \def\XINT_expr_func_ifsgn #1#2#3% {% \expandafter #1\expandafter #2\csname - .\expandafter\xintifSgn:: + .=\expandafter\xintifSgn:: \romannumeral-`0\XINT_expr_unlock #3,\endcsname }% \let\XINT_flexpr_func_ifsgn\XINT_expr_func_ifsgn +\let\XINT_iiexpr_func_ifsgn\XINT_expr_func_ifsgn \def\XINT_newexpr_print #1{\ifnum\xintNthElt{0}{#1}>1 \expandafter\xint_firstoftwo \else \expandafter\xint_secondoftwo \fi {_xintListWithSep,{#1}}{\xint_firstofone#1}}% -\xintForpair #1#2 in {(fl,Float),(num,iRound0),(bool,IsTrue)}\do {% +\xintForpair #1#2 in {(fl,Float),(i,iRound0),(bool,IsTrue)}\do {% \expandafter\def\csname XINT_new#1expr_print\endcsname ##1{\ifnum\xintNthElt{0}{##1}>1 \expandafter\xint_firstoftwo @@ -828,12 +945,18 @@ {_xintListWithSep,{\xintApply{_xint#2}{##1}}} {_xint#2##1}}}% \toks0 {}% -\xintFor #1 in {Bool,Toggle,Floor,Ceil,iRound,Round,iTrunc,Trunc,% +\xintFor #1 in {Bool,Toggle,Floor,Ceil,iRound,Round,iTrunc,Trunc,TFrac,% Lt,Gt,Eq,AND,OR,IsNotZero,IsZero,ifNotZero,ifSgn,% - Irr,Num,Abs,Sgn,Opp,Quo,Rem,Add,Sub,Mul,Sqr,Div,Pow,Fac,fE}\do + Irr,Num,Abs,Sgn,Opp,Quo,Rem,Add,Sub,Mul,Sqr,Div,Pow,Fac,fE,iSqrt,% + iiAdd,iiSub,iiMul,iiSqr,iiPow,iiQuo,iiRem,iiSgn,iiAbs,iiOpp,iE}\do {\toks0 \expandafter{\the\toks0\expandafter\def\csname xint#1\endcsname {_xint#1}}}% -\xintFor #1 in {GCDof,LCMof,Maxof,Minof,ANDof,ORof,XORof,Sum,Prd}\do +\xintFor #1 in {,Sqrt,Add,Sub,Mul,Div,Power,fE,Frac}\do + {\toks0 + \expandafter{\the\toks0\expandafter\def\csname XINTinFloat#1\endcsname + {_XINTinFloat#1}}}% +\xintFor #1 in {GCDof,LCMof,Maxof,Minof,ANDof,ORof,XORof,Sum,Prd,% + iMaxof,iMinof,iiSum,iiPrd}\do {\toks0 \expandafter{\the\toks0\expandafter\def\csname xint#1:csv\endcsname ####1{_xint#1{\xintCSVtoListNonStripped {####1}}}}}% @@ -841,17 +964,13 @@ {\toks0 \expandafter{\the\toks0\expandafter\def\csname XINTinFloat#1:csv\endcsname ####1{_XINTinFloat#1{\xintCSVtoListNonStripped {####1}}}}}% -\xintFor #1 in {,Sqrt,Add,Sub,Mul,Div,Power,fE}\do - {\toks0 - \expandafter{\the\toks0\expandafter\def\csname XINTinFloat#1\endcsname - {_XINTinFloat#1}}}% \expandafter\def\expandafter\XINT_expr_protect\expandafter{\the\toks0 \def\XINTdigits {_XINTdigits}% \def\XINT_expr_print ##1{\expandafter\XINT_newexpr_print\expandafter {\romannumeral0\xintcsvtolistnonstripped{\XINT_expr_unlock ##1}}}% \def\XINT_flexpr_print ##1{\expandafter\XINT_newflexpr_print\expandafter {\romannumeral0\xintcsvtolistnonstripped{\XINT_expr_unlock ##1}}}% - \def\XINT_numexpr_print ##1{\expandafter\XINT_newnumexpr_print\expandafter + \def\XINT_iexpr_print ##1{\expandafter\XINT_newiexpr_print\expandafter {\romannumeral0\xintcsvtolistnonstripped{\XINT_expr_unlock ##1}}}% \def\XINT_boolexpr_print ##1{\expandafter\XINT_newboolexpr_print\expandafter {\romannumeral0\xintcsvtolistnonstripped{\XINT_expr_unlock ##1}}}% @@ -859,7 +978,9 @@ \toks0 {}% \def\xintNewExpr {\xint_NewExpr\xinttheexpr }% \def\xintNewFloatExpr {\xint_NewExpr\xintthefloatexpr }% -\def\xintNewNumExpr {\xint_NewExpr\xintthenumexpr }% +\def\xintNewIExpr {\xint_NewExpr\xinttheiexpr }% +\let\xintNewNumExpr\xintNewIExpr +\def\xintNewIIExpr {\xint_NewExpr\xinttheiiexpr }% \def\xintNewBoolExpr {\xint_NewExpr\xinttheboolexpr }% \def\xint_NewExpr #1#2[#3]% {% @@ -877,31 +998,32 @@ \or \toks0 {\xdef #2##1##2##3##4##5##6##7##8##9}% \fi \xintexprSafeCatcodes + \escapechar92 \XINT_NewExpr #1% }% \catcode`* 13 \def\XINT_NewExpr #1#2% {% - \def\xintTmp ##1##2##3##4##5##6##7##8##9{#2}% + \def\XINT_tmpa ##1##2##3##4##5##6##7##8##9{#2}% \XINT_expr_protect - \lccode`\*=`_ \lowercase {\def*}{!noexpand!}% - \catcode`_ 13 \catcode`: 11 \endlinechar -1 + \lccode`*=`_ \lowercase {\def*}{!noexpand!}% + \catcode`_ 13 \catcode`: 11 %\endlinechar -1 %not sure why I had that, \par? \everyeof {\noexpand }% - \edef\XINTtmp ##1##2##3##4##5##6##7##8##9% + \edef\XINT_tmpb ##1##2##3##4##5##6##7##8##9% {\scantokens \expandafter{\romannumeral-`0#1% - \xintTmp {####1}{####2}{####3}% - {####4}{####5}{####6}% - {####7}{####8}{####9}% + \XINT_tmpa {####1}{####2}{####3}% + {####4}{####5}{####6}% + {####7}{####8}{####9}% \relax}}% - \lccode`\*=`\$ \lowercase {\def*}{####}% + \lccode`*=`\$ \lowercase {\def*}{####}% \catcode`\$ 13 \catcode`! 0 \catcode`_ 11 % \the\toks0 {\scantokens\expandafter{\expandafter - \XINT_newexpr_stripprefix\meaning\XINTtmp}}% + \XINT_newexpr_setprefix\meaning\XINT_tmpb}}% \endgroup }% -\let\xintexprRestoreCatcodes\relax +\let\xintexprRestoreCatcodes\empty \def\xintexprSafeCatcodes {% for end user. \edef\xintexprRestoreCatcodes {% @@ -924,8 +1046,9 @@ \catcode46=\the\catcode46 % . \catcode45=\the\catcode45 % - \catcode44=\the\catcode44 % , - \catcode61=\the\catcode61\relax % = - }% this is just for some standard situation with a few made active by Babel + \catcode61=\the\catcode61 % = + \catcode32=\the\catcode32\relax % space + }% it's hard to know where to stop... \catcode63=12 % ? \catcode124=12 % | \catcode38=4 % & @@ -946,6 +1069,7 @@ \catcode45=12 % - \catcode44=12 % , \catcode61=12 % = + \catcode32=10 % space }% \let\XINT_tmpa\relax \let\XINT_tmpb\relax \let\XINT_tmpc\relax \XINT_restorecatcodes_endinput% |