When is %destructor invoked in BISON? I have the following bison code:
%union{
char * sval;
Variable * vval;
}
%token VARIABLE
%token Literal
%type <vval> Expression VARIABLE
%type <sval> Literal
%destructor { delete $$; } <vval>
%destructor { delete $$; } Literal
where Variable is a class. I thought that after processing a line, all the Variable objects will be freed, but I can see no destructor invoked. And that will lead straightly to memory leak...
Edit: To be clear; I allocate a new Variable object for a new token, and this token is pushed to the BISON stack. I want to delete the Variable when it is popped by bison and discarded from the stack. I thought that %destructor serves that purpose, but I am not sure anymore..