Flex/Bison: Error recovery destructors?

前端 未结 1 1403
予麋鹿
予麋鹿 2021-01-20 15:22

I have the following grammar for a comma-separated list with at least one item:

column_expression_list:
    column_expression {
        $$ = LinkedList_New()         


        
相关标签:
1条回答
  • 2021-01-20 15:45

    Supposing you destroy a list with all items in it using a function called "LinkedList_Del", use Bison's %destructor directive which is made especially for cleaning up allocated elements that end up not used because of error:

    %destructor { LinkedList_Del($$); } column_expression
    

    Good luck!

    Reference: http://www.gnu.org/software/bison/manual/bison.html#Destructor-Decl

    0 讨论(0)
提交回复
热议问题