Re: Yacc shift/reduce conflicts

"Dawid Pawlata" <dawidpawlata@wp.pl>
22 Dec 2004 01:05:42 -0500

          From comp.compilers

Related articles
Yacc shift/reduce conflicts anumber@compuserve.com (Martyn Weiss) (2004-12-19)
Re: Yacc shift/reduce conflicts snicol@apk.net (Scott Nicol) (2004-12-22)
Re: Yacc shift/reduce conflicts casse@irit.fr (=?ISO-8859-1?Q?Hugues_Cass=E9?=) (2004-12-22)
Re: Yacc shift/reduce conflicts dawidpawlata@wp.pl (Dawid Pawlata) (2004-12-22)
| List of all articles for this month |
From: "Dawid Pawlata" <dawidpawlata@wp.pl>
Newsgroups: comp.compilers
Date: 22 Dec 2004 01:05:42 -0500
Organization: news.onet.pl
References: 04-12-094
Keywords: yacc
Posted-Date: 22 Dec 2004 01:05:42 EST

Martyn Weiss wrote:


> I'm updating a language grammar I wrote a while ago using MKS Yacc,
> which consists of one or more statements separated by semicolons, i.e.
> S1;S2;...SN
>
> One of the things I want to do is to allow for superfluous embedded
> and trailing semicolons, as in S1;;S2;
>
> I had a bit if trouble expressing this in rules without getting
> shift/reduce conflicts. I found that if I simplify the grammar down
> to the following:
>
> program:
> statements
> ;
> statements:
> statement
> | statements semicolon
> | statements semicolon statement
> ;
> statement:
> someterminal
> ;


Hi!


what would you say about:


program:
      statements
  ;
  statements:
      statement
  | statements statement
  ;
  statement:
      | semicolon
      someterminal_or_nonterminal semicolon
  ;


best regards
Dawid Pawlata


Post a followup to this message

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