openwcom.mak: wmake uses & for continuation, not \ (sigh)
[nasm.git] / macros.pl
blob98f97ee7e77e31ee14e06f3d8c60b02fa70bc1bc
1 #!/usr/bin/perl -w
3 # macros.pl produce macros.c from standard.mac
5 # The Netwide Assembler is copyright (C) 1996 Simon Tatham and
6 # Julian Hall. All rights reserved. The software is
7 # redistributable under the license given in the file "LICENSE"
8 # distributed in the NASM archive.
10 use strict;
12 my $fname;
13 my $line = 0;
14 my $index = 0;
15 my $tasm_count;
17 undef $tasm_count;
19 open(OUTPUT,">macros.c") or die "unable to open macros.c\n";
21 print OUTPUT "/* This file auto-generated from standard.mac by macros.pl" .
22 " - don't edit it */\n";
23 print OUTPUT "\n";
24 print OUTPUT "#include \"tables.h\"\n";
25 print OUTPUT "\n";
26 print OUTPUT "const char * const nasm_stdmac[] = {\n";
28 foreach $fname ( @ARGV ) {
29 open(INPUT,$fname) or die "unable to open $fname\n";
30 while (<INPUT>) {
31 $line++;
32 chomp;
33 if (m/^\s*\*END\*TASM\*MACROS\*\s*$/) {
34 $tasm_count = $index;
35 } elsif (m/^\s*((\s*([^\"\';\s]+|\"[^\"]*\"|\'[^\']*\'))*)\s*(;.*)?$/) {
36 $_ = $1;
37 s/\\/\\\\/g;
38 s/"/\\"/g;
39 if (length > 0) {
40 print OUTPUT " \"$_\",\n";
41 $index++;
43 } else {
44 die "$fname:$line: error unterminated quote";
47 close(INPUT);
49 print OUTPUT " NULL\n};\n\n";
50 $tasm_count = $index unless ( defined($tasm_count) );
51 print OUTPUT "const char * const * nasm_stdmac_after_tasm = ",
52 "&nasm_stdmac[$tasm_count];\n";
53 close(OUTPUT);