On Sat, 2002-07-13 at 12:32, Tom Hughes wrote: > In message <20020703012231$[EMAIL PROTECTED]> > Simon Glover (via RT) <[EMAIL PROTECTED]> wrote: > > > This code: > > > > A: # prints "a" > > print "a" > > end > > > > doesn't assemble; the assembler dies with the error message: > > > > Use of uninitialized value in hash element at assemble.pl line 844. > > Couldn't find operator '' on line 1. > > > > If you remove the ""s from the comment, it works fine. Likewise, if > > you put the label, op and comment on the same line, ie: > > > > A: print "a" # prints "a" > > end > > > > then it assembles and runs OK. > > Here's a patch that will fix this. I havn't committed it because I'm > not sure why the assember wasn't dropping comments that included quotes > so I'm giving people who know more about the assembler than me a chance > to comment first...
I believe it wasn't dropping the comments with quotes as a side effect of not wanting to break things like: print "#" which breaks with the included patch. I basically had the same patch you do, but wasn't able to figure out how to handle the above case *and* do the right thing with # prints "a" Brian > > Tom > > -- > Tom Hughes ([EMAIL PROTECTED]) > http://www.compton.nu/ > ---- > > Index: assemble.pl > =================================================================== > RCS file: /cvs/public/parrot/assemble.pl,v > retrieving revision 1.77 > diff -u -r1.77 assemble.pl > --- assemble.pl 4 Jul 2002 18:36:17 -0000 1.77 > +++ assemble.pl 13 Jul 2002 17:30:48 -0000 > @@ -433,7 +433,7 @@ > > $self->{pc}++; > return if $line=~/^\s*$/ or $line=~/^\s*#/; # Filter out the comments and blank >lines > - $line=~s/#[^'"]+$//; # Remove trailing comments > + $line=~s/#.*$//; # Remove trailing comments > $line=~s/(^\s+|\s+$)//g; # Remove leading and trailing whitespace > # > # Accumulate lines that only have labels until an instruction is found..