Re: precedences vs. hierarchy

George Neuner <>
Mon, 06 Jun 2016 12:35:55 -0400

          From comp.compilers

Related articles
precedences vs. hierarchy (Andreas Schramm) (2016-06-06)
Re: precedences vs. hierarchy (Dmitry A. Kazakov) (2016-06-06)
Re: precedences vs. hierarchy (George Neuner) (2016-06-06)
Re: precedences vs. hierarchy (2016-06-06)
precedences vs. hierarchy (SLK Mail) (2016-06-07)
Re: precedences vs. hierarchy (Kaz Kylheku) (2016-06-07)
Re: precedences vs. hierarchy (Dmitry A. Kazakov) (2016-06-07)
Re: precedences vs. hierarchy (2016-06-08)
| List of all articles for this month |

From: George Neuner <>
Newsgroups: comp.compilers
Date: Mon, 06 Jun 2016 12:35:55 -0400
Organization: A noiseless patient Spider
References: 16-06-001
Injection-Info:; posting-host=""; logging-data="23873"; mail-complaints-to=""
Keywords: parse
Posted-Date: 07 Jun 2016 10:54:27 EDT

On Mon, 6 Jun 2016 09:08:56 +0200, Andreas Schramm
<> wrote:

>for specifying the syntax of operator expressions
>with multiple levels of precedences,
>there are essentially two approaches:
>(i) by precedence and associativity declarations, and
>(ii) by a hierarchy of non-terminals.
>Both approaches have been known and in use for decades.
>My question is:
>Are there trends in the public opinion
>in favor of one of them over the other?
>Or are they equally respected approaches?

In general, precedence is shorter and easier to define. However when
there are many levels, associativity can be hard to get right, and
incorrect associativity chaining can be difficult to debug.

Non-terminal operator heirarchies are more work to define, but they
usually are easier to fix when associativity is wrong.

Your tools will dictate which approach you can use: few (if any) LL
tools support operator precedence, while all (?) LR tools do support
it. If your tool supports precedence, you still can choose to use an
explicit heirarchy instead if that works better for you.

What matters most is getting your grammar right ... don't worry too
much about what other people think of it.

Hope this helps,

Post a followup to this message

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