Browse thread
Problem with precedence declaration in .mly file
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Peter Ilberg <peter.ilberg@g...> |
| Subject: | Re: [Caml-list] Problem with precedence declaration in .mly file |
I have no experience with ocamlyacc, but looking at your grammar below, it
seems that you don't need the 'value PLUS exp' etc rules. All these cases
should be covered already by the 'exp PLUS exp' rules at the beginning and
the 'value' rule at the end.
Try removing the 'value PLUS exp' rules. Maybe ocamlyacc gets confused
if it has two sets of productions that it has to disambiguate with
precedence rules.
--- Peter
On Tue, 30 Oct 2007, Angela Zhu wrote:
> exp:
> ...
> | exp PLUS exp { Add($1, $3) }
> | MINUS exp { Sub(Value(VFloat(0.0)), $2)
> }
> | exp MINUS exp { Sub($1, $3) }
> | exp DIVIDE exp { Divide($1, $3) }
> | exp STAR exp { Mult($1, $3) }
> | exp ATOB exp { Atob($1, $3) }
*** do you really need these productions?
> | value PLUS exp { Add(Value($1), $3) }
> | value MINUS exp { Sub(Value($1), $3) }
> | value DIVIDE exp { Divide(Value($1), $3) }
> | value STAR exp { Mult(Value($1), $3) }
> | value ATOB exp { Atob(Value($1), $3) }
***
> ...
>
> | IDENT { Id($1) }
> | value { Value($1) }
>
>
> ;