[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help resolving conflicts in grammar



On Wed, Sep 3, 2008 at 5:00 PM,  Etienne Gagnon wrote:

> Hi Fidel,
>
> Your grammar (even with the mult fix) is ambiguous:
>
> singleton = ... | {arith_expr} arith_expr | ... ;
> arith_expr = ... | arith_term ; // implicitly because of "?"
> arith_term = {fac} arith_fac | ... ;
> arith_fac = {singleton} singleton | ... ;
>
> This leads to an infinite number of ASTs for the following singleton:
> identifier, as it can be seen as a singleton.type_cast, or as a
> singleton.arith_expr which is made up of a singleton (and so on).
>
> Removing the ? in singleton.type_cast will get you past the TAs
> conflict. You'll at least get to the next conflict. But, I don't know if
> this matches your desired semantics...
>
>   singleton =
>     ...
>     {type_cast} [varid]:identifier type_cast_rest | ...
>

Hi Etienne,

Thanks for the reply. I was looking at the grammar once again, and
realized that is really very ambiguous. I was just trying to implement
a parser for the Daplex language and wanted to make it compliant. But,
the grammar they have provided is ambiguous and I will make a change
to try to make it simpler.

Once again, thank you for the reply.

Fidel.