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

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

On Fri, 05 Aug 2005 12:47:16 -0700, DB James <guest at RapidEuphoria.com>
wrote:

>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.

Since there are many places in Edita which must explicitly strip
comments, here is the general approach I use. It may not be as general
as you hoped, but it elegantly and efficiently covers all cases I know
of for comments and strings:

function getCodeAndComments(sequence line)
integer k, len, ch
	len=length(line)
	k=1
	while k<=len do
		ch=line[k]
		if ch='-' and k<len and line[k+1]='-' then
			exit
		elsif ch='\"' then
			while k<len do
				k+=1
				ch=line[k]
				if ch='\"' then exit end if
				if ch='\\' then k+=1 end if
			end while
		end if
		k+=1
	end while
	return {line[1..k-1],line[k..len]}
end function


Regards,
Pete

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

Search



Quick Links

User menu

Not signed in.

Misc Menu