Re: Problem with Flex/Bison and C/C++

Chris F Clark <>
27 Mar 2006 01:26:37 -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: Chris F Clark <>
Newsgroups: comp.compilers
Date: 27 Mar 2006 01:26:37 -0500
Organization: The World Public Access UNIX, Brookline, MA
References: 06-03-077
Keywords: parse, C++
Posted-Date: 27 Mar 2006 01:26:37 EST

Christoph asked:
> 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.

Yes, put only pointers in your union. You can then use a "void *" (or
char *) pointer in your lexer and that will work in C. There are
other reasons why using only pointers in your union is a good
solution. However, let me just say that your union is to help hook you
resulting AST together, and as such you want to have a pointer to the
object being linked and not a copy of the object being linked.

There are also versions of "lex" that generate C++. I would recommend
finding one of them for the long run.

Hope this helps,

Chris Clark Internet :
Compiler Resources, Inc. Web Site :
23 Bailey Rd voice : (508) 435-5016
Berlin, MA 01503 USA fax : (978) 838-0263 (24 hours)

Post a followup to this message

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