5
# Author: Paul Marquess
9
# Macro files end with .M
10
# Tagged source files end with .T
11
# Output from the code ends with .O
12
# Pre-Pod file ends with .P
27
$Verbose = 1 if $ARGV[0] =~ /^-v/i ;
30
foreach $file (glob("*.M"))
32
open (F, "<$file") or die "Cannot open '$file':$!\n" ;
33
print " Processing Macro file $file\n" ;
36
# Skip blank & comment lines
37
next if /^\s*$/ || /^\s*#/ ;
40
($name, $expand) = split (/\t+/, $_, 2) ;
45
if ($expand =~ /\[#/ )
49
$Macros{$name} = $expand ;
54
# Suck up all the code files
55
foreach $file (glob("t/*.T"))
57
($newfile = $file) =~ s/\.T$// ;
58
open (F, "<$file") or die "Cannot open '$file':$!\n" ;
59
open (N, ">$newfile") or die "Cannot open '$newfile':$!\n" ;
61
print " Processing $file -> $newfile\n" ;
65
if ($line =~ /^$TOKEN\s*BEGIN\s+(\w+)\s*$/ or
66
$line =~ m[\s*/\*$TOKEN\s*BEGIN\s+(\w+)\s*$] )
68
print " Section $1 begins\n" if $Verbose ;
70
$Section{$1} = '' unless $Section{$1} ;
72
elsif ($line =~ /^$TOKEN\s*END\s+(\w+)\s*$/ or
73
$line =~ m[^\s*/\*$TOKEN\s*END\s+(\w+)\s*$] )
75
warn "Encountered END without a begin [$line]\n"
76
unless $InSection{$1} ;
78
delete $InSection{$1} ;
79
print " Section $1 ends\n" if $Verbose ;
87
# Save the current line in each of the sections
88
foreach( keys %InSection)
90
if ($line !~ /^\s*$/ )
91
#{ $Section{$_} .= " $line" }
92
{ $Section{$_} .= $line }
93
$Section{$_} .= "\n" ;
101
# Check for unclosed sections
102
print "The following Sections are not terminated\n" ;
103
foreach (sort keys %InSection)
112
print "\n\nCreating pod file(s)\n\n" if $Verbose ;
114
@ppods = glob('*.P') ;
118
# Now process the pre-pod file
119
foreach $ppod (@ppods)
121
($pod = $ppod) =~ s/\.P$// ;
122
open (PPOD, "<$ppod") or die "Cannot open file '$ppod': $!\n" ;
123
open (POD, ">$pod") or die "Cannot open file '$pod': $!\n" ;
125
print " $ppod -> $pod\n" ;
127
while ($line = <PPOD>)
129
if ( $line =~ /^\s*$TOKEN\s*(\w+)\s*$/)
131
warn "No code insert '$1' available\n"
132
unless $Section{$1} ;
134
print "Expanding section $1\n" if $Verbose ;
135
print POD $Section{$1} ;
139
# $line =~ s/\[#([^\]])]/$Macros{$1}/ge ;