diff options
author | Karl Berry <karl@freefriends.org> | 2019-01-06 22:02:47 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-01-06 22:02:47 +0000 |
commit | 3354abdc519630ad9975bfce46bada2882fcd6af (patch) | |
tree | f803a9bf96bd1c8eb2b618218f06fb20306bf387 /Master/texmf-dist/tex/generic/xint/xintexpr.sty | |
parent | bee0d2fefd913952b342b909a4a278ce72712e51 (diff) |
xint (6jan19)
git-svn-id: svn://tug.org/texlive/trunk@49617 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 | 156 |
1 files changed, 123 insertions, 33 deletions
diff --git a/Master/texmf-dist/tex/generic/xint/xintexpr.sty b/Master/texmf-dist/tex/generic/xint/xintexpr.sty index 72a614e2692..13bbb335437 100644 --- a/Master/texmf-dist/tex/generic/xint/xintexpr.sty +++ b/Master/texmf-dist/tex/generic/xint/xintexpr.sty @@ -21,8 +21,8 @@ %% same distribution. (The sources need not necessarily be %% in the same archive or directory.) %% --------------------------------------------------------------- -%% The xint bundle 1.3c 2018/06/17 -%% Copyright (C) 2013-2018 by Jean-Francois Burnol +%% The xint bundle 1.3d 2019/01/06 +%% Copyright (C) 2013-2019 by Jean-Francois Burnol %% xintexpr: Expandable expression parser %% --------------------------------------------------------------- \begingroup\catcode61\catcode48\catcode32=10\relax% @@ -81,7 +81,7 @@ \XINTsetupcatcodes% \XINT_providespackage \ProvidesPackage{xintexpr}% - [2018/06/17 1.3c Expandable expression parser (JFB)]% + [2019/01/06 1.3d Expandable expression parser (JFB)]% \catcode`! 11 \let\XINT_Cmp \xintiiCmp \def\xint_gob_til_! #1!{}% ! with catcode 11 @@ -113,17 +113,28 @@ \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\xinteval }% -\def\xintiexpr {\romannumeral0\xintieval }% -\def\xintfloatexpr {\romannumeral0\xintfloateval }% -\def\xintiiexpr {\romannumeral0\xintiieval }% +\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`&&@\xintthe\xintiexpr }% -\def\xintthefloatexpr {\romannumeral`&&@\xintthe\xintfloatexpr }% + {\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 }% + {\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 @@ -146,9 +157,9 @@ \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\xinteval {\expandafter\XINT_expr_wrap\romannumeral0\xintbareeval }% -\def\xintiieval {\expandafter\XINT_iiexpr_wrap\romannumeral0\xintbareiieval }% -\def\xintieval #1% +\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}% \def\XINT_iexpr_noopt {\expandafter\XINT_iexpr_wrap \expandafter 0\romannumeral0\xintbareeval }% @@ -163,7 +174,7 @@ \expandafter\XINT_expr_wrap \csname .=\xintRound::csv {#1}{\XINT_expr_unlock #2}\endcsname }% -\def\xintfloateval #1% +\def\xintfloatexpro #1% {% \ifx [#1\expandafter\XINT_flexpr_withopt_a\else\expandafter\XINT_flexpr_noopt \fi #1% @@ -192,14 +203,17 @@ }% \def\XINT_expr_unlock_sp #1.;#2.=#3!{{#2}{#3}}% \def\xintboolexpr {\romannumeral0\expandafter\expandafter\expandafter - \XINT_boolexpr_done \expandafter\xint_gobble_iv\romannumeral0\xinteval }% + \XINT_boolexpr_done \expandafter\xint_gobble_iv\romannumeral0\xintexpro }% \def\xinttheboolexpr {\romannumeral`&&@\expandafter\expandafter\expandafter - \XINT_boolexpr_print\expandafter\xint_gobble_iv\romannumeral0\xinteval }% + \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\xintifnotzero {\xinttheexpr #1\relax}}% -\def\xintifboolfloatexpr #1{\romannumeral0\xintifnotzero {\xintthefloatexpr #1\relax}}% -\def\xintifbooliiexpr #1{\romannumeral0\xintifnotzero {\xinttheiiexpr #1\relax}}% +\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 \let\XINT:NEhook:one\empty \let\XINT:NEhook:csv\empty @@ -1469,7 +1483,7 @@ \fi }% \catcode`* 12 -\catcode`~\active +\catcode`~ 13 \catcode`: 12 \def\XINT_expr_defvar_getname #1:#2~{\endgroup \def\XINT_expr_tmpa{#1}\edef\XINT_expr_tmpc{\xintCSVLength{#1}}}% @@ -1483,7 +1497,7 @@ \detokenize\expandafter{\XINT_expr_tmpa}:~% \ifcase\XINT_expr_tmpc \xintMessage {xintexpr}{Warning} - {Aborting: impossible to declare variable with empty name.}% + {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 @@ -1528,12 +1542,10 @@ \ifnum\expandafter\xintLength\expandafter{\XINT_expr_tmpa}=\@ne \expandafter\xintnewdummy\XINT_expr_tmpa \else - \XINT_global - \expandafter\edef\csname XINT_expr_var_\XINT_expr_tmpa\endcsname - {\csname .=0\endcsname\noexpand\XINT_expr_undefined {\XINT_expr_tmpa}}% - \XINT_global - \expandafter\edef\csname XINT_expr_onliteral_\XINT_expr_tmpa\endcsname - {\csname .=0\endcsname\noexpand\XINT_expr_undefined {\XINT_expr_tmpa}*}% + \XINT_global\expandafter + \let\csname XINT_expr_var_\XINT_expr_tmpa\endcsname\xint_undefined + \XINT_global\expandafter + \let\csname XINT_expr_onliteral_\XINT_expr_tmpa\endcsname\xint_undefined \ifxintverbose\xintMessage {xintexpr}{Info} {Variable \XINT_expr_tmpa\space has been \ifxintglobaldefs globally \fi ``unassigned''.}% @@ -1544,7 +1556,6 @@ {Error: there was no such variable \XINT_expr_tmpa\space to unassign.}% \fi }% -\def\XINT_expr_undefined #1{\xintError:replaced_by_zero\xint_gobble_i {#1}}% \catcode`* 11 \def\XINT_expr_makedummy #1% {% @@ -2049,10 +2060,55 @@ \expandafter\xint_firstofone\romannumeral`&&@#1,^,{1/1[0]}}% \def\xintiiPrd:csv #1{\expandafter\XINT_oncsv:_a\expandafter\xintiimul \expandafter\xint_firstofone\romannumeral`&&@#1,^,1}% -\def\xintGCDof:csv #1{\expandafter\XINT_oncsv:_a\expandafter\xintgcd - \expandafter\xint_firstofone\romannumeral`&&@#1,^,1}% -\def\xintLCMof:csv #1{\expandafter\XINT_oncsv:_a\expandafter\xintlcm - \expandafter\xint_firstofone\romannumeral`&&@#1,^,0}% +\def\xintGCDof:csv #1{\expandafter\XINT_gcdof:_a\romannumeral`&&@#1,^,{1/1[0]}}% +\def\XINT_gcdof:_a #1% + {\if ,#1\expandafter\XINT_oncsv:_empty\else\expandafter\XINT_gcdof:_b\fi #1}% +\def\XINT_gcdof:_b #1,% + {\expandafter\XINT_gcdof:_c\romannumeral0\xintiiabs#1\xint:}% +\def\XINT_gcdof:_c #1\xint:#2,% + {\expandafter\XINT_gcdof:_d\romannumeral0\xintiiabs#2\xint:#1\xint:}% +\def\XINT_gcdof:_d #1% + {\if ^#1\expandafter\XINT_gcdof:_end\else\expandafter\XINT_gcdof:_e\fi #1}% +\def\XINT_gcdof:_e#1#2\xint:#3\xint: +{% + \if0#1\expandafter\XINT_gcdof:_f\fi + \expandafter\XINT_gcdof:_e\romannumeral0\xintmod{#3}{#1#2}\xint:#1#2\xint: +}% +\def\XINT_gcdof:_f + \expandafter\XINT_gcdof:_e\romannumeral0\xintmod#1#2\xint:#3\xint:#4,% +{% + \expandafter\XINT_gcdof:_d\romannumeral0\xintiiabs#4\xint:#1\xint: +}% +\def\XINT_gcdof:_end ^\xint:#1\xint:#2{#1}% +\def\xintLCMof:csv #1{\expandafter\XINT_lcmof:_a\romannumeral`&&@#1,^,{0/1[0]}}% +\def\XINT_lcmof:_a #1% + {\if ,#1\expandafter\XINT_oncsv:_empty\else\expandafter\XINT_lcmof:_b\fi #1}% +\def\XINT_lcmof:_b #1,% + {\expandafter\XINT_lcmof:_c\romannumeral0\xintiiabs\xintRaw{#1}\xint:}% +\def\XINT_lcmof:_c #1{\if0#1\expandafter\XINT_lcmof:_zero\fi + \expandafter\XINT_lcmof:_d\romannumeral0\XINT_inv #1}% +\def\XINT_lcmof:_d #1\xint:#2,% + {\expandafter\XINT_lcmof:_e\romannumeral0\xintiiabs#2\xint:#1\xint:}% +\def\XINT_lcmof:_e #1% + {\if ^#1\expandafter\XINT_lcmof:_end\else\expandafter\XINT_lcmof:_f\fi #1}% +\def\XINT_lcmof:_f#1#2\xint: +{% + \if0#1\expandafter\XINT_lcmof:_zero\fi + \expandafter\XINT_lcmof:_g\romannumeral0\expandafter\XINT_inv + \romannumeral0\xintraw{#1#2}\xint: +}% +\def\XINT_lcmof:_g #1#2\xint:#3\xint: +{% + \if0#1\expandafter\XINT_lcmof:_h\fi + \expandafter\XINT_lcmof:_g\romannumeral0\xintmod{#3}{#1#2}\xint:#1#2\xint: +}% +\def\XINT_lcmof:_h + \expandafter\XINT_lcmof:_g\romannumeral0\xintmod#1#2\xint:#3\xint:#4,% +{% + \expandafter\XINT_lcmof:_e\romannumeral0\xintiiabs#4\xint:#1\xint: +}% +\def\XINT_lcmof:_zero #1^,#2{0/1[0]}% +\def\XINT_lcmof:_end ^\xint:#1\xint:#2{\romannumeral0\XINT_inv #1}% \def\xintiiGCDof:csv #1{\expandafter\XINT_oncsv:_a\expandafter\xintiigcd \expandafter\xint_firstofone\romannumeral`&&@#1,^,1}% \def\xintiiLCMof:csv #1{\expandafter\XINT_oncsv:_a\expandafter\xintiilcm @@ -2233,6 +2289,28 @@ \expandafter #1\expandafter #2\csname.=% \XINT:NEhook:one\xintiiEven{\XINT_expr_unlock #3}\endcsname }% +\def\XINT_expr_func_isint #1#2#3% +{% + \expandafter #1\expandafter #2\csname.=% + \XINT:NEhook:one\xintIsInt{\XINT_expr_unlock #3}\endcsname +}% +\def\XINT_flexpr_func_isint #1#2#3% +{% + \expandafter #1\expandafter #2\csname.=% + \XINT:NEhook:one\xintFloatIsInt{\XINT_expr_unlock #3}\endcsname +}% +\let\XINT_iiexpr_func_isint\XINT_expr_func_isint % ? perhaps rather always 1 +\def\XINT_expr_func_isone #1#2#3% +{% + \expandafter #1\expandafter #2\csname.=% + \XINT:NEhook:one\xintIsOne{\XINT_expr_unlock #3}\endcsname +}% +\let\XINT_flexpr_func_isone\XINT_expr_func_isone +\def\XINT_iiexpr_func_isone #1#2#3% +{% + \expandafter #1\expandafter #2\csname.=% + \XINT:NEhook:one\xintiiIsOne{\XINT_expr_unlock #3}\endcsname +}% \def\XINT_expr_func_nuple #1#2#3% {\expandafter #1\expandafter #2\csname.=\XINT_expr_unlock #3\endcsname }% \let\XINT_flexpr_func_nuple\XINT_expr_func_nuple @@ -2771,6 +2849,18 @@ \def\XINT:newexpr:userfunc #1#2#3% {~xintExpandArgs{XINT_#1_userfunc_#2}{\xintCSVtoListNonStripped{#3}}}% \catcode`~ 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}% + \XINT_global\expandafter + \let\csname XINT_#1_func_\XINT_expr_tmpa\endcsname\xint_undefined + \XINT_global\expandafter + \let\csname XINT_#1_userfunc_\XINT_expr_tmpa\endcsname\xint_undefined + \ifxintverbose\xintMessage {xintexpr}{Info} + {Function \XINT_expr_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% {% |