% Copyright 2012-2022, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% SPLinT is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with SPLinT.  If not, see <http://www.gnu.org/licenses/>.

% some examples of the `tree evaluator' and the `expandable arithmetic' macros

\input ../../tex/yycommon.sty
\input ../../tex/trt1.sty
\input ../../tex/yymisc.sty
\input basic.sty
\input tree.sty

% defining the node arities for the tree evaluator

\nodesetup{xmul}{2}
\nodesetup{xsum}{2}
\nodesetup{xxttop}{0}
\nodesetup{the}{0}
\nodesetup{number}{0}

%\tracingmacros=3
%\tracingonline=3

\tempca=77

\edef\asum{\xsum{0}{21809808}}
\edef\aproduct{\xmul{118768770987098709870987098787979}{69876987698769824320980}}

\message{product: \aproduct, sum: \asum}

\def\anexpression{\treeeval{\xmul{\xsum{\xsum{1}{\xmul{2764567}{74674}}}{3}}{\xsum{\the\tempca}{\xsum{\number\tempcb}{\xmul{5764567}{7}}}}}}

\message{value of the expression: \anexpression}

% `symbolic definitions' of the nodes for the tree evaluator

\def\xsum#1#2{(#1 + #2)}
\def\xmul#1#2{#1 * #2}

\message{expression: \anexpression}

%\tracingmacros=0
%\tracingonline=0

%\tempca=17

%\edef\seq{\noexpand\startconversion\expander{}\sequence\tempca{*}SS\sequence\tempca{.}SS\sequence\tempca{.}SF}
%\show\seq
%\edef\cseq{\seq}
%\show\cseq

\end

.
