

%TEX
 \subsubsection{Match and build replace list.}
Try to find  an  alternative of a macro 
in which  the formal and actual parameters macth.
Build a replace list simultaniously.
%

match (>replace list, >FCComp*f*r,>VList* LIST * ff *rr):->,
     match (>replace list,>f,>ff),
     match (>replace list, >r,>VList *LIST *rr);
match (>replace list, >FCComp*f*r,>VBuiltin*compose operator * LIST * ff*rr*_):->,

     match (>replace list,>f,>ff),
     match (>replace list, >r,>rr);
match (>replace list, >FCSym*STRING*name,>actual ):->,
     add to (>replace list,>name,>actual),
     add to (>name, >FORMAL PAR,>empty),
     no renaming of (>actual); 
match (>replace list, >FpEmpty,>VList*LIST*empty):->;
match (>replace list, >FCList*LIST*x,>composed list):
     where (>composed list,VBuiltin*_>), ->,
     match comp (>replace list,>x,>composed list);
match (>replace list, >FCList*LIST*x,>VList*LIST*y):->,
     match els (>replace list,>x,>y), ->;
match (>replace list, >fp int etc *i f num*val,>par int etc  * i f num*val):. 


match comp (>replace list, >x*y,>VBuiltin*cp*LIST*xx*yy*_): ->,
     match (>replace list,>x,>xx), 
     match comp (>replace list,>y,>yy);
match comp (>replace list, >v,>v ):.


match els (>replace list, >x*y,>u*v): ->,
     match (>replace list,>x,>u), 
     match els (>replace list,>y,>v);
match els (>replace list, >v,>v ):.


no renaming of (>VSym*or*STRING*name): ->,
    add to (>name,>FORMAL PAR,>empty); 
no renaming of (>_):.


FORMAL PAR:: "FP".

%TEX
{\tt Replace list} makes a replace list
containing  the formal parameter list and the corresponding actual parameters.
%


replace list (>replace list,>VValApply*vsym cs*a 1,
           >VMacLambda*f 1*rest,rest>):
    where (>vsym cs,VSym*_>), ->,
    match  (>replace list,>f 1,>a 1);
replace list (>replace list,>VValApply*VVal first cs*a i,
                  >VMac first cs,rest>): ->,
    replace list (>replace list,>VVal first cs,>VMac first cs,
                     VMacLambda*f i*rest>),
    match (>replace list,>f i ,>a i);
replace list (>replace list,>VSym*_, >fc,fc>):.
%TEX

\subsection{ Transform lists}
The following code is all generated.
%

trans def list (> node, >LIST * ds ):
	trans def els (> ds ,> ds ),
        remove macros and par defs (>ds, trans def els>),
        repair (>node,>LIST, >trans def els).

trans def els (> node,> trans def * trans def els ):
	trans def(> trans def,> trans def),->,
	trans def els (> trans def els ,> trans def els );
trans def els (> constant, > empty):.

trans typ list (> node, >LIST * trans typ els ):
	trans typ els (> trans typ els ,> trans typ els ).

trans typ els (> node,> trans typ * trans typ els ):
	trans typ(> trans typ,> trans typ),->,
	trans typ els (> trans typ els ,> trans typ els );
trans typ els (> constant, > empty):.

trans formcon list (> node, >LIST * trans formcon els ):
	trans formcon els (> trans formcon els ,> trans formcon els ).

trans formcon els (> node,> trans formcon * trans formcon els ):
	trans formcon(> trans formcon,> trans formcon),->,
	trans formcon els (> trans formcon els ,> trans formcon els );
trans formcon els (> constant, > empty):.

trans val list (> node, >LIST * trans val els ,>apply node):
	trans val els (> trans val els ,> trans val els ,>apply node).

trans val els (> node,> trans val * trans val els,>apply node ):
	trans val(> trans val,> trans val,>apply node),->,
	trans val els (> trans val els ,> trans val els ,>apply node);
trans val els (> constant, > empty,>apply node):.
