Edita syntax colouring

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

Can anyone suggest a replacement for this fragment of code:
 (from easynclr.e)
elsif ctype=String then
--DEV '\') at end of line is wrong, but this mod crashes...
--			while chidx2<=length(text) do
			cQfound = 0
			while chidx2 < length(text) do
				ch2 = text[chidx2]
				chidx2 += 1
				if ch2 = ch then					-- closing quote
found
					cQfound = 1
					exit
				end if
				if ch2=EscapeLeadIns[newSyntax] and
length(Escapes[newSyntax]) then
					if not find(text[chidx2],Escapes[newSyntax]) then
						-- mark first segment (if any) as Strings, 
						-- these two characters as illegal,
						-- increment chidx & carry on.
						textC[chidx..chidx2-2]=ColourTab[Strings]
						attrC[chidx..chidx2-2]=StyleTab[Strings]
						backC[chidx2-1..chidx2]=ColourTab[Illegals]
						chidx=chidx2+1
					end if
					chidx2+=1
				end if	-- skip escaped chars
			end while
			syntaxClass=Strings
			if not cQfound then
--DEV '\' at end of line is still wrong
				chidx2=length(text)+1
				if ch!=text[length(text)] then
					syntaxClass=Illegals
				end if
			end if

<\eucode>

The problem is that '\' and "\" at the end of the line are not caught properly. The reason is fairly obvious: the while loop terminates on

rather than <= to avoid a subscript error, and the final test on text[length(text)] is inadequate. However, I appear to be suffering from brainfreeze & can't see the right way to re-code it.

It also needs to handle '\') at the end of the line, and should probably have different code for ' and ".

Regards, Pete }}}

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

Search



Quick Links

User menu

Not signed in.

Misc Menu