help-bison
[Top][All Lists]
Advanced

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

Re: %union and shared pointers to AST nodes


From: Frans Englich
Subject: Re: %union and shared pointers to AST nodes
Date: Mon, 26 Sep 2005 17:49:53 +0000
User-agent: KMail/1.8.50

On Friday 16 September 2005 20:28, Evan Lavelle wrote:
> struct yystype {
>     ...
>     antlr::RefToken  tok;
>     antlr::RefAST    ast;
> };
>
> #define YYSTYPE yystype

Yupp, that is an attractive solution from a memory management perspective. 
However, I have trouble with connecting flex to that. This is my type:

struct mType
{
    DOMString string;
    SharedQName::Ptr qname;
    Cardinality::Ptr cardinality;
    Expression::List *expressionList;
    Expression::Ptr expression;
    ItemType::Ptr itemType;
    SequenceType::Ptr sequenceType;
};

and I have the following in the C-section of the Bison file:
#define YYSTYPE mType

The parser compiles fine, but my flex grammar bails with:

------------
XPathLexer.l:98: error: request for member `string' in `XPathlval', which is 
of
   non-class type `YYSTYPE'
(etc)
----------
Line 98 looks like this:
XPathlval.string = DOMString(&(XPathtext[0]));

The mType struct is included into the XPathLexer so the compiler sees it. 

It feels as if I've gotten something dead wrong, but in a nutshell: how do I 
integrate with flex when using a YYSTYPE that is a struct?

(From the top of my head it would be nice if one could combine different types 
for different types of "entities". Say, a union for tokens, and an YYSTYPE 
struct for non-terminals. And yes, I also think the mType struct is 
inefficient performance wise.)


Cheers,

                Frans




reply via email to

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