diff options
author | Karl Berry <karl@freefriends.org> | 2015-11-19 22:41:59 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-11-19 22:41:59 +0000 |
commit | 7b703227755f59f6d8e6aa04eedefe0b86e20cc3 (patch) | |
tree | 67140be98970442e26b99c69f99ef3f163c0d3cd /Master/texmf-dist/tex/generic/xint/xintexpr.sty | |
parent | 8bc177aa284756939eeec5497c1799fbfae775ae (diff) |
xint (18nov15)
git-svn-id: svn://tug.org/texlive/trunk@38897 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 | 135 |
1 files changed, 64 insertions, 71 deletions
diff --git a/Master/texmf-dist/tex/generic/xint/xintexpr.sty b/Master/texmf-dist/tex/generic/xint/xintexpr.sty index e8ce94fce56..e65c9ecae28 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 v1.2c 2015/11/16 +%% The xint bundle v1.2d 2015/11/18 %% Copyright (C) 2013-2015 by Jean-Francois Burnol %% xintexpr: Expandable expression parser %% --------------------------------------------------------------- @@ -81,7 +81,7 @@ \XINTsetupcatcodes% \XINT_providespackage \ProvidesPackage{xintexpr}% - [2015/11/16 v1.2c Expandable expression parser (jfB)]% + [2015/11/18 v1.2d Expandable expression parser (jfB)]% \catcode`! 11 \def\xint_gob_til_! #1!{}% catcode 11 ! default in xintexpr.sty code. \edef\XINT_expr_lockscan#1!% not used for decimal numbers in xintexpr 1.2 @@ -330,9 +330,8 @@ {% \if e#1\xint_dothis{[\the\numexpr0\XINT_expr_scanexp_a +}\fi \if E#1\xint_dothis{[\the\numexpr0\XINT_expr_scanexp_a +}\fi - \ifcat a#1\xint_dothis{\endcsname*#1}\fi \if .#1\xint_dothis{\XINT_expr_startdec_a .}\fi - \xint_orthat {\expandafter\endcsname \string#1}% + \xint_orthat {\endcsname #1}% }% \def\XINT_expr_startdec_a .#1% {% @@ -354,10 +353,9 @@ {% \if e#1\xint_dothis{0[\the\numexpr0\XINT_expr_scanexp_a +}\fi \if E#1\xint_dothis{0[\the\numexpr0\XINT_expr_scanexp_a +}\fi - \ifcat a#1\xint_dothis{0\endcsname*#1}\fi \if .#1\xint_dothis{\XINT_expr_gobz_startdec_a .}\fi \if 0#1\xint_dothis\XINT_expr_gobz_scanint_d\fi - \xint_orthat {0\expandafter\endcsname \string#1}% + \xint_orthat {0\endcsname #1}% }% \def\XINT_expr_gobz_scanint_d #1% {% @@ -389,8 +387,7 @@ {% \if e#1\xint_dothis{[\the\numexpr#3\XINT_expr_scanexp_a +}\fi \if E#1\xint_dothis{[\the\numexpr#3\XINT_expr_scanexp_a +}\fi - \ifcat a#1\xint_dothis{[#3]\endcsname *#1}\fi - \xint_orthat {[#3]\expandafter\endcsname \string#1}% + \xint_orthat {[#3]\endcsname #1}% }% \def\XINT_expr_gobz_scandec_b #1.#2% {% @@ -405,8 +402,7 @@ {% \if e#1\xint_dothis{0[\the\numexpr0\XINT_expr_scanexp_a +}\fi \if E#1\xint_dothis{0[\the\numexpr0\XINT_expr_scanexp_a +}\fi - \ifcat a#1\xint_dothis{0[0]\endcsname *#1}\fi - \xint_orthat {0[0]\expandafter\endcsname \string#1}% + \xint_orthat {0[0]\endcsname #1}% }% \def\XINT_expr_scanexp_a #1#2% {% @@ -425,10 +421,9 @@ }% \def\XINT_expr_scanexp_c\string #1\XINT_expr_scanexp_d {% - \ifcat a#1\xint_dothis {]\endcsname *#1}\fi \if +#1\xint_dothis {\XINT_expr_scanexp_a +}\fi \if -#1\xint_dothis {\XINT_expr_scanexp_a -}\fi - \xint_orthat {]\expandafter\endcsname\string #1}% + \xint_orthat {]\endcsname #1}% }% \def\XINT_expr_scanexp_bb #1% {% @@ -441,11 +436,7 @@ {% \expandafter\XINT_expr_scanexp_bb\romannumeral`&&@#1% }% -\def\XINT_expr_scanexp_cb\string #1\XINT_expr_scanexp_db -{% - \ifcat a#1\xint_dothis {]\endcsname *#1}\fi - \xint_orthat {]\expandafter\endcsname\string #1}% -}% +\def\XINT_expr_scanexp_cb\string #1\XINT_expr_scanexp_db {]\endcsname #1}% \def\XINT_expr_scanhex_I #1% #1=" {% \expandafter\XINT_expr_getop\csname.=\expandafter @@ -454,7 +445,7 @@ \def\XINT_expr_scanhexI_a #1% {% \ifcat #1\relax\xint_dothis{.>\endcsname\endcsname #1}\fi - \ifx !#1\xint_dothis{.>\endcsname\endcsname*!}\fi % tacit multiplication + \ifx !#1\xint_dothis{.>\endcsname\endcsname !}\fi \xint_orthat {\expandafter\XINT_expr_scanhexI_aa\string #1}% }% \def\XINT_expr_scanhexI_aa #1% @@ -488,7 +479,7 @@ \def\XINT_expr_scanhexII_a #1% {% \ifcat #1\relax\xint_dothis{\endcsname\endcsname#1}\fi - \ifx !#1\xint_dothis{\endcsname\endcsname*!}\fi % tacit multiplication + \ifx !#1\xint_dothis{\endcsname\endcsname !}\fi \xint_orthat {\expandafter\XINT_expr_scanhexII_aa\string #1}% }% \def\XINT_expr_scanhexII_aa #1% @@ -518,7 +509,6 @@ }% \def\XINT_expr_scanfunc_b #1% {% - \ifx !#1\xint_dothis{\xint_firstoftwo{(_*!}}\fi \ifcat \relax#1\xint_dothis{(_}\fi \if (#1\xint_dothis{\xint_firstoftwo{(`}}\fi \if _#1\xint_dothis \XINT_expr_scanfunc_a \fi @@ -528,7 +518,8 @@ \xint_orthat {(_}% #1% }% -\def\XINT_expr_func #1(#2{\xint_c_xviii #2{#1}}% +\def\XINT_expr_func #1(#2{\if _#2\xint_dothis\XINT_expr_op__\fi + \xint_orthat{\xint_c_xviii #2}{#1}}% \def\XINT_expr_getop #1#2% this #1 is the current locked computed value {% \expandafter\XINT_expr_getop_a\expandafter #1\romannumeral`&&@#2% @@ -541,11 +532,11 @@ \if _#2\xint_dothis \xint_secondofthree\fi \if @#2\xint_dothis \xint_secondofthree\fi \if (#2\xint_dothis \xint_secondofthree\fi - \ifx !#2\xint_dothis \xint_secondofthree\fi + \ifcat a#2\xint_dothis \xint_secondofthree\fi \xint_orthat \xint_thirdofthree {\XINT_expr_foundend #1}% - {\XINT_expr_precedence_* *#1#2}% tacit multiplication - {\XINT_expr_getop_b #2#1}% + {\XINT_expr_precedence_*** *#1#2}% tacit multiplication with higher precedence + {\expandafter\XINT_expr_getop_b \string#2#1}% }% \catcode`* 12 \def\XINT_expr_foundend {\xint_c_ \relax }% \relax is a place holder here. @@ -654,7 +645,7 @@ \xintFor #1 in {expr,flexpr,iiexpr} \do {% \expandafter\let\csname XINT_#1_op_)\endcsname \XINT_expr_getop \expandafter\let\csname XINT_#1_op_;\endcsname \space - \expandafter\def\csname XINT_#1_op_]\endcsname ##1{\XINT_expr_getop ##1a}% + \expandafter\def\csname XINT_#1_op_]\endcsname ##1{\XINT_expr_scanop_a a##1}% \expandafter\let\csname XINT_#1_op_a\endcsname \XINT_expr_getop \expandafter\def\csname XINT_#1_op_++)\endcsname ##1##2\relax {\expandafter\XINT_expr_foundend \expandafter @@ -664,9 +655,10 @@ \catcode`& 12 \xintFor* #1 in {{==}{<=}{>=}{!=}{&&}{||}{**}{//}{/:}{..}{..[}{].}{]..}% {+[}{-[}{*[}{/[}{**[}{^[}{a+}{a-}{a*}{a/}{a**}{a^}% - {][}{][:}{:]}{!?}{++}{++)}} + {][}{][:}{:]}{!?}{++}{++)}}%{***}} \do {\expandafter\def\csname XINT_expr_itself_#1\endcsname {#1}}% \catcode`& 7 +\expandafter\let\csname XINT_expr_precedence_***\endcsname \xint_c_viii \def\XINT_tmpc #1#2#3#4#5#6#7#8% {% \def #1##1% \XINT_expr_op_<op> ou flexpr ou iiexpr @@ -723,7 +715,7 @@ {-{vi}{vi}{Sub}}% {*{vii}{vii}{Mul}}% {/{vii}{vii}{Div}}% - {^{viii}{viii}{Pow}}% + {^{ix}{ix}{Pow}}% {{..[}{iii}{vi}{SeqA::csv}}% {{]..}{iii}{vi}{SeqB::csv}}% }% @@ -733,7 +725,7 @@ {-{vi}{vi}{Sub}}% {*{vii}{vii}{Mul}}% {/{vii}{vii}{Div}}% - {^{viii}{viii}{Power}}% + {^{ix}{ix}{Power}}% {{..[}{iii}{vi}{SeqA::csv}}% {{]..}{iii}{vi}{SeqB::csv}}% }% @@ -753,7 +745,7 @@ {-{vi}{vi}{iiSub}}% {*{vii}{vii}{iiMul}}% {/{vii}{vii}{iiDivRound}}% CHANGED IN 1.1! PREVIOUSLY DID EUCLIDEAN QUOTIENT - {^{viii}{viii}{iiPow}}% + {^{ix}{ix}{iiPow}}% {{..[}{iii}{vi}{iiSeqA::csv}}% {{]..}{iii}{vi}{iiSeqB::csv}}% {{..}{iii}{vi}{iiSeq::csv}}% @@ -811,17 +803,17 @@ {{expr}{a-}{vi}{xintSub}}% {{expr}{a*}{vii}{xintMul}}% {{expr}{a/}{vii}{xintDiv}}% - {{expr}{a^}{viii}{xintPow}}% + {{expr}{a^}{ix}{xintPow}}% {{iiexpr}{a+}{vi}{xintiiAdd}}% {{iiexpr}{a-}{vi}{xintiiSub}}% {{iiexpr}{a*}{vii}{xintiiMul}}% {{iiexpr}{a/}{vii}{xintiiDivRound}}% - {{iiexpr}{a^}{viii}{xintiiPow}}% + {{iiexpr}{a^}{ix}{xintiiPow}}% {{flexpr}{a+}{vi}{XINTinFloatAdd}}% {{flexpr}{a-}{vi}{XINTinFloatSub}}% {{flexpr}{a*}{vii}{XINTinFloatMul}}% {{flexpr}{a/}{vii}{XINTinFloatDiv}}% - {{flexpr}{a^}{viii}{XINTinFloatPower}}% + {{flexpr}{a^}{ix}{XINTinFloatPower}}% }% \def\XINT_tmpc #1#2#3#4#5#6#7% {% @@ -855,29 +847,29 @@ {{expr}{-[}{vi}{xintSub}}% {{expr}{*[}{vii}{xintMul}}% {{expr}{/[}{vii}{xintDiv}}% - {{expr}{^[}{viii}{xintPow}}% + {{expr}{^[}{ix}{xintPow}}% {{iiexpr}{+[}{vi}{xintiiAdd}}% {{iiexpr}{-[}{vi}{xintiiSub}}% {{iiexpr}{*[}{vii}{xintiiMul}}% {{iiexpr}{/[}{vii}{xintiiDivRound}}% - {{iiexpr}{^[}{viii}{xintiiPow}}% + {{iiexpr}{^[}{ix}{xintiiPow}}% {{flexpr}{+[}{vi}{XINTinFloatAdd}}% {{flexpr}{-[}{vi}{XINTinFloatSub}}% {{flexpr}{*[}{vii}{XINTinFloatMul}}% {{flexpr}{/[}{vii}{XINTinFloatDiv}}% - {{flexpr}{^[}{viii}{XINTinFloatPower}}% + {{flexpr}{^[}{ix}{XINTinFloatPower}}% }% \xintFor #1 in {and,or,xor,mod} \do {% \expandafter\def\csname XINT_expr_itself_#1\endcsname {#1}}% \expandafter\let\csname XINT_expr_precedence_and\expandafter\endcsname - \csname XINT_expr_precedence_\string&\endcsname + \csname XINT_expr_precedence_&\endcsname \expandafter\let\csname XINT_expr_precedence_or\expandafter\endcsname \csname XINT_expr_precedence_|\endcsname \expandafter\let\csname XINT_expr_precedence_mod\expandafter\endcsname \csname XINT_expr_precedence_/:\endcsname \xintFor #1 in {expr, flexpr, iiexpr} \do {% \expandafter\let\csname XINT_#1_op_and\expandafter\endcsname - \csname XINT_#1_op_\string&\endcsname + \csname XINT_#1_op_&\endcsname \expandafter\let\csname XINT_#1_op_or\expandafter\endcsname \csname XINT_#1_op_|\endcsname \expandafter\let\csname XINT_#1_op_mod\expandafter\endcsname @@ -885,8 +877,8 @@ }% \expandafter\let\csname XINT_expr_precedence_==\expandafter\endcsname \csname XINT_expr_precedence_=\endcsname -\expandafter\let\csname XINT_expr_precedence_\string&\string&\expandafter\endcsname - \csname XINT_expr_precedence_\string&\endcsname +\expandafter\let\csname XINT_expr_precedence_&\string&\expandafter\endcsname + \csname XINT_expr_precedence_&\endcsname \expandafter\let\csname XINT_expr_precedence_||\expandafter\endcsname \csname XINT_expr_precedence_|\endcsname \expandafter\let\csname XINT_expr_precedence_**\expandafter\endcsname @@ -898,8 +890,8 @@ \xintFor #1 in {expr, flexpr, iiexpr} \do {% \expandafter\let\csname XINT_#1_op_==\expandafter\endcsname \csname XINT_#1_op_=\endcsname - \expandafter\let\csname XINT_#1_op_\string&\string&\expandafter\endcsname - \csname XINT_#1_op_\string&\endcsname + \expandafter\let\csname XINT_#1_op_&\string&\expandafter\endcsname + \csname XINT_#1_op_&\endcsname \expandafter\let\csname XINT_#1_op_||\expandafter\endcsname \csname XINT_#1_op_|\endcsname \expandafter\let\csname XINT_#1_op_**\expandafter\endcsname @@ -2392,39 +2384,39 @@ \def\xintRound::csv {~xintRound::csv }% }% \toks0 {}% -\def\xintNewExpr {\XINT_NewExpr{}\XINT_expr_redefineprints\xinttheexpr }% -\def\xintNewFloatExpr {\XINT_NewExpr{}\XINT_expr_redefineprints\xintthefloatexpr }% -\def\xintNewIExpr {\XINT_NewExpr{}\XINT_expr_redefineprints\xinttheiexpr }% -\def\xintNewIIExpr {\XINT_NewExpr{}\XINT_expr_redefineprints\xinttheiiexpr }% -\def\xintNewBoolExpr {\XINT_NewExpr{}\XINT_expr_redefineprints\xinttheboolexpr }% -\def\XINT_NewFunc {\XINT_NewExpr,\xintverbosefalse\xintthebareeval }% -\def\XINT_NewFloatFunc {\XINT_NewExpr,\xintverbosefalse\xintthebarefloateval }% -\def\XINT_NewIIFunc {\XINT_NewExpr,\xintverbosefalse\xintthebareiieval }% -\def\XINT_newexpr_finish #1>{\noexpand\romannumeral`&&@}% -\def\XINT_NewExpr #1#2#3#4[#5]% +\def\xintNewExpr {\XINT_NewExpr{}\XINT_expr_redefineprints\xint_firstofone\xinttheexpr }% +\def\xintNewFloatExpr {\XINT_NewExpr{}\XINT_expr_redefineprints\xint_firstofone\xintthefloatexpr }% +\def\xintNewIExpr {\XINT_NewExpr{}\XINT_expr_redefineprints\xint_firstofone\xinttheiexpr }% +\def\xintNewIIExpr {\XINT_NewExpr{}\XINT_expr_redefineprints\xint_firstofone\xinttheiiexpr }% +\def\xintNewBoolExpr {\XINT_NewExpr{}\XINT_expr_redefineprints\xint_firstofone\xinttheboolexpr }% +\def\XINT_NewFunc {\XINT_NewExpr,{}\xint_gobble_i\xintthebareeval }% +\def\XINT_NewFloatFunc {\XINT_NewExpr,{}\xint_gobble_i\xintthebarefloateval }% +\def\XINT_NewIIFunc {\XINT_NewExpr,{}\xint_gobble_i\xintthebareiieval }% +\def\XINT_newexpr_clean #1>{\noexpand\romannumeral`&&@}% +\def\XINT_NewExpr #1#2#3#4#5#6[#7]% {% \begingroup - \ifcase #5\relax - \toks0 {\xdef #4}% - \or \toks0 {\xdef #4##1#1}% - \or \toks0 {\xdef #4##1#1##2#1}% - \or \toks0 {\xdef #4##1#1##2#1##3#1}% - \or \toks0 {\xdef #4##1#1##2#1##3#1##4#1}% - \or \toks0 {\xdef #4##1#1##2#1##3#1##4#1##5#1}% - \or \toks0 {\xdef #4##1#1##2#1##3#1##4#1##5#1##6#1}% - \or \toks0 {\xdef #4##1#1##2#1##3#1##4#1##5#1##6#1##7#1}% - \or \toks0 {\xdef #4##1#1##2#1##3#1##4#1##5#1##6#1##7#1##8#1}% - \or \toks0 {\xdef #4##1#1##2#1##3#1##4#1##5#1##6#1##7#1##8#1##9#1}% + \ifcase #7\relax + \toks0 {\endgroup\def#5}% + \or \toks0 {\endgroup\def#5##1#1}% + \or \toks0 {\endgroup\def#5##1#1##2#1}% + \or \toks0 {\endgroup\def#5##1#1##2#1##3#1}% + \or \toks0 {\endgroup\def#5##1#1##2#1##3#1##4#1}% + \or \toks0 {\endgroup\def#5##1#1##2#1##3#1##4#1##5#1}% + \or \toks0 {\endgroup\def#5##1#1##2#1##3#1##4#1##5#1##6#1}% + \or \toks0 {\endgroup\def#5##1#1##2#1##3#1##4#1##5#1##6#1##7#1}% + \or \toks0 {\endgroup\def#5##1#1##2#1##3#1##4#1##5#1##6#1##7#1##8#1}% + \or \toks0 {\endgroup\def#5##1#1##2#1##3#1##4#1##5#1##6#1##7#1##8#1##9#1}% \fi \xintexprSafeCatcodes \XINT_expr_redefinemacros #2% - \XINT_NewExpr_a #4#3% + \XINT_NewExpr_a #3#4#5% }% \catcode`~ 13 \catcode`@ 14 \catcode`\% 6 \catcode`# 12 \catcode`$ 11 @ $ -\def\XINT_NewExpr_a %1%2%3@ +\def\XINT_NewExpr_a %1%2%3%4@ {@ - \def\XINT_tmpa %%1%%2%%3%%4%%5%%6%%7%%8%%9{%3}@ + \def\XINT_tmpa %%1%%2%%3%%4%%5%%6%%7%%8%%9{%4}@ \def~{$noexpand$}@ \catcode`: 11 \catcode`_ 11 \catcode`# 12 \catcode`~ 13 \escapechar 126 @@ -2434,12 +2426,13 @@ {\romannumeral`&&@\expandafter%2\XINT_tmpa {#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9}\relax}@ }@ \escapechar 92 \catcode`# 6 \catcode`$ 0 @ $ - \the\toks0 - {\scantokens\expandafter{\expandafter\XINT_newexpr_finish\meaning\XINT_tmpb}}@ - \ifxintverbose\xintMessage{info}{xintexpr} - {\string%1\space now with meaning \meaning%1}@ - \fi - \endgroup + \edef\XINT_tmpa %%1%%2%%3%%4%%5%%6%%7%%8%%9@ + {\scantokens\expandafter{\expandafter\XINT_newexpr_clean\meaning\XINT_tmpb}}@ + \the\toks0\expandafter{\XINT_tmpa{%%1}{%%2}{%%3}{%%4}{%%5}{%%6}{%%7}{%%8}{%%9}}@ + %1{\ifxintverbose + \xintMessage{info}{xintexpr}@ + {\string%3\space now with meaning \meaning%3}@ + \fi}@ }@ \catcode`% 14 \let\xintexprRestoreCatcodes\empty |