|Syntax Highlighting and Lexical Analysis Dominic@tootedom.freeserve.co.uk (Dominic Tootell) (1999-09-11)|
|Re: Syntax Highlighting and Lexical Analysis firstname.lastname@example.org (jacob.navia) (1999-09-16)|
|Re: Syntax Highlighting and Lexical Analysis email@example.com (Armel) (1999-09-16)|
|Re: Syntax Highlighting and Lexical Analysis Marko.Makela@HUT.FI (Marko =?ISO-8859-1?Q?M=E4kel=E4?=) (1999-09-20)|
|Re: Syntax Highlighting and Lexical Analysis maratb@CS.Berkeley.EDU (Marat Boshernitsan) (1999-09-20)|
|Re: Syntax Highlighting and Lexical Analysis firstname.lastname@example.org (Quinn Tyler Jackson) (1999-10-04)|
|Date:||16 Sep 1999 01:58:26 -0400|
> Syntax highlighing ?
Use something like 'flex' which will recongize all your base lexems
(words, ponctuations...) then use it on a per line basys (i don't
remenber if lex do that easily, but it must be possible) and in the
return of each function associated with a regular expression (which
describes your lexem) your return the number of character making up
the expression, and a code then you deduce a color from the code (you
can use the color code directly, but if you want the colors to be
parameterized, use the code as lookup index in a color table that the
user fills with a great interface :)
then you just have to do for each line :
for each (code,nb_char) group
set the color
print the nb_char next character in the string
if your lexer stop before the of the file : color the rest of the line an
red by example to show the user he has made a mistake.
you can use the 'above' context (lines before the one you colorize) if you
use comments as /* */
(VC++ uses the 100 previous lines for is context by default).
wish it helped you
Return to the
Search the comp.compilers archives again.