Re: Problem with Flex/Bison and C/C++
- From: Chris F Clark <cfc@xxxxxxxxxxxxxxxxxxxx>
- Date: 27 Mar 2006 01:26:37 -0500
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
*****************************************************************************
Chris Clark Internet : compres@xxxxxxxxxxxxx
Compiler Resources, Inc. Web Site : http://world.std.com/~compres
23 Bailey Rd voice : (508) 435-5016
Berlin, MA 01503 USA fax : (978) 838-0263 (24 hours)
------------------------------------------------------------------------------
.
- References:
- Problem with Flex/Bison and C/C++
- From: Christoph B.
- Problem with Flex/Bison and C/C++
- Prev by Date: Re: LL(1) grammar for regex
- Next by Date: Re: Grammar translator
- Previous by thread: Re: Problem with Flex/Bison and C/C++
- Next by thread: Re: Problem with Flex/Bison and C/C++
- Index(es):
Relevant Pages
|
|