diff options
author | H. Peter Anvin <hpa@zytor.com> | 2002-04-30 21:01:08 +0000 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2002-04-30 21:01:08 +0000 |
commit | 734b188090539eddf08e61c317415f566446691b (patch) | |
tree | abc7516f5a80c8b0810f5018125eb5f95717ca76 /macros.pl | |
parent | 1cd0e2d5bf50b2cc482cad7beb8f7dee6a81d57b (diff) | |
download | nasm-734b188090539eddf08e61c317415f566446691b.tar.gz |
NASM 0.98.09nasm-0.98.09
Diffstat (limited to 'macros.pl')
-rw-r--r-- | macros.pl | 38 |
1 files changed, 27 insertions, 11 deletions
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/perl -w # # macros.pl produce macros.c from standard.mac # @@ -6,6 +6,11 @@ # Julian Hall. All rights reserved. The software is # redistributable under the licence given in the file "Licence" # distributed in the NASM archive. +use strict; + +my $fname; +my $line = 0; +my $index = 0; $fname = "standard.mac" unless $fname = $ARGV[0]; open INPUT,$fname || die "unable to open $fname\n"; @@ -15,14 +20,25 @@ print OUTPUT "/* This file auto-generated from standard.mac by macros.pl" . " - don't edit it */\n\nstatic char *stdmac[] = {\n"; while (<INPUT>) { - chomp; - # this regexp ought to match anything at all, so why bother with - # a sensible error message ;-) - die "swirly thing alert" unless /^\s*((\s*([^"';\s]+|"[^"]*"|'[^']*'))*)/; - $_ = $1; - s/\\/\\\\/g; - s/"/\\"/g; - print OUTPUT " \"$_\",\n" if length > 0; + $line++; + chomp; + if (m/^\s*((\s*([^"';\s]+|"[^"]*"|'[^']*'))*)\s*(;.*)?$/) { + $_ = $1; + s/\\/\\\\/g; + s/"/\\"/g; + if (length > 0) { + print OUTPUT " \"$_\",\n"; + if ($index >= 0) { + if (m/__NASM_MAJOR__/) { + $index = -$index; + } else { + $index++; + } + } + } + } else { + die "$fname:$line: error unterminated quote"; + } } - -print OUTPUT " NULL\n};\n" +$index = -$index; +print OUTPUT " NULL\n};\n#define TASM_MACRO_COUNT $index\n" |