2008-11-15 Di-an Jan Improves options in the manual. * doc/bison.texinfo (-g, -x): Add space before argument. (Option Cross Key): Implement FIXME: listing directives also. * build-aux/cross-options.pl (Short Option): Special case -d. Put arguments inside @option{...}. (Bison Directive): Add column, automatically extracted from src/scan-gram.l with special case for %define. diff --git a/build-aux/cross-options.pl b/build-aux/cross-options.pl index 2cec369..ef117f0 100755 --- a/build-aux/cross-options.pl +++ b/build-aux/cross-options.pl @@ -5,6 +5,9 @@ use 5.005; use strict; my %option; +my %directive; +my $scanner = `grep -i '"%[a-z]' src/scan-gram.l`; +$scanner =~ s/"\[-_\]"/-/g; while (<>) { if (/^\s* # Initial spaces. @@ -16,7 +19,10 @@ while (<>) /x) { my ($short, $long, $opt, $arg) = ($1, $2, $3, $4); - $short = defined $short ? '@option{' . $short . '}' : ''; + $short = '' if ! defined $short; + $short = '-d' if $long eq '--defines' && ! $short; + my $dir = '%' . substr($long, 2); + $dir = '' if index ($scanner, "\"$dir\"") < 0; if ($arg) { # if $opt, $arg contains the closing ]. @@ -24,25 +30,40 @@ while (<>) if $opt eq '['; $arg =~ s/^=//; $arg = lc ($arg); + my $dir_arg = $arg; # If the argument is compite (e.g., for --define[=NAME[=VALUE]]), # put each word in @var, to build @address@hidden, not # @var{name[=value]}]. $arg =~ s/(\w+)/address@hidden/g; $arg = '[' . $arg . ']' if $opt eq '['; - $option{"$long=$arg"} = $short ? "$short $arg" : ''; - } - else - { - $option{"$long"} = "$short"; + # For arguments of directives: this only works if all arguments + # are strings and have the same syntax as on the command line. + if ($dir_arg eq 'name[=value]') + { + $dir_arg = '@var{name} ["@var{value}"]'; + } + else + { + $dir_arg =~ s/(\w+)/address@hidden"$1"}/g; + $dir_arg = '[' . $dir_arg . ']' + if $opt eq '['; + } + $long = "$long=$arg"; + $short = "$short $arg" if $short && $short ne '-d'; + $dir = "$dir $dir_arg" if $dir; } + $option{$long} = $short; + $directive{$long} = $dir; } } foreach my $long (sort keys %option) { # Avoid trailing spaces. - printf ("address@hidden %-40s address@hidden", - '@option{' . $long . '}', - $option{$long} ? " $option{$long}" : ""); + print '@item @option{', $long, "address@hidden"; + print ' @option{', $option{$long}, '}' if $option{$long}; + print "address@hidden"; + print ' @code{', $directive{$long}, '}' if $directive{$long}; + print "\n"; } diff --git a/doc/bison.texinfo b/doc/bison.texinfo index 70f6267..faa6e45 100644 --- a/doc/bison.texinfo +++ b/doc/bison.texinfo @@ -7999,7 +7999,7 @@ Specify the @var{file} for the parser file. The other output files' names are constructed from @var{file} as described under the @samp{-v} and @samp{-d} options. address@hidden address@hidden address@hidden -g address@hidden @itemx address@hidden Output a graphical representation of the @acronym{LALR}(1) grammar automaton computed by Bison, in @uref{http://www.graphviz.org/, Graphviz} @@ -8008,7 +8008,7 @@ automaton computed by Bison, in @uref{http://www.graphviz.org/, Graphviz} If omitted and the grammar file is @file{foo.y}, the output file will be @file{foo.dot}. address@hidden address@hidden address@hidden -x address@hidden @itemx address@hidden Output an XML report of the @acronym{LALR}(1) automaton computed by Bison. @address@hidden is optional. @@ -8021,12 +8021,11 @@ More user feedback will help to stabilize it.) @node Option Cross Key @section Option Cross Key address@hidden FIXME: How about putting the directives too? Here is a list of options, alphabetized by long option, to help you find the corresponding short option. address@hidden address@hidden@var{defines-file}}} address@hidden @var{file-prefix}XXX}} address@hidden Long Option @tab Short Option address@hidden address@hidden@var{defines-file}}} address@hidden @address@hidden address@hidden address@hidden Long Option @tab Short Option @tab Bison Directive @include cross-options.texi @end multitable