doc: Nasm -> NASM
[nasm/autotest.git] / macros.pl
blob7bba2b19a491d1e8369d6e811273b19699dc951e
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 "/*\n";
22 print OUTPUT " * Do not edit - this file auto-generated by macros.pl from:\n";
23 print OUTPUT " * ", join(' ', @ARGV), "\n";
24 print OUTPUT " */\n";
25 print OUTPUT "\n";
26 print OUTPUT "#include \"tables.h\"\n";
27 print OUTPUT "\n";
28 print OUTPUT "const char * const nasm_stdmac[] = {";
30 foreach $fname ( @ARGV ) {
31 open(INPUT,$fname) or die "unable to open $fname\n";
32 print OUTPUT "\n /* From $fname */\n";
33 while (<INPUT>) {
34 $line++;
35 chomp;
36 if (m/^\s*\*END\*TASM\*MACROS\*\s*$/) {
37 $tasm_count = $index;
38 print OUTPUT " /* End of TASM macros */\n";
39 } elsif (m/^\s*((\s*([^\"\';\s]+|\"[^\"]*\"|\'[^\']*\'))*)\s*(;.*)?$/) {
40 $_ = $1;
41 s/\\/\\\\/g;
42 s/"/\\"/g;
43 if (length > 0) {
44 print OUTPUT " \"$_\",\n";
45 $index++;
47 } else {
48 die "$fname:$line: error unterminated quote";
51 close(INPUT);
53 print OUTPUT "\n NULL\n};\n\n";
54 $tasm_count = $index unless ( defined($tasm_count) );
55 print OUTPUT "const char * const * nasm_stdmac_after_tasm = ",
56 "&nasm_stdmac[$tasm_count];\n";
57 close(OUTPUT);