File: gri2texi

package info (click to toggle)
gri 2.12.26-1
  • links: PTS
  • area: main
  • in suites: buster, sid
  • size: 5,952 kB
  • ctags: 2,396
  • sloc: cpp: 36,598; sh: 4,196; lisp: 3,764; perl: 1,362; ansic: 1,046; makefile: 606
file content (38 lines) | stat: -rwxr-xr-x 1,323 bytes parent folder | download | duplicates (8)
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
#!/usr/bin/perl
# Convert Gri file to texi file.
die "Usage: gri2texi file.gri file.texi" if ($#ARGV !=1);
open(IN,  "$ARGV[0]")  || die "Can't open `$ARGV[0]' for input\n";
open(OUT, ">$ARGV[1]") || die "Can't open `$ARGV[1]' for output\n";

$now = localtime;
print OUT "\@c Created $now by $0 from $ARGV[0].gri\n" ;
print OUT "\@example\n";
while(<IN>) {
    s:\@:\@\@:g; 
    s:\{:\@{:g; 
    s:\}:\@}:g; 
    s:([^\$])\#(.*):$1\@emph{\# $2}:g;
    # s:"(.*)":\@emph{"$1"}:g;
    s:^if(\b):$1\@strong{if}$2:g;
    s:(\b)if(\b):$1\@strong{if}$2:g;
    s:^else(\b):$1\@strong{else}$2:g;
    s:(\b)else(\b):$1\@strong{else}$2:g;
    s:^for(\b):$1\@strong{for}$2:g;
    s:(\b)for(\b):$1\@strong{for}$2:g;
    s:^foreach(\b):$1\@strong{foreach}$2:g;
    s:(\b)foreach(\b):$1\@strong{foreach}$2:g;
    s:^while(\b):$1\@strong{while}$2:g;
    s:(\b)while(\b):$1\@strong{while}$2:g;
    s:^do(\b):$1\@strong{do}$2:g;
    s:(\b)do(\b):$1\@strong{do}$2:g;
    s:^return(\b):$1\@strong{return}$2:g;
    s:(\b)return(\b):$1\@strong{return}$2:g;
    s:^sub(\b):$1\@strong{sub}$2:g;
    s:(\b)sub(\b):$1\@strong{sub}$2:g;
    # s:(\b)eq(\b):$1\@strong{eq}$2:g;
    # s:(\b)ne(\b):$1\@strong{ne}$2:g;
    s:^break(\b):$1\@strong{break}$2:g;
    s:(\b)break(\b):$1\@strong{break}$2:g;
    print OUT "$_";
}
print OUT "\@end example\n";