Re: Syntax Highlighting and Lexical Analysis

"Armel" <webid@asi.fr>
16 Sep 1999 01:58:26 -0400

          From comp.compilers

Related articles
Syntax Highlighting and Lexical Analysis Dominic@tootedom.freeserve.co.uk (Dominic Tootell) (1999-09-11)
Re: Syntax Highlighting and Lexical Analysis jacob.navia@wanadoo.fr (jacob.navia) (1999-09-16)
Re: Syntax Highlighting and Lexical Analysis webid@asi.fr (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 qjackson@wave.home.com (Quinn Tyler Jackson) (1999-10-04)
| List of all articles for this month |

From: "Armel" <webid@asi.fr>
Newsgroups: comp.compilers
Date: 16 Sep 1999 01:58:26 -0400
Organization: WebID
References: 99-09-041
Keywords: parse, tools

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


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
Armel ASSELIN


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.