Re: Several flex scanners share common rules/definitions?

Carl Barron <cbarron413@adelphia.net>
28 Jun 2004 20:01:46 -0400

          From comp.compilers

Related articles
Several flex scanners share common rules/definitions? markus.cl@gmx.de (2004-06-26)
Re: Several flex scanners share common rules/definitions? cbarron413@adelphia.net (Carl Barron) (2004-06-28)
Re: Several flex scanners share common rules/definitions? snicol@apk.net (Scott Nicol) (2004-06-28)
Re: Several flex scanners share common rules/definitions? haberg@matematik.su.se (Hans Aberg) (2004-06-28)
Re: Several flex scanners share common rules/definitions? clint@0lsen.net (Clint Olsen) (2004-06-30)
Re: Several flex scanners share common rules/definitions? johnmillaway@yahoo.com (John Millaway) (2004-06-30)
Re: Several flex scanners share common rules/definitions? sjohnson@mathworks.com (Steve Johnson) (2004-07-13)
| List of all articles for this month |

From: Carl Barron <cbarron413@adelphia.net>
Newsgroups: comp.compilers
Date: 28 Jun 2004 20:01:46 -0400
Organization: Compilers Central
References: 04-06-102
Keywords: lex
Posted-Date: 28 Jun 2004 20:01:46 EDT

In article 04-06-102, Markus Dehmann
<markus.cl@gmx.de> wrote:


> I have two scanners that use basically the same regular expressions
> and differ only in a few details. How can I write the two lex files so
> that I don't have to write the common things twice?
>
> For example, my tow scanners both use these and several other
> definitions and rules:
>
> digit [0-9]
> octet [0-7]
> hexet [0-9a-fA-F]
> uAlpha [A-Z]
> lAlpha [a-z]
> alpha ({uAlpha}|{lAlpha})
>
> %%
>
> \n { lineNum++; }
> {digit}+ { process_digit(yytext); }
> ...
>
> I don't want to write this again and again for each scanner that uses
> these. How can I make a kind of scanner base class? Or can I just
> include these basic common rules in each of my scanners?
>


    searching for include in text version of flex.man gives no method
using just directives in the flex file,but you can separate the
components into files that correspond to the sections of the flex file
and write your own simple inclusion scheme, if what your are including
does not include anything else that the C preprocessor will not
include when compiling the flex output. Might be more of nightmare
than just including the parts directly in your text editor.



Post a followup to this message

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