[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Top Dowm Variable Communication
From: |
lfinsto1 |
Subject: |
Re: Top Dowm Variable Communication |
Date: |
Wed, 22 Aug 2007 19:28:27 +0200 (CEST) |
User-agent: |
SquirrelMail/1.4.9a |
> 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.
You'll need to cast it to the correct type in each rule in which you want
to access the structure, unless you're just passing it further to a
function (which takes a `void*' argument, obviously).
You can use this object to store whatever information you like. My parser
(for GNU 3DLDF) needs to be thread-safe, so global variables wouldn't be a
good idea. There's a `Scanner_Type' object (this is the type pointed to
by my `void* parameter') for each instance of `yyparse', each of which is
in a separate thread.
It works great for me. If you want to see lots of examples, you could
look in the files with the suffix `.w' here:
http://cvs.savannah.gnu.org/viewvc/3dldf/3dldf/Group/CWEB/
`grep' for `parameter' and/or `Scanner_Node' (a `typedef' for
`Scanner_Type*').
Laurence Finston
- shift/reduce conflict with unary, cwcaceres, 2007/08/21
- Re: shift/reduce conflict with unary, Derek M Jones, 2007/08/21
- Re: shift/reduce conflict with unary, cwcaceres, 2007/08/21
- Re: shift/reduce conflict with unary, Derek M Jones, 2007/08/21
- Re: shift/reduce conflict with unary, cwcaceres, 2007/08/22
- Top Dowm Variable Communication, Arijit Das, 2007/08/22
- Message not available
- Re: Top Dowm Variable Communication, Ramón García, 2007/08/22
- Re: Top Dowm Variable Communication, Evan Lavelle, 2007/08/22
- Re: Top Dowm Variable Communication, Evan Lavelle, 2007/08/22
- Message not available
- Re: Top Dowm Variable Communication,
lfinsto1 <=
- Re: Top Dowm Variable Communication, Ramón García, 2007/08/24
- Re: shift/reduce conflict with unary, Evan Lavelle, 2007/08/22
- Re: shift/reduce conflict with unary, cwcaceres, 2007/08/22
- Re: shift/reduce conflict with unary, Evan Lavelle, 2007/08/22
- Re: shift/reduce conflict with unary, cwcaceres, 2007/08/22
- Re: shift/reduce conflict with unary, Evan Lavelle, 2007/08/22