Create dummy file to test nasm-cvs list
[platform/upstream/nasm.git] / macros.pl
1 #!/usr/bin/perl -w
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 # use strict;
11
12 my $fname;
13 my $line = 0;
14 my $index = 0;
15
16 $fname = "standard.mac" unless $fname = $ARGV[0];
17 open INPUT,$fname || die "unable to open $fname\n";
18 open OUTPUT,">macros.c" || die "unable to open macros.c\n";
19
20 print OUTPUT "/* This file auto-generated from standard.mac by macros.pl" .
21         " - don't edit it */\n\n#include <stddef.h>\n\nstatic char *stdmac[] = {\n";
22
23 while (<INPUT>) {
24         $line++;
25         chomp;
26         if (m/^\s*((\s*([^"';\s]+|"[^"]*"|'[^']*'))*)\s*(;.*)?$/) {
27                 $_ = $1;
28         s/\\/\\\\/g;
29         s/"/\\"/g;
30                 if (length > 0) {
31                         print OUTPUT "    \"$_\",\n";
32                         if ($index >= 0) {
33                                 if (m/__NASM_MAJOR__/) {
34                                         $index = -$index;
35                                 } else {
36                                         $index++;
37                                 }
38                         }               
39                 } 
40         } else {
41                 die "$fname:$line:  error unterminated quote";
42         }
43 }
44 $index = -$index;
45 print OUTPUT "    NULL\n};\n#define TASM_MACRO_COUNT $index\n"