home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / perl-5.003-src.tgz / tar.out / fsf / perl / vms / vms_yfix.pl < prev    next >
Text File  |  1996-09-28  |  2KB  |  57 lines

  1. # This script takes the output produced from perly.y by byacc and
  2. # the perly.fixer shell script (i.e. the perly.c and perly.h built
  3. # for Unix systems) and patches them to produce copies containing
  4. # appropriate declarations for VMS handling of global symbols.
  5. #
  6. # If it finds that the input files are already patches for VMS,
  7. # it just copies the input to the output.
  8. #
  9. # Revised 29-Jan-1996 by Charles Bailey  bailey@genetics.upenn.edu
  10.  
  11. $VERSION = '1.1';
  12.  
  13. ($cinfile,$hinfile,$coutfile,$houtfile) = @ARGV;
  14.  
  15. open C,$cinfile or die "Can't read $cinfile: $!\n";
  16. open COUT, ">$coutfile" or die "Can't create $coutfile: $!\n";
  17. print COUT <<EOH;
  18. /* Postprocessed by vms_yfix.pl $VERSION to add VMS declarations of globals */
  19. EOH
  20. while (<C>) {
  21.   # "y.tab.c" is illegal as a VMS filename; DECC 5.2/VAX preprocessor
  22.   # doesn't like this.
  23.   if ( s/^#line\s+(\d+)\s+"y.tab.c"/#line $1 "y_tab.c"/ ) { 1; }
  24.   else {
  25.     # add the dEXT tag to definitions of global vars, so we'll insert
  26.     # a globaldef when perly.c is compiled
  27.     s/^(short|int|YYSTYPE|char \*)\s*yy/dEXT $1 yy/;
  28.   }
  29.   print COUT;
  30. }
  31. close C;
  32. close COUT;
  33.  
  34. open H,$hinfile  or die "Can't read $hinfile: $!\n";
  35. open HOUT, ">$houtfile" or die "Can't create $houtfile: $!\n";
  36. print HOUT <<EOH;
  37. /* Postprocessed by vms_yfix.pl $VERSION to add VMS declarations of globals */
  38. EOH
  39. $hfixed = 0;  # keep -w happy
  40. while (<H>) {
  41.   $hfixed = /globalref/ unless $hfixed;  # we've already got a fixed copy
  42.   next if /^extern YYSTYPE yylval/;  # we've got a Unix version, and this
  43.                                      # is what we want to replace
  44.   print HOUT;
  45. }
  46. close H;
  47.  
  48. print HOUT <<'EODECL' unless $hfixed;
  49. #ifndef vax11c
  50.   extern YYSTYPE yylval;
  51. #else
  52.   globalref YYSTYPE yylval;
  53. #endif
  54. EODECL
  55.  
  56. close HOUT;
  57.