Re: yacc error clauses

babu@wipro.wipsys.soft.net (Satish Babu)
Tue, 20 Jul 1993 06:31:18 GMT

          From comp.compilers

Related articles
yacc error clauses jk@cs.man.ac.uk (1993-07-15)
Re: yacc error clauses babu@wipro.wipsys.soft.net (1993-07-20)
| List of all articles for this month |
Newsgroups: comp.compilers
From: babu@wipro.wipsys.soft.net (Satish Babu)
Keywords: yacc, errors
Organization: Compilers Central
References: 93-07-052
Date: Tue, 20 Jul 1993 06:31:18 GMT

> item_list
> : item
> { $$= $1; }
>
> | item_list COMMA item
> { $3->add_item($1); $$= $3; }
>
> | item_list COMMA error
> { delete $1; $$= 0; }


The error production can't catch the error in the first 'item'
in an 'item_list'. So, one more error production


            item_list : error


is necessary to do this. The error recovery ignores input tokens until the
follow of 'item_list' ( I can see COMMA, EQ) is encountered. Here, the
'item_list' is not yet formed, so no deletion is possible. The
introduction of this production may cause some conflicts, which can be
removed.


The 'yyerrok' is to be called (I hope you are doing so) to reset YACC's
error flag at appropriate places.


> item_list_use
> : item_list EQ item_list
> { $$= new item_list_use($1, $3); }
>
> What error productions do we need for item_list_use?


If the error production I suggested for 'item_list' is added, then no
others are necessary for 'item_list_use'. (Hoping that you don't want to
catch error for EQ).


I worked extensively with YACC in developing a Pascal Compiler. I'm
glad to help for any other problem in formulating error productions.


  --- K.Satish Babu
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.