Re: Re: help please?
Kenny MacDermid <[email protected]> Mon, 3 May 2004 10:55:36 -0300
| Newsgroups | gmane.comp.lang.prothon.devel |
|---|---|
| Message-ID | <[email protected]> |
On Mon, May 03, 2004 at 04:54:34PM +1200, Greg Ewing wrote:
> Alternatively, don't use precedence rules at all, and write
> out a hierarchy of productions to express precedences.
>
> Explicit is better than implicit. :-)
I agree to a certain degree, but for someone without much
cc experience it's easier to read and write:
----------
%left '+'
%left '*'
exp: num
| exp '+' exp
| exp '*' exp
----------
then:
----------
exp: exp '+' term
| term
term: term '*' num
| num
----------
Even though the second gives a much clear indication of what
it's going to do.
Factoring out most of the precedence should definitely be done
at some point though.
Kenny