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) |
Newsgroups: | comp.compilers |
From: | Terence John Parr <parrt@parr-research.com> |
Keywords: | yacc |
Organization: | Compilers Central |
References: | 95-03-023 |
Date: | Sat, 4 Mar 1995 03:48:34 GMT |
Frazer Worley, #909980 DAD (frazerw@dseg.ti.com) wrote:
: First up, I have a limited knowledge of compilers and so please
: forgive me if this is a dumb question.
: I want to add semantic actions to a Yacc parser. The way I'd considered
.....
: digits : /* empty */
: | {} digits {} digit {}
: ;
.....
: Now this causes reduce/reduce conflicts in Yacc. Is there a way to
: avoid this ? Or is there a better way to add semantic actions ?
For your info: adding an action to the left edge of every production
in an LR(1)-based grammar weakens its strength to that of LL(1),
unfortunately. Hence, there is a theoretical reason behind your
experience.
LALR(k) would fix this (k>1 tokens of lookahead), by the way (in
that actions could only reduce the strength of the grammar to LL(k)).
: to do this already - yacc2rdp or something ?
There isn't a general tool that can take an LALR(1) grammar and convert
it to LL(1) for theoretical reasons etc..., but the removal of left-recursion
and such is no big deal and there must be tools around for that.
: Or, is there another compiler generator which I could use instead
: of Yacc which would enable me to do what I want ?
Sure, RDP looks nice, the Cocktail/GMD and new stuff by Josef Grosch
is nice too. You can also check out PCCTS which is LL(k) for k>1
and has mucho other features that might interest you. Check out
newsgroup comp.compilers.tools.pccts and ftp site ftp.parr-research.com
in pub/pccts.
Good luck,
Terence
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.