[Top][All Lists]

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

Bison prologues

From: Hans Aberg
Subject: Bison prologues
Date: Sat, 19 Oct 2002 18:58:29 +0200

One may need more than just two prologues under C++. One might in principle
put code at five places: In header: before, in and after the parser class;
and in source: before and in the parse() function. The place in the header
after the parser class might be needed certain types of user defined
template function definitions.

Of course, as much as possible of that should be avoided.

But one may need a more general construction: the ability to name prologues.

It could be that one writes say

%code <name> {

Then Bison creates a macro related to the names "code" and <name> where
"..." is put.

Then one might decide to use code like

%code header {

%code class {


Then it is no longer necessary to have a specific order between the
different code segments, as Bison sorts it out, and hand it over as a macro
to M4, which then will place the stuff where it should be.

-- The idea above is to be able to exploit M4 as much as possible in order
to create properly files write, and only use C preprocessor macros when
appropriate. This need then show up more than in C because there are a
number of C++ constructs one wants to be able to exploit, rather than using
C preprocessor macros.

  Hans Aberg

reply via email to

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