3
# Simple macro processor.
5
# Macros are defined in a control file that follows
6
# a simple definition-based grammar as documented in the
7
# trans script. Stdin is then copied to stdout, and any
8
# occurrence of @@MACRO@@ is substituted. Macros can also
9
# be specified on the command line.
11
die "usage: macro [-O<openquote>] [-C<closequote>] [-Dname=var ...] [control-file ...] " if (@ARGV < 1);
17
while ($arg=shift(@ARGV)) {
19
if ($arg =~ /^-D(\w+)(?:=(.*))?$/) {
21
} elsif ($arg =~ /-O(.*)$/) {
23
} elsif ($arg =~ /-C(.*)$/) {
26
die "unrecognized option: $arg";
29
open(CONTROL, "< $arg") or die "cannot open $arg";
31
if (/^!define\s+(\w+)(?:\s+['"]?(.*?)['"]?)?\s*$/) {
38
sub print_symbol_table {
39
foreach my $k (sort (keys(%Parms))) {
41
print "[$k] -> \"$v\"\n";
45
#print_symbol_table ();