Re: A Puzzle in Eu -- what would you do?

new topic     » goto parent     » topic index » view thread      » older message » newer message

DB James wrote:
> 
> 

> What if the line contents above were this?:
> line=InnocentRtn("--In Eu, a comment begins with 2 hyphens") --A real comment
> 
> The "x" would report the first "--" and miss the real comment (oops).
> 
> The puzzle:
> How do *you* deal with this?  There must be a dozen ways, and I'd like to know
> what
> you would do.  The better answers would deal with *any* such search issue, not
> just
> double-hyphens.

I once made a program that did somthing like this.
I simlply removed all strings, replaced them with negitive integers,
then removed comments as above. I then went back and replaced
the negative integers with the strings(ignoring any that might
have been cut out with the comments).
This worked fine for:
--A comment
blah("--blah")--A comment
blah("--blah")--A comment with -- in it
blah("--blah")--A comment with "quotes" in it
and also handled strange lines like these by ignoring \"
and removing anything from a " to the end of the line
if there wasn't an ending ".
blah("--\"blah\"")--A comment with -- and a " in it

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu