I've implemented a .include directive for the new assembler.  It
basically changes the preprocessor to shift through the source file, and
when an include is found, the included file is unshifted to the
beginning.


Should I commit it?

Brian

--- assemble.pl 17 Jun 2002 03:18:17 -0000      1.74
+++ assemble.pl 22 Jun 2002 02:39:15 -0000
@@ -227,7 +227,9 @@
   my $reg_re   = qr([INSP]\d+);
   my $num_re   = qr([-+]?\d+(\.\d+([eE][-+]?\d+)?)?);
 
-  for(@{$self->{cur_contents}}) {
+  my @todo=@{$self->{cur_contents}};
+  while(scalar(@todo)) {
+    $_=shift(@todo);
     $line++;
 
     #
@@ -263,16 +265,19 @@
     elsif(/^\.include \s+
            "([^"]+)"
           /x) {                                # .include "{file}"
-#      if(-e $1) {
-#        open FOO,"< $1";
-#        while(<FOO>) {
-#          chomp;
-#        }
-#        close FOO;
-#      }
-#      else {
-#        print STDERR "Couldn't open '$1' for inclusion at line $line: $!.\n";
-#      }
+      if(-e $1) {
+        open FOO,"< $1";
+        my @include;
+        while(<FOO>) {
+          chomp;
+          push(@include,$_);
+        }
+        unshift(@todo,@include);
+        close FOO;
+      }
+      else {
+        print STDERR "Couldn't open '$1' for inclusion at line $line: $!.\n";
+      }
     }
     elsif(/^\.macro    \s+
            ($label_re) \s*

Reply via email to