help-bison
[Top][All Lists]
Advanced

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

Re: C++ / multiple instances / iostreams


From: Laurence Finston
Subject: Re: C++ / multiple instances / iostreams
Date: Sun, 18 Jul 2004 14:15:16 +0200 (MEST)

On Sun, 18 Jul 2004, Oliver Kowalke wrote:

> Hi,
>
> I've bison-1.875a installed and I've some questions to this version.
>
> 1) Does bison create an c++-parser class (wrapper) and can I use multiple
> instances of the parser in an application?

I've just been using 1.875, but the comments below might be helpful anyway.

There's been some discussion about C++ parser classes recently,
at least with respect to 1.875.
You can look at the archives here:
http://lists.gnu.org/archive/html/help-bison/

I just generate a reentrant C parser and put C++ code in the actions for
the rules.  It works fine.  I keep all the information about the parser
state that I need in the object pointed to by the `void*' argument passed
to `yyparse()'.  Therefore there's really no need for a parser class with
`yyparse()' as a member function.  I use multiple threads that call
`yyparse()' and that also works fine.

> 2) Does it support iostreams?

If you use the method described above, this question becomes irrelevant,
except with regard to the debugging output produced when using the `%debug'
feature and `yydebug' is positive.  This doesn't work well when using
multiple threads because output isn't peformed atomically.  I use
iostreams for my own debugging output and protect the stream with a mutex.
It may be possible to get Bison to use iostreams by defining
`YYFPRINTF', but I haven't gotten around to trying this yet.

Laurence Finston
GNU 3DLDF maintainer
http://www.gnu.org.software/3dldf




reply via email to

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