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: Hans Aberg
Subject: Re: %union and shared pointers to AST nodes
Date: Tue, 27 Sep 2005 15:09:08 +0200

On 27 Sep 2005, at 10:40, Evan Lavelle wrote:

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

This is not possible, as all parser semantic values use the same stack.

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

If one is using union for semantic type, some type checking is needed to avoid the code breaking. A similar happens with C++, if one is using static_cast.

The original Lex(Yacc setup, is that the parser includes the lexer directly, not a header. When changing this, and with additional complications under C++, the interfaces have to be reworked. Probably on a todo-list.

  Hans Aberg






reply via email to

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