help-bison
[Top][All Lists]
Advanced

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

%union, C++, symbol types


From: Evan Lavelle
Subject: %union, C++, symbol types
Date: Wed, 06 Jul 2005 10:40:31 +0100
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

I'd like to pass a token class from Flex to Bison (ideally, a tr1::shared_ptr - a reference counted smart pointer class). However, in Bison itself I need to deal with a number of symbol types - tokens, AST nodes, and so on.

This means that I need to use a %union, but this is difficult because the classes are too complex to put in a union. Using class pointers in the union is difficult, because this messes up the reference counting, and I have to do manual resource management.

Is there anything new in Bison that could help with this (I'm on 1.875c)? Or can anyone suggest a work-around?

One fix might be to split up the Flex and Bison symbol types - is this possible? In other words, Flex and Bison communicate using only one type, and Bison has its own multiple types for terminals, non-terminals, and so on (it seems strange that F/B share a single YYSTYPE - why is this?)

Thanks -

Evan





reply via email to

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