Re: Semantic actions in Yacc ?

Terence John Parr <>
Sat, 4 Mar 1995 03:48:34 GMT

          From comp.compilers

Related articles
Semantic actions in Yacc ? (1995-03-02)
Re: Semantic actions in Yacc ? c1veeru@WATSON.IBM.COM (Virendra K. Mehta) (1995-03-03)
Re: Semantic actions in Yacc ? (Terence John Parr) (1995-03-04)
Re: Semantic actions in Yacc ? (1995-03-06)
Re: Semantic actions in Yacc ? (1995-03-06)
Re: Semantic actions in Yacc ? (Parag V. Tijare) (1995-03-08)
| List of all articles for this month |

Newsgroups: comp.compilers
From: Terence John Parr <>
Keywords: yacc
Organization: Compilers Central
References: 95-03-023
Date: Sat, 4 Mar 1995 03:48:34 GMT

Frazer Worley, #909980 DAD ( 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

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 and ftp site
in pub/pccts.

Good luck,

Post a followup to this message

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