Re: Problem with Flex/Bison and C/C++ (Hans Aberg)
27 Mar 2006 01:27:40 -0500

          From comp.compilers

Related articles
Problem with Flex/Bison and C/C++ (Christoph B.) (2006-03-22)
Re: Problem with Flex/Bison and C/C++ (John Millaway) (2006-03-27)
Re: Problem with Flex/Bison and C/C++ (Chris F Clark) (2006-03-27)
Re: Problem with Flex/Bison and C/C++ (2006-03-27)
| List of all articles for this month |

From: (Hans Aberg)
Newsgroups: comp.compilers
Date: 27 Mar 2006 01:27:40 -0500
Organization: Mathematics
References: 06-03-077
Keywords: yacc, C++
Posted-Date: 27 Mar 2006 01:27:40 EST

In article 06-03-077, "Christoph B."
<> wrote:

> First, my YYSTYPE union looked like this:
> %union
> So my question is if there is a simple way to have all the tokens as
> strings and integers and have nonterminals with more complicated C++
> data types. Is there a way to define the data format for nonterminals
> outside from YYSTYPE?

One can do it, but not yet officially using Bison, though it is on the
agenda. Right now, using %union only admits C++ POD types (essentially C
legacy types), as the parser implementation uses C/C++ union. If you do
not use %union, you can define YYSTYPE to any C++ type, but there are some
problems with placing the C++ code. Therefore, I use a special Bison tweak
for that, hoping that eventually it should become a part of Bison. But if
you are programming conservatively, you may not need this, but you can
attempt to use Bison's official C++ skeleton file.

    Hans Aberg

Post a followup to this message

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