]>
git.saurik.com Git - bison.git/blob - examples/extexi
6315479c4957ae94567179c5944b15c15b508aed
2 # Extract all examples from the manual source.
4 # This file is part of GNU Bison
6 # Copyright (C) 1992, 2000-2001, 2005-2006, 2009-2012 Free Software
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 # Usage: extexi input-file.texi ... -- [FILES to extract]
28 # Remove Texinfo mark up.
33 s/^\@(c |comment|dots|end (ignore|group)|ignore|group).*//mg;
34 s/\@value\{VERSION\}/$ENV{VERSION}/g;
35 s/^\@(error|result)\{\}//mg;
41 # Print messages only once.
48 print STDERR
"extexi: $msg\n";
53 # basename => full file name for files we should extract.
55 # Whether we already say that file (in which case, append instead of
63 my $f = new IO
::File
($in)
64 or die "$in: cannot open: $?";
65 # The latest "@comment file: " argument.
67 # The @example block currently read.
72 if (/^\@comment file: (.*)/)
77 $file = $file_wanted{$f};
78 message
(" GEN $file");
85 elsif ($file && /^\@(small)?example$/ .. /^\@end (small)?example$/)
87 if (/^\@(small)?example$/)
89 $input = $file_output{$file} ? "\n" : "";
90 # Bison supports synclines, but not Flex.
91 $input .= sprintf ("#line %s \"$in\"\n", $. + 1)
92 if $file =~ /\.[chy]*$/;
95 elsif (/^\@end (small)?example$/)
97 die "no contents: $file"
100 $input = normalize
($input);
101 # No spurious end of line: use printf.
104 ? new IO
::File
(">>$file")
105 : new IO
::File
(">$file"));
107 $file_output{$file} = 1;
108 $file = $input = undef;
130 $file_wanted{basename
($arg)} = $arg;
141 ### Setup "GNU" style for perl-mode and cperl-mode.
143 ## perl-indent-level: 2
144 ## perl-continued-statement-offset: 2
145 ## perl-continued-brace-offset: 0
146 ## perl-brace-offset: 0
147 ## perl-brace-imaginary-offset: 0
148 ## perl-label-offset: -2
149 ## cperl-indent-level: 2
150 ## cperl-brace-offset: 0
151 ## cperl-continued-brace-offset: 0
152 ## cperl-label-offset: -2
153 ## cperl-extra-newline-before-brace: t
154 ## cperl-merge-trailing-else: nil
155 ## cperl-continued-statement-offset: 2