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: Evan Lavelle
Subject: Re: %union and shared pointers to AST nodes
Date: Tue, 27 Sep 2005 09:40:01 +0100
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

Frans Englich wrote:
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: 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?

What is XPathlval? Is it yylval? If so, 'XPathlval.string = x' should work fine.

The code above is in a .h file which I include in the C section of *both* the lex and parser files; I think that'll fix your problem. If not, check your generated lex.yy.c - it should be pretty easy to find out how to make it compile.

(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.

I personally don't see any advantage in the yystype/union/struct mechanism; I would prefer to see a clean token interface between flex and bison, which is completely independent of bison's $/typing mechanism (which flex needs to know nothing about).

Evan





reply via email to

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