cvsuser     01/09/23 17:56:45

  Modified:    .        assemble.pl
  Log:
  * Added --include=dir option to assembler to provide a path to look for
  included files.
  * Error message of a macro is defined inside of a macro
  
  Revision  Changes    Path
  1.41      +18 -5     parrot/assemble.pl
  
  Index: assemble.pl
  ===================================================================
  RCS file: /home/perlcvs/parrot/assemble.pl,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -w -r1.40 -r1.41
  --- assemble.pl       2001/09/23 20:29:38     1.40
  +++ assemble.pl       2001/09/24 00:56:45     1.41
  @@ -18,10 +18,13 @@
                      'version',
                      'verbose',
                      'output=s',
  -                   'listing=s'));
  +                   'listing=s',
  +                   'include=s@'));
   
  +my @include=(@{$options{'include'}},'.');
  +
   if($options{'version'}) {
  -    print $0,'Version $Id: assemble.pl,v 1.40 2001/09/23 20:29:38 bdwheele Exp $ 
',"\n";
  +    print $0,'Version $Id: assemble.pl,v 1.41 2001/09/24 00:56:45 bdwheele Exp $ 
',"\n";
       exit;
   }
   
  @@ -31,6 +34,7 @@
      --checksyntax        Check assembler syntax only, no output
      --help               This text
      --listing            Dump assembly listing to file
  +   --include            Directory to search for included files
      --output             File to dump bytecode into
      --verbose            Show what's going on
      --version            Show assembler version
  @@ -75,7 +79,7 @@
   my ($file,$line,$pline,$sline);
   my %equate=('*'=>sub { return $pc },
            '__DATE__'=>'"'.scalar(localtime).'"',
  -         '__VERSION__'=>'" $Revision: 1.40 $ "',
  +         '__VERSION__'=>'" $Revision: 1.41 $ "',
            '__LINE__' => sub { return $line },
            '__FILE__' => sub { return "\"$file\"" });
   
  @@ -86,13 +90,15 @@
        if($pline=~m/^endm$/i) {
            # end of the macro
            $in_macro=0;
  +     } elsif($pline=~m/^\S+\s+macro/) {
  +         error("Cannot define a macro inside of another macro");
        } else {
            push(@{$macros{$cur_macro}[1]},$l);
        }
        $pline="";
       }
       if($pline=~m/^\#/ || $pline eq "") {
  -     # its a comment, do nothing
  +     # its a comment or blank, do nothing
        $code=undef;
       } else {
        my($label);
  @@ -458,7 +464,14 @@
       my($line)=1;
       my(@lines);
       my($handle)=gensym;
  -    open($handle,$file) || error("Cannot open $file for input!",$ofile,$oline);
  +    my($found);
  +    foreach my $path (@include) {
  +     open($handle,"$path/$file") && do {
  +         $found=1;
  +         last;
  +     }
  +    }
  +    error("Cannot open $file for input!",$ofile,$oline) if(!$found);
       while(<$handle>) {
        chomp;
        my($sline)=$_;
  
  
  

Reply via email to