diff options
author | Karl Berry <karl@freefriends.org> | 2019-09-11 21:20:23 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-09-11 21:20:23 +0000 |
commit | a4638c5ac366e7d8e329f5276543492ee5c22f41 (patch) | |
tree | 389c084a88deb4ee8c094654268ac45d331d680e /Master/texmf-dist/tex/generic/xint/xintexpr.sty | |
parent | ae7f7ce522ff387f85698d8f28692b008de1e520 (diff) |
xint (11sep19)
git-svn-id: svn://tug.org/texlive/trunk@52081 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.sty | 134 |
1 files changed, 72 insertions, 62 deletions
diff --git a/Master/texmf-dist/tex/generic/xint/xintexpr.sty b/Master/texmf-dist/tex/generic/xint/xintexpr.sty index 8ed1191fb8a..382a121466a 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.3e 2019/04/05 +%% The xint bundle 1.3f 2019/09/10 %% Copyright (C) 2013-2019 by Jean-Francois Burnol %% xintexpr: Expandable expression parser %% --------------------------------------------------------------- @@ -81,9 +81,16 @@ \XINTsetupcatcodes% \XINT_providespackage \ProvidesPackage{xintexpr}% - [2019/04/05 1.3e Expandable expression parser (JFB)]% + [2019/09/10 v1.3f Expandable expression parser (JFB)]% \catcode`! 11 \let\XINT_Cmp \xintiiCmp +\def\xintDigits {\futurelet\XINT_token\xintDigitss}% +\def\xintDigitss #1={\afterassignment\xintDigitsss\mathchardef\XINTdigits=}% +\def\xintDigitsss#1{\ifx*\XINT_token\expandafter\xintreloadxinttrig\fi}% +\let\xintfracSetDigits\xintSetDigits +\def\xintSetDigits#1#{\if\relax\detokenize{#1}\relax + \else\afterassignment\xintreloadxinttrig\fi + \xintfracSetDigits}% \def\xintexpr {\romannumeral0\xintexpro }% \def\xintiexpr {\romannumeral0\xintiexpro }% \def\xintfloatexpr {\romannumeral0\xintfloatexpro }% @@ -97,16 +104,16 @@ }% \def\XINT_iexpr_noopt {% - \expandafter\XINT_iexpr_preprint\expandafter 0% + \expandafter\XINT_iexpr_round\expandafter 0% \romannumeral0\xintbareeval }% \def\XINT_iexpr_withopt [#1]% {% - \expandafter\XINT_iexpr_preprint\expandafter + \expandafter\XINT_iexpr_round\expandafter {\the\numexpr \xint_zapspaces #1 \xint_gobble_i\expandafter}% \romannumeral0\xintbareeval }% -\def\XINT_iexpr_preprint #1#2% +\def\XINT_iexpr_round #1#2% {% \expandafter\XINT_expr_wrap \csname .=\xintRound::csv {#1}{\XINT_expr_unlock #2}\endcsname @@ -118,27 +125,40 @@ }% \def\XINT_flexpr_noopt {% - \expandafter\XINT_flexpr_preprint\expandafter\xinttheDigits - \romannumeral0\xintbarefloateval + \expandafter\XINT_flexpr_noopt_a\romannumeral0\xintbarefloateval +}% +\def\XINT_flexpr_noopt_a #1% +{% + \expandafter\XINT_flexpr_wrap + \csname .;\xinttheDigits.=\XINT_expr_unlock #1\endcsname }% \def\XINT_flexpr_withopt [#1]% {% - \expandafter\XINT_flexpr_preprint\expandafter - {\the\numexpr\xint_zapspaces #1 \xint_gobble_i\expandafter}% + \expandafter\XINT_flexpr_withopt_a + \the\numexpr\xint_zapspaces #1 \xint_gobble_i\expandafter.% \romannumeral0\xintbarefloateval }% -\def\XINT_flexpr_preprint #1#2% +\def\XINT_flexpr_withopt_a #1.#2% {% \expandafter\XINT_flexpr_wrap \csname .;#1.=\XINTinFloat::csv {#1}{\XINT_expr_unlock #2}\endcsname }% +\def\XINT:NE_flexpr_withopt_a #1.#2% +{% + \expandafter\XINT_flexpr_wrap + \csname .;#1.=\XINT:NE:one{\XINTinFloat::csv{#1}}{\XINT_expr_unlock #2}\endcsname +}% \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:NE_expr_print#1{\expandafter + \xintSPRaw::csv\expandafter{\romannumeral`&&@\XINT_expr_unlock #1}}% +\def\XINT_iiexpr_print #1{\xintCSV::csv {\XINT_expr_unlock #1}}% +\def\XINT:NE_iiexpr_print #1{\expandafter + \xintCSV::csv\expandafter{\romannumeral`&&@\XINT_expr_unlock #1}}% \def\XINT_flexpr_print #1% {% \expandafter\xintPFloat::csv @@ -165,6 +185,10 @@ {\romannumeral`&&@\expandafter\xint_gobble_iii\romannumeral`&&@\xintfloatexpr#1\relax}% \def\xintiieval #1% {\romannumeral`&&@\expandafter\XINT_iiexpr_print\romannumeral0\xintbareiieval#1\relax}% +\def\XINT:NE:eval #1{\xintexpr #1\relax}% +\def\XINT:NE:ieval #1{\xintiexpr #1\relax}% +\def\XINT:NE:floateval#1{\xintfloatexpr #1\relax}% +\def\XINT:NE:iieval #1{\xintiiexpr #1\relax}% \def\xintthe #1{\romannumeral`&&@\expandafter\xint_gobble_iii\romannumeral`&&@#1}% \def\xintbareeval {\expandafter\XINT_expr_until_end_a\romannumeral`&&@\XINT_expr_getnext }% @@ -181,7 +205,9 @@ \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\XINT_boolexpr_print #1{\xintIsTrue::csv {\XINT_expr_unlock #1}}% +\def\XINT:NE_boolexpr_print #1{\expandafter + \xintIsTrue::csv\expandafter{\romannumeral`&&@\XINT_expr_unlock #1}}% \def\xinttheboolexpr {% \romannumeral`&&@\expandafter\expandafter\expandafter @@ -2993,7 +3019,7 @@ \def\XINT_expr_defuserefunc_none #1#2#3% {% \expandafter\XINT_expr_defuserefunc_none_a - \csname XINT_#3_userefunc_#2\endcsname + \csname XINT_#3_userefunc_#2\endcsname #1% }% \def\XINT_expr_defuserefunc_none_a #1#2% {% @@ -3196,13 +3222,13 @@ {% \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#1#2{\expandafter\XINT:NE:one_a\romannumeral`&&@#2!{#1}}% \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}% + \xint_orthat {#3}{#1#2}% }% \def\XINT:NE:userfunc #1#2#3% {~xintExpandArgs{XINT_#1_userfunc_#2}{\xintCSVtoListNonStripped{#3}}}% @@ -3381,7 +3407,6 @@ \let\xintiiifSgn: \xintiiifSgnNE: \let\xintSeqNumeric::csv \xintSeq::csv \let\xintiiSeqNumeric::csv \xintiiSeq::csv - \let\XINTinFloatSeqNumeric::csv \XINTinFloatSeq::csv \let\xintSeqBNumeric::csv \xintSeqB::csv \let\xintiiSeqBNumeric::csv \xintiiSeqB::csv \let\XINTinFloatSeqBNumeric::csv\XINTinFloatSeqB::csv @@ -3389,8 +3414,6 @@ {\XINT:NE:two_\xintSeqNumeric::csv{$noexpand$xintSeq::csv}}% \def\xintiiSeq::csv {\XINT:NE:two_\xintiiSeqNumeric::csv{$noexpand$xintiiSeq::csv}}% - \def\XINTinFloatSeq::csv - {\XINT:NE:two_\XINTinFloatSeqNumeric::csv{$noexpand$XINTinFloatSeq::csv}}% \def\xintSeqB::csv {\XINT:NE:two_\xintSeqBNumeric::csv{$noexpand$xintSeqB:f:csv}}% \def\xintiiSeqB::csv @@ -3402,73 +3425,60 @@ \def\XINTinRandomFloatSixteen{~XINTinRandomFloatSixteen }% \def\xintiiRandRange{~xintiiRandRange }% \def\xintiiRandRangeAtoB{~xintiiRandRangeAtoB }% + \let\xinteval\XINT:NE:eval + \let\xintieval\XINT:NE:ieval + \let\xintiieval\XINT:NE:iieval + \let\xintfloateval\XINT:NE:floateval }% \def\XINT_expr_redefineprints {% - \def\XINT_flexpr_noopt - {% - \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}}% + \let\XINT_flexpr_withopt_a\XINT:NE_flexpr_withopt_a + \let\XINT_expr_print \XINT:NE_expr_print + \let\XINT_iiexpr_print \XINT:NE_iiexpr_print + \let\XINT_boolexpr_print \XINT:NE_boolexpr_print \def\xintCSV::csv {~xintCSV::csv }% \def\xintSPRaw::csv {~xintSPRaw::csv }% \def\xintPFloat::csv {~xintPFloat::csv }% \def\xintIsTrue::csv {~xintIsTrue::csv }% \def\xintRound::csv {~xintRound::csv }% }% -\def\xintNewExpr {\XINT_NewExpr\XINT_expr_redefineprints\xint_firstofone +\def\xintNewExpr {\XINT_NewExpr\xint_firstofone \xinttheexpr\XINT_newexpr_clean}% -\def\xintNewFloatExpr{\XINT_NewExpr\XINT_expr_redefineprints\xint_firstofone +\def\xintNewFloatExpr{\XINT_NewExpr\xint_firstofone \xintthefloatexpr\XINT_newexpr_clean}% -\def\xintNewIExpr {\XINT_NewExpr\XINT_expr_redefineprints\xint_firstofone +\def\xintNewIExpr {\XINT_NewExpr\xint_firstofone \xinttheiexpr\XINT_newexpr_clean}% -\def\xintNewIIExpr {\XINT_NewExpr\XINT_expr_redefineprints\xint_firstofone +\def\xintNewIIExpr {\XINT_NewExpr\xint_firstofone \xinttheiiexpr\XINT_newexpr_clean}% -\def\xintNewBoolExpr {\XINT_NewExpr\XINT_expr_redefineprints\xint_firstofone +\def\xintNewBoolExpr {\XINT_NewExpr\xint_firstofone \xinttheboolexpr\XINT_newexpr_clean}% \def\XINT_newexpr_clean #1>{\noexpand\romannumeral`&&@}% \def\XINT_NewFunc - {\XINT_NewExpr\XINT_expr_redefineprints\xint_gobble_i\xintthebareeval\XINT_newfunc_clean}% + {\XINT_NewExpr\xint_gobble_i\xintthebareeval\XINT_newfunc_clean}% \def\XINT_NewFloatFunc - {\XINT_NewExpr\XINT_expr_redefineprints\xint_gobble_i\xintthebarefloateval\XINT_newfunc_clean}% + {\XINT_NewExpr\xint_gobble_i\xintthebarefloateval\XINT_newfunc_clean}% \def\XINT_NewIIFunc - {\XINT_NewExpr\XINT_expr_redefineprints\xint_gobble_i\xintthebareiieval\XINT_newfunc_clean}% + {\XINT_NewExpr\xint_gobble_i\xintthebareiieval\XINT_newfunc_clean}% \def\XINT_newfunc_clean #1>{}% -\def\XINT_NewExpr #1#2#3#4#5#6[#7]% +\def\XINT_NewExpr #1#2#3#4#5[#6]% {% \begingroup - \ifcase #7\relax - \toks0 {\endgroup\XINT_global\def#5}% - \or \toks0 {\endgroup\XINT_global\def#5##1}% - \or \toks0 {\endgroup\XINT_global\def#5##1##2}% - \or \toks0 {\endgroup\XINT_global\def#5##1##2##3}% - \or \toks0 {\endgroup\XINT_global\def#5##1##2##3##4}% - \or \toks0 {\endgroup\XINT_global\def#5##1##2##3##4##5}% - \or \toks0 {\endgroup\XINT_global\def#5##1##2##3##4##5##6}% - \or \toks0 {\endgroup\XINT_global\def#5##1##2##3##4##5##6##7}% - \or \toks0 {\endgroup\XINT_global\def#5##1##2##3##4##5##6##7##8}% - \or \toks0 {\endgroup\XINT_global\def#5##1##2##3##4##5##6##7##8##9}% + \ifcase #6\relax + \toks0 {\endgroup\XINT_global\def#4}% + \or \toks0 {\endgroup\XINT_global\def#4##1}% + \or \toks0 {\endgroup\XINT_global\def#4##1##2}% + \or \toks0 {\endgroup\XINT_global\def#4##1##2##3}% + \or \toks0 {\endgroup\XINT_global\def#4##1##2##3##4}% + \or \toks0 {\endgroup\XINT_global\def#4##1##2##3##4##5}% + \or \toks0 {\endgroup\XINT_global\def#4##1##2##3##4##5##6}% + \or \toks0 {\endgroup\XINT_global\def#4##1##2##3##4##5##6##7}% + \or \toks0 {\endgroup\XINT_global\def#4##1##2##3##4##5##6##7##8}% + \or \toks0 {\endgroup\XINT_global\def#4##1##2##3##4##5##6##7##8##9}% \fi - #2\xintexprSafeCatcodes + #1\xintexprSafeCatcodes \XINT_expr_redefinemacros - #1% - \XINT_NewExpr_a #2#3#4#5% + \XINT_expr_redefineprints + \XINT_NewExpr_a #1#2#3#4% }% \catcode`~ 13 \catcode`@ 14 \catcode`\% 6 \catcode`# 12 \catcode`$ 11 @ $ \def\XINT_NewExpr_a %1%2%3%4%5@ |