On Tue, Aug 23, 2005 at 08:04:10PM +0000, Cedric wrote:
Hi all,

I've been programming in C/C++ now, and i found that no editor i've tried can highlight variables.

In C you have to declaire the variables before you can use them, so i think it should be possible to detect them, and then give them a color.

Has anybody already seen an editor who does that?

Probably none exist.

Typically a highlight engine works on regular expression, which is type-3 grammar. The C syntax is a context free grammar, which is type-2 grammar. Needless to say that a c parser is much more complex than the regular engine (comparing lexing and parsing). What you are asking for, however, is further into semantic parsing. For the minimum it is a context sensitive problem, which goes to type-1 grammar. A bullet-proof solution to your request is very complex.

However, if we assume the C source follows certain style so that simple regex parsing is sufficient to catch all the variable declarations and scoping and variable referring, a simpler solution may exist.
Greets,
--
Hui Zhou
--
http://linuxfromscratch.org/mailman/listinfo/lfs-chat
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to