On 13 Feb 2010, at 22:45, Michael Budach wrote:
arch_body_1 : ;
{ $<Iface>$ = new TDataLineList; }
arch_body_1 : block_decltve_item;
{ $<Iface>$ = $<Iface>1; }
arch_body_1 : arch_body_1 block_decltve_item;
{ $<Iface>$ = appendToInterface($<Iface>1, $<Iface>2); }
block_decltve_item : common_decltve_item;
block_decltve_item : subprog_body;
block_decltve_item : comp_decl;
block_decltve_item : attribute_decl;
block_decltve_item : attribute_spec;
block_decltve_item : config_spec;
block_decltve_item : disconnection_spec;
block_decltve_item : signal_decl { $<Iface>$ = $<Iface>1; }
I implemented actions only for the signal_decl stuff, which returns
an Iface*. This means when e.g. a comp_decl occurs in the input, the
program crashes in the arch_body_1 actions, becuase they don't get
an Iface* but (in my case) a keyword (char*).
How can I determine of which type or which token-type an argument $n
is? I tried a dynamic_cast, but this does not work with unions and I
don't want to implement 'dummy' actions for all rules which i want
to ignore.
Bison just implements the %union default rule as untyped $$ = $1, that
is, the types only exist as static checking in the Bison compile, and
not in the output parser code. (For C++, Akim has implemented
variants, to appear in Bison 2.6, where the type also exits in the C++
code, but suspect you do not need it.)
So you need to assign config_spec a valid value somewhere, or write a
rule that initializes $$ instead of the default rule.
Hans
_______________________________________________
help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison