ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/libcpjit/prep.pl
Revision: 1.1
Committed: Fri Oct 14 18:34:22 2005 UTC (18 years, 9 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #!/usr/bin/perl
2    
3     my $infile = $ARGV[0];
4    
5     open STDIN, "<:utf8", $infile
6     or die "$infile: $!";
7     binmode STDOUT, ":utf8";
8    
9     my $max_args = 9;
10    
11     while (<>) {
12     if (/«repeat»/) {
13     my $line1 = $. + 1;
14     my $block;
15     while (<>) {
16     last if /«end»/;
17     $block .= $_;
18     }
19     $line2 = $. + 1;
20    
21     for (0..$max_args) {
22     my $copy = $block;
23     $copy =~ s{«([^«»\|]*)\|([^«»\|]*)»}{join $2, map eval "\"$1\"", 1..$_}ge;
24     $copy =~ s/«([^«»\|]+)»/eval $1/ge;
25     print "\n#line $line1 \"$infile\"\n$copy";
26     }
27    
28     print "\n#line $line2 \"$infile\"\n";
29     } else {
30     s/«([^«»\|]+)»/eval $1/ge;
31     print;
32     }
33     }