#!/bin/perl
# Perl output for Thutu2 file forte.t22
$_="=1";
$row="";
$ninequit=0;
while(!$ninequit)
{
$row =~ s/=/=q/g;
$row =~ s/\t/=t/g;
$row =~ s/\n/=x/g; # The newline at the end of the line becomes =x
$row =~ s/\r/=r/g;
$row =~ s/\f/=f/g;
$row =~ s/\a/=a/g;
$row =~ s/\e/=e/g;
$row =~ s/([!-\/:-<>-@[-`{-~])/=$1/g; #`
defined($row) or $row = '=9';
$_ = $row . $_;
while(1) {
s/^(.*)=x(.*)=:%x/$2=:$1=x/ and next;
s/=:=x/=:%x/ and next;
while(not(/<r>/ or /=9/ or /=:%x/ or 0)) {do {
s/^([0-9])/=n$1/ and next;
s/=1// and next;
s/=x/=n/ and next;
s/=n=n/=n/ and next;
s/REM[^=]/REM/ and next;
s/REM=[^n]/REM/ and next;
s/(PRINT[^=]*)=\"=\"=;/$1\~/ and next;
s/(PRINT[^=]*)=\"=\"/$1\~61\~110\~/ and next;
/PRINT[^=]*=\"(.)()/ and do{$c=ord($1);$e=$1eq$2;$g=$1gt$2;$u=uc($1);$l=lc($1);};
s/(PRINT[^=]*)=\"./$1\~$c=\"/ and next;
s/=t// and next;
s/=v// and next;
s/=f// and next;
s/=r// and next;
s/=([()])/%$1/ and next;
s/ // and next;
s/LET([^=%][^:nq]*)=q([^:nq]*[:n])/LET%\{$1%\}=q%\{$2%\}/ and next;
s/PRINT([^=%~;][^:n;]*?)=([:n;])/PRINT%\{$1%\}=$2/ and next;
s/%\(/%\{/ and next;
s/%\)/%\}/ and next;
s/=n%\}/%\}=n/ and next;
s/=:%\}/%\}=:/ and next;
s/([^{0-9~])([0-9]+)([^0-9~])/$1%\{$2%\}$3/ and next;
s/([^0-9~])([0-9]+)([^}%0-9~]|%[^}])/$1%\{$2%\}$3/ and next;
last;}};
while(not(/<r>/ or 0)) {do {
s/=9/<o><r><0><d>%,<p>/ and next;
last;}};
/<r>/ and s/=9// and next;
while(/<r>/ and 1) {do {
/^61\~110\~<o>/ and last;
/[^0-9]61\~110\~<o>/ and last;
s/%\{/%\(/ and next;
s/%\}/%\)/ and next;
/<r><([0-9]+)%\+(1)>/ and do {$s=$1+$2;$p=$1*$2;$d=$1-$2;$m=0;$2 and $m=$1%$2;$g=$1>$2;$c=chr($1);$e=$1==$2;$q=0;$2 and $q=$1/$2;$v=int($q);};
s/<r><[0-9]+%\+1>/<r><$s>/ and next;
s/%\,(%\([0-9]+%\))\1// and next;
s/%\,(%\([0-9]+%\))(%\([0-9]+%\))%\,(.*)\1/%\,$1$2%\,$3$2/ and next;
s/<r><i><([0-9]+)>/<r><$1%\+1>/ and next;
s/%\[([0-9]+)%\]/$1/ and next;
/%\[([0-9]+)=\+([0-9]+)%\]/ and do {$s=$1+$2;$p=$1*$2;$d=$1-$2;$m=0;$2 and $m=$1%$2;$g=$1>$2;$c=chr($1);$e=$1==$2;$q=0;$2 and $q=$1/$2;$v=int($q);};
s/%\[[0-9]+=\+[0-9]+%\]/%\($s%\)/ and next;
/%\[([0-9]+)=\-([0-9]+)%\]/ and do {$s=$1+$2;$p=$1*$2;$d=$1-$2;$m=0;$2 and $m=$1%$2;$g=$1>$2;$c=chr($1);$e=$1==$2;$q=0;$2 and $q=$1/$2;$v=int($q);};
s/%\[[0-9]+=\-[0-9]+%\]/%\($d%\)/ and next;
/%\[([0-9]+)=\*([0-9]+)%\]/ and do {$s=$1+$2;$p=$1*$2;$d=$1-$2;$m=0;$2 and $m=$1%$2;$g=$1>$2;$c=chr($1);$e=$1==$2;$q=0;$2 and $q=$1/$2;$v=int($q);};
s/%\[[0-9]+=\*[0-9]+%\]/%\($p%\)/ and next;
/%\[([0-9]+)=\/([0-9]+)%\]/ and do {$s=$1+$2;$p=$1*$2;$d=$1-$2;$m=0;$2 and $m=$1%$2;$g=$1>$2;$c=chr($1);$e=$1==$2;$q=0;$2 and $q=$1/$2;$v=int($q);};
s/%\[[0-9]+=\/[0-9]+%\]/%\($v%\)/ and next;
s/(<a>[^):n]*)%\(([^)]*)%\)/$1%\[$2%\]/ and next;
s/<r>(.*)<n>([^:]*?)=n/<r><i>$1$2=n/ and next;
s/<r>(.*)<n>([^:n]*?)=:([^:n]*[:n])/<t>$3<r>$1$2=:<a>$3/ and next;
while(not(/<a>/ or /<n>/ or /<i>/ or 0)) {do {
s/<r><([0-9]+)>(.*)<p>(.*)=n%\(\1%\)([^<][^:n]*[:n])/<t>$4<l><r><$1>$2<p>$3=n%\($1%\)<a>$4/ and next;
last;}};
s/<l>// and next;
s/<r>(.*)<a>REM/<r><i>$1REM/ and next;
s/<t>(.*)<r>(.*)<d>(.*)<a>LET([0-9]+)=q([0-9]+)=[:n]/<r>$2<d>%\,%\($4%\)%($5%\)$3<n>$1/ and next;
s/^(.*)<o>(.*)<t>(.*)<r>(.*)<a>PRINT\~([^=]*)=[:n]/$1$5<o>$2<r>$4<n>$3/ and next;
s/^(.*)<o>(.*)<t>(.*)<r>(.*)<a>PRINT([0-9]+)=;=[:n]/$1$5\^<o>$2<r>$4<n>$3/ and next;
s/^(.*)<o>(.*)<t>(.*)<r>(.*)<a>PRINT([0-9]+)=[:n]/$1$5\^61\~110\~<o>$2<r>$4<n>$3/ and next;
s/<o>.*<a>END.*$/<o>=9/ and next;
s/<r>/<r><i>/ and next;
last;}};
/<o>/ and do {while(1) {
while(not(/^\~/ or 0)) {do {
s/^/\~/ and next;
last;}};
s/<o>/%%0%%=x<%o%>/ and next;
/[~^]([0-9]+)\~%%(0)%%/ and do {$s=$1+$2;$p=$1*$2;$d=$1-$2;$m=0;$2 and $m=$1%$2;$g=$1>$2;$c=chr($1);$e=$1==$2;$q=0;$2 and $q=$1/$2;$v=int($q);};
s/([~^])([0-9]+)\~%%0%%/$1%%0%%$c/ and next;
s/([~^])([0-9]+)\^%%0%%/$1%%0%%$2/ and next;
while(1) {do {
s/^\~%%0%%// and next;
s/<%o%>/<o>/ and next;
last;}};
last;}};
last; }
s/=9// and $ninequit=1;
if(s/(.*?)=x//) # =x marks the end of what to print out.
{
$orow=$1;
$orow =~ s/=t/\t/g;
$orow =~ s/=n/\n/g; # =n converts back to newline.
$orow =~ s/=r/\r/g;
$orow =~ s/=f/\f/g;
$orow =~ s/=a/\a/g;
$orow =~ s/=e/\e/g;
$orow =~ s/=([!-\/:-<>-@[-`{-~])/$1/g; #`
$orow =~ s/=q/=/g;
# print "\n"; # DEBUG
print $orow;
}
# Perl changes input source on EOF, but we want to continue in an EOF
# condition after EOF is reached.
$ninequit or ($row eq '=9' and scalar($row = undef, 1)) or $row=<>;
};