[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: using flex for source-hilighting
From: |
Valkanas Nikos |
Subject: |
RE: using flex for source-hilighting |
Date: |
Mon, 10 Jun 2002 11:29:08 +0300 |
Hi,
Being one of the performance die-hards, I feel obliged to offer a solution.
It is rather straightforward to implement it yourself through lex. Declare a
global integer, floc, and increment in every production by +=yylen (Take care
if you are using yyless() to increment only by yyless). You can then return
this number at the beginning of a token (before adding yylen) and after
(assumming you match exactly a token). The advantage is that you can easily
manipulate it to get exactly what you need (minus parens or white space for
example). You could also define it with YY_USER_ACTION but I wouldn't recommend
it if you are using yyless or other similar functions that back up the stream.
Cheers,
Nikos Balkanas
> -----Original Message-----
> From: Janus N." Tondering [mailto:address@hidden
> Sent: Sunday, June 09, 2002 6:31 PM
> To: address@hidden
> Subject: using flex for source-hilighting
>
>
> Dear Sirs,
>
> I've written a flex program that spits out a HTML formatted version of
> input in c++. My problem now is that I want to use this lexer
> to give me
> information about each keyword, string, number etc. found. I want the
> start and end file positions of the token matched.
>
> Any hint on how I can do this? Or isn't flex capable of this?
>
> Thank you.
> --
> Janus Nørgaard Tøndering
> email: address@hidden or address@hidden
>
> "Would you buy a car with the hood welded shut?"
> -Phil Hughes, Linux Journal Magazine
>
>
>
> _______________________________________________
> Help-flex mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/help-flex
>