I don't know much about asm, but maybe this will help a little. A s///
should work, and as the replacement value it can call a function to do the
work.
# untested
$code = handle_includes($code);
sub handle_includes {
my $code = shift;
$code = s/^\s*include\s+([\w\.]+)/include_file($1)/eg;
return $code;
}
sub include_file {
my $file = shift;
my $result;
local $/ = undef; # slurp mode
open IN, $file or die "Cannot include file $file: $!\n";
$result = <IN>;
close IN;
$result = handle_includes($result); # recursively handle includes
return $file_content;
}
Rob
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 15, 2004 3:38 PM
To: [EMAIL PROTECTED]
Subject: Making a linker/preassembler
Hi,
I'm planning to make a kind of linker/preassembler for making ROM source
files from multiple header and ASM files.
What sort of regular expression and algoriths could I use to search for
things like "include Name.dat", etc?
Thanks,
Lewis
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>