Sorry, my initial answer was not quite correct.
The way to do this in Bison is to access the semantic value of the
previous non-terminal in the parent rule as $0. For example:
A: B C D
C: X { $0 is the semantic value of B}
This is risky. One has to take care that in all places where a
non-term
> Even though Bison is a bottom up parser, if I need to pass a variable's
> content top-down, what are the possible ways (except using global
> variable)?
One way is to use the optional parameter that you can pass to `yyparse'.
It is a `void*' that can point to an object of whatever type you like.
Ramón García wrote:
directed translation" has all the details.. I think that Synopsys, a
company that charges about 1 $ for each software license, can
afford a 30 $ book.
If you can get any Synopsys licences at $10K, then I'll have a shedload
of them...
:)
Arijit Das wrote:
Even though Bison is a bottom up parser, if I need to pass a variable's
content top-down, what are the possible ways (except using global
variable)?
Register_decl
: REGISTER IDENTIFIER Register_decl_contd
{
Char * register_name =
You have to put the register_name as an attribute of Register_decl_control
%union {
struct register_decl_contd_data {
const char* register_name;
/* other data that you want for register_decl_contd */
} register_decl_contd_data;
// Other union members for other terminals and non
Even though Bison is a bottom up parser, if I need to pass a variable's
content top-down, what are the possible ways (except using global
variable)?
Register_decl
: REGISTER IDENTIFIER Register_decl_contd
{
Char * register_name = $2;