#!/usr/bin/perl -s my $filename = shift; use camila; print "CAMTEX\n"; open(STDIN, "< $filename.aux") or die "cant find $filename.aux\n" ; open(CAL, "> $filename.cal") or die "cant open $filename.cal\n" ; print CAL '\gdef\@camila{\ifcase\cec',"\n lixo\n" ; while(<>){ if(/\\cam\@prototype{(.*?)}/){ print CAL camila::prototype($1);} if(/\\scam\@pretty{(.*?)}{(.*)/) { #} $name = "_f$1"; print "($name)\n"; $corpo = $2; for($corpo){ chop; s/;\s*$//; s/ENDTYPE\s*/ENDTYPE\n/; s/\s*\\par\s*/\n/g; s/##/#/g; s/\\unhbox \\voidb\@x \\penalty \\\@M \\ /~/g; s/\s*\{\\\s*\@\@par\s*\}\s*/\n/g; s/\\penalty \\\@M -\\penalty \\\@M \\hskip \\z\@skip /"-/g; s/\\hskip \\z\@skip /""/g; open(PRETTY,"| jjpretty -t") or die; print "$_;\n\n" if $debug; print PRETTY "$_;\n"; close PRETTY; my $aux=`cat _pretty.tex`; $aux =~ s/(\\\\)?\n*$/\n/; print CAL '\or ', $aux ; } } if(/\\cam\@pretty{(.*?)}{(.*)/) { #} $name = "_f$1"; print "($name)\n"; $corpo = $2; for($corpo){ chop; s/;\s*$//; s/ENDTYPE\s*/ENDTYPE\n/; s/\s*\\par\s*/\n/g; s/##/#/g; s/\\unhbox \\voidb\@x \\penalty \\\@M \\ /~/g; s/\s*\{\\\s*\@\@par\s*\}\s*/\n/g; s/\\penalty \\\@M -\\penalty \\\@M \\hskip \\z\@skip /"-/g; s/\\hskip \\z\@skip /""/g; open(PRETTY,"| jjpretty -t") or die; print "$_;\n\n" if $debug; print PRETTY "$_;\n"; close PRETTY; print CAL '\or ', `cat _pretty.tex`, "\n" ; } } if(/\\cam\@inppretty{(.*?)}{(.*?)}/) { #} $f = $2; print "($1 - $f)\n"; print("$f\n") ; system("jjpretty -t $f") ; print CAL '\or ', `cat _pretty.tex`, "\n" ; } if(/\\cam\@eval{(.*?)}{(.*)/) { #} $name = "_f$1"; $corpo = $2; for($corpo){ chop; s/;\s*$//; s/\\par/\n/g; s/##/#/g; s/\\unhbox \\voidb\@x \\penalty \\\@M \\ /~/g; s/\s*\{\\\s*\@\@par\s*\}\s*/\n/g; if (/^\s*(\w+)\(([^)]*)\)\s*=/) {camila::cameval("$_;"); print CAL "\\or $1\n"; } else {my $a = camila::cameval("pp($_);") ; $a =~ s/[{}\[\]#%]/\\$&/g; $a =~ s/\n$//; print CAL '\or ' ,"$a\n";} } } if(/\\cam\@input{(.*?)}{(.*)/) { #} $corpo = $2; $caminput_file = $1; chop $corpo; $corpo =~ s/\\par/\n/g; open(AUX,"> $caminput_file" ) or die "cant create $caminput_file\n"; print AUX camila::cameval($corpo) ; close AUX; } } print CAL '\fi}',"\n" ; print "\n"; __END__ \penalty \@M -\penalty \@M \hskip \z@skip