Re: Semantic actions in Yacc ?

"Parag V. Tijare" <caibmnfx@ibmmail.com>
Wed, 8 Mar 1995 20:42:57 GMT

          From comp.compilers

Related articles
Semantic actions in Yacc ? frazerw@dseg.ti.com (1995-03-02)
Re: Semantic actions in Yacc ? c1veeru@WATSON.IBM.COM (Virendra K. Mehta) (1995-03-03)
Re: Semantic actions in Yacc ? parrt@parr-research.com (Terence John Parr) (1995-03-04)
Re: Semantic actions in Yacc ? C.A.Elliott@dcs.warwick.ac.uk (1995-03-06)
Re: Semantic actions in Yacc ? clark@quarry.zk3.dec.com (1995-03-06)
Re: Semantic actions in Yacc ? caibmnfx@ibmmail.com (Parag V. Tijare) (1995-03-08)
| List of all articles for this month |

Newsgroups: comp.compilers
From: "Parag V. Tijare" <caibmnfx@ibmmail.com>
Keywords: yacc
Organization: Compilers Central
References: 95-03-032
Date: Wed, 8 Mar 1995 20:42:57 GMT

Virendra Mehta wrote


:Basically, actions are just like any other non-terminals in yacc.
: ...
: This is compounded by the fact that no two actions are considered same even
:if they are empty.


This reminds me of situations when exactly same actions are needed at two
different places in the grammar. However, Yacc by itself cannot make out
that the actions are same, and this can cause conflicts. So simple way out
when it is known that the action required is same is to introduce additional
non-terminals with right hand side of the production empty and associate
the required action with the empty production of the new non-terminal.


eg. something like


A : 'a' { action1 } 'c' X Y;


B : 'a' { action1 } 'c' P Q;


will cause conflict


but


A : 'a' M 'c' X Y;


B : 'a' M 'c' P Q;


M : { action1 };


will not.
At least some of the conflicts can be avoided this way.


Parag IBMMAIL: caibmnfx@ibmmail.com
Internet: ptijare@vnet.ibm.com or parag@genius.tisl.soft.net
Phone: Off:(416) 448-4126 Tie Line: 778-4126 Res:(416) 287-9486
--


Post a followup to this message

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