In message <20020713174114$[EMAIL PROTECTED]> brian wheeler <[EMAIL PROTECTED]> wrote:
> On Sat, 2002-07-13 at 12:32, Tom Hughes wrote: > > In message <20020703012231$[EMAIL PROTECTED]> > > 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" Of course... The attached patch should handle that I think... 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:49:58 -0000 @@ -430,10 +430,13 @@ sub _annotate_contents { my ($self,$line) = @_; + my $str_re = qr(\"(?:[^\\\"]*(?:\\.[^\\\"]*)*)\" | + \'(?:[^\\\']*(?:\\.[^\\\']*)*)\' + )x; $self->{pc}++; return if $line=~/^\s*$/ or $line=~/^\s*#/; # Filter out the comments and blank lines - $line=~s/#[^'"]+$//; # Remove trailing comments + $line=~s/^((?:[^'"]+|$str_re)*)#.*$/$1/; # Remove trailing comments $line=~s/(^\s+|\s+$)//g; # Remove leading and trailing whitespace # # Accumulate lines that only have labels until an instruction is found..