Index: mttroot/mtt/bin/trans/mtt_m2p ================================================================== --- mttroot/mtt/bin/trans/mtt_m2p +++ mttroot/mtt/bin/trans/mtt_m2p @@ -13,10 +13,13 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.6 1998/07/25 16:59:40 peterg +## Give other procedures local i,j vars. +## ## Revision 1.5 1998/07/25 15:06:17 peterg ## Added DDT VAR ## ## Revision 1.4 1998/07/25 15:05:54 peterg ## DD @@ -50,17 +53,10 @@ # Find system constants Nx=`grep "MTTNx " <$Sys\_def.r | awk '{print $3}' | sed 's/;//'` Nu=`grep "MTTNu " <$Sys\_def.r | awk '{print $3}' | sed 's/;//'` Ny=`grep "MTTNy " <$Sys\_def.r | awk '{print $3}' | sed 's/;//'` -#Regexps - name="[a-zA-Z0-9]*" - fun_name="$Sys\_$name" - space="[ \t]*" - spaces="[ \t][ \t]*" - non_space="[^ ]*" - # Heading (case $rep in state) echo "PROCEDURE $Sys_rep(VAR mttx : StateVector);" ;; @@ -85,18 +81,25 @@ echo "PROGRAM $Sys_rep;" echo "TYPE" echo " StateVector =ARRAY[1..$Nx] OF REAL;" echo " InputVector =ARRAY[1..$Nu] OF REAL;" echo " OutputVector =ARRAY[1..$Ny] OF REAL;" + echo " IntegrationMethod = (Euler,ImplicitL,Implicit);" echo "VAR" echo " t,LAST,DT,DDT : REAL;" echo " mttx,mttdx : StateVector;" echo " mttu : InputVector;" echo " mtty : OutputVector;" echo " i,j,it,iLast,STEPFACTOR : INTEGER;" echo " METHOD : STRING;" ;; + switch) + echo "PROCEDURE $Sys_rep(VAR mttxs : StateVector;" + echo " mttx : StateVector);" + echo "VAR" + echo " i,j : INTEGER;" + ;; *) echo "PROCEDURE $Sys_rep;" echo "VAR" echo " i,j : INTEGER;" ;; esac) > $Filename @@ -106,19 +109,26 @@ {*** System $Sys, rep $rep, language Pascal, file $Filename ***} {*** Translated by MTT from $Sys_rep.m on `date` ***} EOF - +#Regexps + name="[a-zA-Z0-9]*" + fun_name="$Sys\_$name" + mttfun_name="mtt_update" + space="[ \t]*" + spaces="[ \t][ \t]*" + non_space="[^ ]*" # Body grep -v '^[ ]*function' < $Sys_rep.m | sed "s/^$space%/#/" |\ awk -F# '{printf("%s",$1) if (NF>1) printf("{* %s *}", $2) printf("\n") }' |\ sed "s/$space\[\($non_space\)\]$spaces=$spaces\($fun_name\)(\([a-zA-Z0-9,]*\))/\2(\1,\3)/" |\ +sed "s/$space\[\($non_space\)\]$spaces=$spaces\($mttfun_name\)(\([a-zA-Z0-9,]*\))/\2(\1,\3)/" |\ sed "s/$space\[\($non_space\)\]$spaces=$spaces\($fun_name\)/\2(\1)/" |\ sed "s/$space\($non_space\)$spaces=$spaces\($fun_name\)(\([a-zA-Z0-9,]*\))/\2(\1,\3)/" |\ sed "s/$space\($non_space\)$spaces=$spaces\($fun_name\)/\2(\1)/" |\ awk ' BEGIN{ @@ -156,10 +166,12 @@ printf("{%s %s_numpar.p}\n",inc,sys) printf("{%s %s_state.p}\n",inc,sys) printf("{%s %s_input.p}\n",inc,sys) printf("{%s %s_ode.p}\n",inc,sys) printf("{%s %s_odeo.p}\n",inc,sys) + printf("{%s %s_switch.p}\n",inc,sys) + printf("{%s mtt_update.p}\n",inc,sys) printf("{%s mtt_write.p}\n",inc,sys) } for (k=1;k<=j;k++) printf("%s\n", comment[k]) printf("\n") printf("\nBEGIN\n") @@ -171,11 +183,12 @@ else printf("%s\n", $0) } else { if ($1=="if") { - printf("%s THEN BEGIN", $0) + sub(/==/, "=", $0) + printf("%s THEN BEGIN\n", $0) } else{ if ($1=="for"){ sub(/:/," TO ",$0) sub(/=/,":=",$0)