]> git.saurik.com Git - bison.git/blobdiff - build-aux/cross-options.pl
Generate the long/short option cross-table.
[bison.git] / build-aux / cross-options.pl
diff --git a/build-aux/cross-options.pl b/build-aux/cross-options.pl
new file mode 100755 (executable)
index 0000000..4c941b0
--- /dev/null
@@ -0,0 +1,32 @@
+#! /usr/bin/env perl
+
+use warnings;
+use 5.005;
+use strict;
+
+my %option;
+while (<>)
+{
+    if (/^\s*(?:(-\w), )?(--[-\w]+)(\[?)(=[-\w]+)?\]?/)
+    {
+       my ($short, $long, $opt, $arg) = ($1, $2, $3, $4);
+       $short = defined $short ? '@option{' . $short . '}' : '';
+       if ($arg)
+       {
+           $arg =~ s/^=//;
+           $arg = '@var{' . lc ($arg) . '}';
+           $arg = '[' . $arg . ']'
+               if defined $opt;
+           $option{"$long=$arg"} = "$short $arg";
+       }
+       else
+       {
+           $option{"$long"} = "$short";
+       }
+    }
+}
+
+foreach my $long (sort keys %option)
+{
+    printf "\@item %-40s \@tab %s\n", '@option{' . $long . '}', $option{$long};
+}