1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
function [txt,ilst,vnms,vtps,lcount]=cod2sci(lst,ilst,vnms,vtps)
//
//!
// Copyright INRIA
nlst=size(lst)
txt=[]
ilst=ilst-1
while ilst<nlst then
ilst=ilst+1
op=lst(ilst)
if type(op)==15 then return,end
select op(1)
case '1' then //stackp
// write(6,'stackp '+op(2));
prev=lst(ilst-1)
if size(prev,'*')==1 then prev=[prev ' '],end
if prev(1:2)==['5','25']|prev(1)=='20' then
lhs=evstr(prev(4))
else
lhs=1
end
if lhs==1 then
expk=stk(1);
opk=lst(ilst);ilst=ilst+1
opk2=opk(2)
if expk(2)<>'-1'& expk(2)<>'-2' then
if opk(2)=='ans' then
txt=[txt;expk(1)+';']
else
if funptr(opk2)<>0 then opk2='%'+opk(2),end
txt=[txt;opk2+' = '+expk(1)+';']
end
nv=find(opk(2)==vnms(:,2))
if nv==[] then
nv=size(vnms,1)+1,
// if funptr(opk2)<>0 then opk2='%'+opk(2),end
end
nv=nv($)
vnms(nv,:)=[opk2,opk(2)]
vtps(nv)=list(expk(5),expk(3),expk(4),0)
end
else //if size(stk)==1 then
LHS=[]
for k=1:lhs
expk=stk(k);
opk=lst(ilst);ilst=ilst+1
opk2=opk(2)
if funptr(opk2)<>0 then opk2='%'+opk(2),end
LHS=[opk2,LHS]
nv=find(opk(2)==vnms(:,2))
if nv==[] then
nv=size(vnms,1)+1,
end
nv=nv($)
vnms(nv,:)=[opk2,opk(2)]
if size(expk)<5 then pause,end
vtps(nv)=list(expk(5),expk(3),expk(4),0)
end
if stk(1)(2)=='-1' then // variable has not been previously stored
txt=[txt;'['+makeargs(LHS)+'] = '+stk(1)(1)+';']
end
end
if ilst<=nlst then
if lst(ilst)(1)<>'15' then
ilst=ilst-1,
else
lcount=lcount+1
end
end
case '12' then //pause
txt=[txt;'pause']
case '13' then //break
txt=[txt;'break']
case '14' then //abort
txt=[txt;'abort']
case '15' then ,//eol
txt=[txt;' ']
lcount=lcount+1
case '18' then
case '99' then //return
txt=[txt;'return']
else
[stk,t1,ilst,vnms,vtps]=exp2sci(lst,ilst,vnms,vtps);
txt=[txt;t1];t1=[]
ilst=ilst-1
end
end
ilst=ilst+1
|