- if (input == "")
- fatal("no contents: " file);
-
- input = normalize(input);
- # No spurious end of line: use printf.
- if (files_output[file])
- # The parens around the output file seem to be required
- # by awk on Mac OS X Tiger (darwin 8.4.6).
- printf ("%s", input) >> (output_dir "/" file);
- else
- printf ("%s", input) > (output_dir "/" file);
- close (output_dir "/" file);
- files_output[file] = 1;
+ if (/^\@comment file: (.*)/)
+ {
+ my $f = $1;
+ if ($file_wanted{$f})
+ {
+ $file = $file_wanted{$f};
+ message(" GEN $file");
+ }
+ else
+ {
+ message("SKIP $f");
+ }
+ }
+ elsif ($file && /^\@(small)?example$/ .. /^\@end (small)?example$/)
+ {
+ if (/^\@(small)?example$/)
+ {
+ $input = $file_output{$file} ? "\n" : "";
+ # Bison supports synclines, but not Flex.
+ $input .= sprintf ("#line %s \"$in\"\n", $. + 1)
+ if $file =~ /\.[chy]*$/;
+ next;
+ }
+ elsif (/^\@end (small)?example$/)
+ {
+ die "no contents: $file"
+ if $input eq "";
+
+ $input = normalize($input);
+ # No spurious end of line: use printf.
+ my $o =
+ ($file_output{$file}
+ ? new IO::File(">>$file")
+ : new IO::File(">$file"));
+ print $o $input;
+ $file_output{$file} = 1;
+ $file = $input = undef;
+ }
+ else
+ {
+ $input .= $_;
+ }
+ }