diff options
author | Larry Wall <lwall@jpl-devvax.jpl.nasa.gov> | 1990-08-08 17:01:53 +0000 |
---|---|---|
committer | Larry Wall <lwall@jpl-devvax.jpl.nasa.gov> | 1990-08-08 17:01:53 +0000 |
commit | 154e51a4a1b0258759b5e901183403af515a35b9 (patch) | |
tree | de56925bf09e2d98ed44c60b3386d09cd675be3d /usub | |
parent | ff8e2863486f651339834bc9e3e0bd49d61ff4e1 (diff) | |
download | perl-154e51a4a1b0258759b5e901183403af515a35b9.tar.gz |
perl 3.0 patch #22 patch #19, continued
See patch #19.
Diffstat (limited to 'usub')
-rw-r--r-- | usub/man2mus | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/usub/man2mus b/usub/man2mus new file mode 100644 index 0000000000..a3046784f4 --- /dev/null +++ b/usub/man2mus @@ -0,0 +1,66 @@ +#!/usr/bin/perl +while (<>) { + if (/^\.SH SYNOPSIS/) { + $spec = ''; + for ($_ = <>; $_ && !/^\.SH/; $_ = <>) { + s/^\.[IRB][IRB]\s*//; + s/^\.[IRB]\s+//; + next if /^\./; + s/\\f\w//g; + s/\\&//g; + s/^\s+//; + next if /^$/; + next if /^#/; + $spec .= $_; + } + $_ = $spec; + 0 while s/\(([^),;]*)\s*,\s*([^);]*)\)/($1|$2)/g; + s/\(\*([^,;]*)\)\(\)/(*)()$1/g; + s/(\w+)\[\]/*$1/g; + + s/\n/ /g; + s/\s+/ /g; + s/(\w+) \(([^*])/$1($2/g; + s/^ //; + s/ ?; ?/\n/g; + s/\) /)\n/g; + s/ \* / \*/g; + s/\* / \*/g; + + $* = 1; + 0 while s/^((struct )?\w+ )([^\n,]*), ?(.*)/$1$3\n$1$4/g; + $* = 0; + s/\|/,/g; + + @cases = (); + for (reverse split(/\n/,$_)) { + if (/\)$/) { + ($type,$name,$args) = split(/(\w+)\(/); + $type =~ s/ $//; + if ($type =~ /^(\w+) =/) { + $type = $type{$1} if $type{$1}; + } + $type = 'int' if $type eq ''; + @args = grep(/./, split(/[,)]/,$args)); + $case = "CASE $type $name\n"; + foreach $arg (@args) { + $type = $type{$arg} || "int"; + $type =~ s/ //g; + $type .= "\t" if length($type) < 8; + if ($type =~ /\*/) { + $case .= "IO $type $arg\n"; + } + else { + $case .= "I $type $arg\n"; + } + } + $case .= "END\n\n"; + unshift(@cases, $case); + } + else { + $type{$name} = $type if ($type,$name) = /(.*\W)(\w+)$/; + } + } + print @cases; + } +} |