develooper Front page | perl.perl6.internals | Postings from June 2002

.include directive for new assembler

Thread Next
From:
brian wheeler
Date:
June 21, 2002 19:45
Subject:
.include directive for new assembler
Message ID:
1024713440.32058.2.camel@thor
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*


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About