Several flex scanners share common rules/definitions?

markus.cl@gmx.de (Markus Dehmann)
26 Jun 2004 23:54:42 -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: markus.cl@gmx.de (Markus Dehmann)
Newsgroups: comp.compilers
Date: 26 Jun 2004 23:54:42 -0400
Organization: http://groups.google.com
Keywords: lex, question
Posted-Date: 26 Jun 2004 23:54:42 EDT

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?


Thanks
Markus


Post a followup to this message

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