[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Flex & Bison under C++

From: John Millaway
Subject: Re: Flex & Bison under C++
Date: Tue, 29 Oct 2002 18:23:34 -0500 (EST)

> >Why do you want a C++ scanner? What feature does the reentrant C
> >scanner lack?
> The main objective is to have a scanner that compiles correctly
> under C++ so that one can use C++ actions.
You can put C++ actions in the C scanner, then simply compile the
scanner with a C++ compiler.

> The next objective is for convenience to wrap this up in a class
> pure interface using namespaces, so it fits together with all the
> other code one writes in C++.
The prefix is your namespace, i.e., "yylex()" is logically equivalent
to "yy::lex()",

> When using Bison, it is imperative to...
I'm ignoring the bison issues, and focusing on flex.

> Such factors then pulls the need and want for a Bison parser C++
> class which is class pure. And if one would want to use Flex, one
> wants it to conveniently interface Bison.
A bison parser class can call a reentrant C scanner without any

> I can immediately note though that it defines a lot of macros. Under
> C++, one does not want to have a lot of macros, as the names can be
> wrapped up in a C++ namespace.
The macros would be present in the C++ scanner, too. Also, none of
flex's macros are exported -- they are used within the scanner, not
from the calling function.

> Also, my parser/lexer combination uses variables that are global to
> the lexer, but local to the parser.
I'm not sure what you mean by this. Either a variable is global or
it's not. But either way, the reentrant C scanner doesn't use any
non-const globals.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]