[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Ambiguity involving two parse stacks reducing on the same rule
From: |
Laurence Finston |
Subject: |
Re: Ambiguity involving two parse stacks reducing on the same rule |
Date: |
Thu, 10 Mar 2005 15:58:28 +0100 (MET) |
> > v: e
> > | e e
> >
> > e: 'a'
> > | 'a' 'a'
> >
> [...] my question was if there was a way
> to get `%dprec' to work in such a case without having to rearrange
> the grammar. This question still stands, and perhaps someone here
> has an idea ...?
Perhaps structuring your grammar in a way similar to the following
example would help to solve your problem. This is just off the
top of my head, so I don't know if it will work, and
you would probably have to fiddle with it.
v_primary: (Whatever)
| e_primary
v_secondary: v_primary
| e_secondary e_primary
v_tertiary: v_secondary
v_expression: v_tertiary
e_primary: 'a'
e_secondary: e_primary
| e_secondary e_primary
e_tertiary: e_secondary
e_expression: e_tertiary
I think of the rules
`v_secondary: e_secondary e_primary'
and
`e_secondary: e_secondary e_primary'
as being operations with an implied operator between the symbols on
the right-hand side.
I use this technique (which I borrowed from Knuth) for my grammar.
Laurence Finston
http://www.gnu.org/software/3dldf/LDF.html