home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / nasm097s.zip / MACROS.PL < prev    next >
Perl Script  |  1997-10-02  |  936b  |  29 lines

  1. #!/usr/bin/perl
  2. #
  3. # macros.pl   produce macros.c from standard.mac
  4. #
  5. # The Netwide Assembler is copyright (C) 1996 Simon Tatham and
  6. # Julian Hall. All rights reserved. The software is
  7. # redistributable under the licence given in the file "Licence"
  8. # distributed in the NASM archive.
  9.  
  10. $fname = "standard.mac" unless $fname = $ARGV[0];
  11. open INPUT,$fname || die "unable to open $fname\n";
  12. open OUTPUT,">macros.c" || die "unable to open macros.c\n";
  13.  
  14. print OUTPUT "/* This file auto-generated from standard.mac by macros.pl" .
  15.         " - don't edit it */\n\nstatic char *stdmac[] = {\n";
  16.  
  17. while (<INPUT>) {
  18.   chomp;
  19.   # this regexp ought to match anything at all, so why bother with
  20.   # a sensible error message ;-)
  21.   die "swirly thing alert" unless /^\s*((\s*([^"';\s]+|"[^"]*"|'[^']*'))*)/;
  22.   $_ = $1;
  23.   s/\\/\\\\/g;
  24.   s/"/\\"/g;
  25.   print OUTPUT "    \"$_\",\n" if length > 0;
  26. }
  27.  
  28. print OUTPUT "    NULL\n};\n"
  29.