6 $mode = $ARGV[0] || die "mode?";
10 my $r = \
%{$ch{$_[0]}};
11 if (exists $r->{$1}) {
14 push @
{$ord{$_[0]}}, $1;
21 } elsif (/^\.OS (.*)$/) {
23 } elsif (/^\.GE/ || /^\.OD/) {
25 } elsif (/^\.GL (.*)$/) {
26 $ch{'grammar'}{$1} .= ".PP\n";
28 } elsif (/^\.OL (.*)$/) {
29 $ch{'option'}{$1} .= ".PP\n";
31 } elsif (/^@@@ (\w+)$/) {
33 foreach $head (@
{$ord{$1}}) {
40 $$chunk .= $_ if $chunk;
42 print if $mode eq 'man';
45 sub ital
{ uc($_[0]); }
46 sub bold
{ $head eq 'option' ?
$_[0] : "`$_[0]'"; }
53 for my $chunk (@
{$ord{$head}}) {
54 (my $chh = $chunk) =~ s/^"(.*)"$/$1/;
55 $out .= "$chsep$chh\n";
58 for (split /\n/, $ch{$head}{$chunk}) {
59 s/\s$//; s/\\\&//g; s/\\-/-/g;
61 $out .= $sep . ital
($1);
63 } elsif (/^\.B (.*)$/) {
64 $out .= $sep . bold
($1);
66 } elsif (/^\.RB (.*)/) {
67 my $i = 1; $out .= $sep; $sep = " ";
68 for my $w (split ' ', $1) {
72 $out .= ($i++%2 ? rom
($w) : bold
($w));
74 } elsif (/^\.BR (.*)/) {
75 my $i = 1; $out .= $sep; $sep = " ";
76 for my $w (split ' ', $1) {
80 $out .= ($i++%2 ? bold
($w) : rom
($w));
82 } elsif (/^\.IR (.*)/) {
83 my $i = 1; $out .= $sep; $sep = " ";
84 for my $w (split ' ', $1) {
88 $out .= ($i++%2 ? ital
($w) : rom
($w));
90 } elsif (/^\.RI (.*)/) {
91 my $i = 1; $out .= $sep; $sep = " ";
92 for my $w (split ' ', $1) {
96 $out .= ($i++%2 ? rom
($w) : ital
($w));
98 } elsif (/^\.BI (.*)/) {
99 my $i = 1; $out .= $sep; $sep = " ";
100 for my $w (split ' ', $1) {
104 $out .= ($i++%2 ? bold
($w) : ital
($w));
106 } elsif (/^\.IB (.*)/) {
107 my $i = 1; $out .= $sep; $sep = " ";
108 for my $w (split ' ', $1) {
112 $out .= ($i++%2 ? ital
($w) : bold
($w));
119 } elsif (/^\.br$/ || /^\.PP$/) {
133 * Generated grammar and options summary
139 for $head (keys %ch) {
140 print "const char ${head}_text[] = \"\\\n";
141 $text = deroff
($head);
142 $text =~ s/\n/\\n\\\n/g;
146 } elsif ($mode eq 'text') {
148 for $head (keys %ch) {
149 print $sep, deroff
($head);