Debian Codegraph @

doc/gri2texi

raw
1 #!/usr/bin/perl
2 # Convert Gri file to texi file.
3 die "Usage: gri2texi file.gri file.texi" if ($#ARGV !=1);
4 open(IN, "$ARGV[0]") || die "Can't open `$ARGV[0]' for input\n";
5 open(OUT, ">$ARGV[1]") || die "Can't open `$ARGV[1]' for output\n";
6
7 $now = localtime;
8 print OUT "\@c Created $now by $0 from $ARGV[0].gri\n" ;
9 print OUT "\@example\n";
10 while(<IN>) {
11 s:\@:\@\@:g;
12 s:\{:\@{:g;
13 s:\}:\@}:g;
14 s:([^\$])\#(.*):$1\@emph{\# $2}:g;
15 # s:"(.*)":\@emph{"$1"}:g;
16 s:^if(\b):$1\@strong{if}$2:g;
17 s:(\b)if(\b):$1\@strong{if}$2:g;
18 s:^else(\b):$1\@strong{else}$2:g;
19 s:(\b)else(\b):$1\@strong{else}$2:g;
20 s:^for(\b):$1\@strong{for}$2:g;
21 s:(\b)for(\b):$1\@strong{for}$2:g;
22 s:^foreach(\b):$1\@strong{foreach}$2:g;
23 s:(\b)foreach(\b):$1\@strong{foreach}$2:g;
24 s:^while(\b):$1\@strong{while}$2:g;
25 s:(\b)while(\b):$1\@strong{while}$2:g;
26 s:^do(\b):$1\@strong{do}$2:g;
27 s:(\b)do(\b):$1\@strong{do}$2:g;
28 s:^return(\b):$1\@strong{return}$2:g;
29 s:(\b)return(\b):$1\@strong{return}$2:g;
30 s:^sub(\b):$1\@strong{sub}$2:g;
31 s:(\b)sub(\b):$1\@strong{sub}$2:g;
32 # s:(\b)eq(\b):$1\@strong{eq}$2:g;
33 # s:(\b)ne(\b):$1\@strong{ne}$2:g;
34 s:^break(\b):$1\@strong{break}$2:g;
35 s:(\b)break(\b):$1\@strong{break}$2:g;
36 print OUT "$_";
37 }
38 print OUT "\@end example\n";