]>
git.saurik.com Git - bison.git/blob - build-aux/cross-options.pl
9 my $scanner = `grep -i '"%[a-z]' $ARGV[0]`;
10 $scanner =~ s/"\[-_\]"/-/g;
13 if (/^\s
* # Initial spaces.
14 (?:(-\w
),\s
+)? # $1: $short: Possible short option.
15 (--[-\w
]+) # $2: $long: Long option.
16 (\
[?) # $3: $opt: '[' iff the argument is optional.
17 (?:=(\S
+))? # $4: $arg: Possible argument name.
21 my ($short, $long, $opt, $arg) = ($1, $2, $3, $4);
22 $short = '' if ! defined $short;
23 $short = '-d' if $long eq '--defines' && ! $short;
24 my $dir = '%' . substr($long, 2);
25 if (index ($scanner, "\"$dir\"") < 0)
27 if ($long eq '--force-define') { $dir = '%define'; }
32 # if $opt, $arg contains the closing ].
33 substr ($arg, -1) = ''
38 # If the argument is compite (e.g., for --define[=NAME[=VALUE]]),
39 # put each word in @var, to build @var{name}[=@var{value}], not
40 # @var{name[=value]}].
41 $arg =~ s/(\w+)/\@var{$1}/g;
42 my $long_arg = "=$arg";
44 $long_arg = "[$long_arg]";
47 # For arguments of directives: this only works if all arguments
48 # are strings and have the same syntax as on the command line.
49 if ($dir_arg eq 'name[=value]')
51 $dir_arg = '@var{name} ["@var{value}"]';
55 $dir_arg =~ s/(\w+)/\@var{"$1"}/g;
56 $dir_arg = '[' . $dir_arg . ']'
59 $long = "$long$long_arg";
60 $short = "$short $arg" if $short && $short ne '-d';
61 $dir = "$dir $dir_arg" if $dir;
63 $option{$long} = $short;
64 $directive{$long} = $dir;
69 foreach my $long (sort keys %option)
71 # Avoid trailing spaces.
74 print '@item @option{', $long, "}\n\@tab";
75 print ' @option{', $option{$long}, '}' if $option{$long};
77 print ' @code{', $directive{$long}, '}' if $directive{$long};