[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Type checking in semantic actions
From: |
Michael Budach |
Subject: |
Type checking in semantic actions |
Date: |
Sat, 13 Feb 2010 22:45:58 +0100 |
User-agent: |
Thunderbird 2.0.0.23 (Windows/20090812) |
Hello folks
I am currently working on my first bison project, which is a parser for
vhdl. Since I only need a subset of the language, I want to specify
actions only this subset.
consider the following example:
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.
Thanks for you help
Best regards,
Michael
- Type checking in semantic actions,
Michael Budach <=