On 5 Jul 2007, at 03:27, Gary Funck wrote:
Given the following semantic value definition:
%union {
uda_tword_t val;
uda_tword_t val2[2];
uda_tint_t signed_val;
uda_taddr_t addr_val;
uda_debugger_pts_t pts;
char *str;
uda_binary_data_t *data;
}
where uda_binary_data_t is defined as:
typedef uint8_t uda_byte_t;
typedef struct uda_binary_data_struct
{
size_t len;
uda_byte_t *bytes;
} uda_binary_data_t;
Above, data->bytes is an arbitrary sequence of bytes allocated
via malloc. In practice, a large maximum size (on the order of
16K bytes) could be established. But if uda_binary_data_
is redefined as:
typedef struct uda_binary_data_struct
{
size_t len;
uda_byte_t bytes[16*1024];
} uda_binary_data_t;
my understanding is that bison will copy this 16K byte value
on each reduce operation. Is that correct?
The Bison generated parser just implements %union as a C/C++ "union",
which is copied as memory. So if you have put in a pointer into %
union, as above, only the pointer will be copied. The rest will have
to be implemented in the actions, and during error recovery, using %
destructor (typically for cleanups).
Hans Aberg
_______________________________________________
[email protected] http://lists.gnu.org/mailman/listinfo/help-bison