Re: why use flex?

tnaran@direct.ca (Travers Naran)
5 Feb 1999 17:15:00 -0500

          From comp.compilers

Related articles
why use flex? frankhale@worldnet.att.net (Frank Hale) (1999-01-27)
Re: why use flex? irclark@latveria.castledoom.org (1999-01-31)
Re: why use flex? rkrayhawk@aol.com (1999-01-31)
Re: why use flex? tnaran@direct.ca (1999-02-01)
Re: why use flex? colas@aye.inria.fr (1999-02-03)
Re: why use flex? Marko.Makela@HUT.FI (Marko =?ISO-8859-1?Q?M=E4kel=E4?=) (1999-02-03)
Re: why use flex? tnaran@direct.ca (1999-02-05)
Re: why use flex? Theodore.Papadopoulo@sophia.inria.fr (Theodore.Papadopoulo) (1999-02-05)
Re: why use flex? Marko.Makela@HUT.FI (Marko =?ISO-8859-1?Q?M=E4kel=E4?=) (1999-02-10)
Re: why use flex? wvenable_net@iname.com (1999-02-15)
Re: why use flex? dmitrik@my-dejanews.com (Dmitri Katchalov) (1999-02-16)
| List of all articles for this month |
From: tnaran@direct.ca (Travers Naran)
Newsgroups: comp.compilers
Date: 5 Feb 1999 17:15:00 -0500
Organization: Rangersoft Vancouver
References: 99-01-111 99-02-004 99-02-015
Keywords: lex, C++

> Travers> The only real complaint I have is the *still* lacking direct
> Travers> C++ support. If one wants that, one has to use to modified
> Travers> Flex++/Bison++ utilities.
>
> Could someone enlighten me what kind of real advantages using
> generated scanner and parser classes could have over the traditional
> yyparse () / yylex () interface? Does it have something to do with
> re-entrant parsers? Or does it make "sub-parser calls" easier
> (i.e. when the input can contain multiple languages that cannot be
> feasibly handled by one parser, like SDL (ITU-T Z.100,Z.105) with
> ASN.1 definitions embedded between the ALTERNATIVE/ENDALTERNATIVE
> keywords)?


Excellent question which I forgot to answer: It has more to do with
encapsulating multiple parsers and making them easier to become
re-entrant. Currently, one has to ask Flex/Bison to emit their
scanners and parsers with a prefix, which isn't that bad, but it makes
it difficult to, say, switch lexers at run-time for a source code
highlighting system. One has to add a case statement at every point
one needs to call the lexer for C-style lexical scanners. With an
object encapsulation, the scanner objects can just be switched without
a problem.


(Of course this is a strawman argument: One could write a wrapper
class by hand for each lexical scanner, but it would be nice if Flex
and Bison would do it for me. <grin>)


--
Travers Naran Computer Programmer, P/T Meddler in Time & Space
New Westminster, British Columbia, Canada, North America, Earth...
E-mail: tnaran@direct.ca, naran@vcn.bc.ca
WWW: <http://www.loonie.net/~tnaran>


Post a followup to this message

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