When is

后端 未结 2 1216
遥遥无期
遥遥无期 2021-01-05 20:45

When is %destructor invoked in BISON? I have the following bison code:

%union{
    char * sval; 
    Variable * vval; 
} 

%token VARIABLE 
%token L         


        
2条回答
  •  不知归路
    2021-01-05 20:56

    From the Bison Manual:

    Discarded symbols are the following:

    • stacked symbols popped during the first phase of error recovery,
    • incoming terminals during the second phase of error recovery,
    • the current lookahead and the entire stack (except the current right-hand side symbols) when the parser returns immediately, and
    • the start symbol, when the parser succeeds.

    So if you don't hit an error, the %destructor will be called on the stack if you return immediately (call YYABORT or YYACCEPT), or it will call it on start symbol if parsing succeeds.

提交回复
热议问题