Re: Parsing fully context-free grammars

hannah@schlund.de (Hannah Schroeter)
6 Oct 2005 15:17:22 -0400

          From comp.compilers

Related articles
[2 earlier articles]
Re: Parsing fully context-free grammars lowell@coasttocoastresearch.com (Lowell Thomas) (2005-09-22)
Re: Parsing fully context-free grammars haberg@math.su.se (2005-09-23)
Re: Parsing fully context-free grammars paul@parsetec.com (Paul Mann) (2005-10-02)
Re: Parsing fully context-free grammars haberg@math.su.se (2005-10-02)
Re: Parsing fully context-free grammars drikosv@otenet.gr (Evangelos Drikos) (2005-10-03)
Re: Parsing fully context-free grammars paul@parsetec.com (Paul Mann) (2005-10-04)
Re: Parsing fully context-free grammars hannah@schlund.de (2005-10-06)
Re: Parsing fully context-free grammars drikosv@otenet.gr (Evangelos Drikos) (2005-10-07)
Re: Parsing fully context-free grammars lowell@coasttocoastresearch.com (lowell@coasttocoastresearch.com) (2005-10-20)
| List of all articles for this month |
From: hannah@schlund.de (Hannah Schroeter)
Newsgroups: comp.compilers
Date: 6 Oct 2005 15:17:22 -0400
Organization: Schlund + Partner AG
References: 05-10-037
Keywords: parse
Posted-Date: 06 Oct 2005 15:17:22 EDT

Hello!


Juggling around the quotes a bit:


Paul Mann <paul@parsetec.com> wrote:
>[...]


>BTW, this grammar is unworkable in LR/LALR parser generators.
><stmt> is unreducible. It is a circular grammar.


>[...]


This can be fixed if you amend the grammer like this:


>> We could disambiguate by restating the grammar as:


>> <stmt> ::= <if-stmt>
>> | <if-else-stmt>
| <other-stmt>


>> <if-stmt> ::= if ( cond ) <stmt>
>>
>> <if-else-stmt> ::= if ( cond ) <non-if-stmt> else <stmt>
>>
>> <non-if-stmt> ::= <if-else-stmt>
| <other-stmt>


<other-stmt> ::= ... define other statements ...


I think it was quite obvious that something like that was meant.


Kind regards,


Hannah.


Post a followup to this message

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