|Peculiarity in Ada grammar clsi!graham@uunet.UU.NET (1994-01-19)|
|Re: Peculiarity in Ada grammar firstname.lastname@example.org (1994-01-20)|
|Re: Peculiarity in Ada grammar email@example.com (1994-01-20)|
|From:||clsi!graham@uunet.UU.NET (Paul Graham)|
|Keywords:||Ada, parse, design|
|Date:||Wed, 19 Jan 1994 17:18:05 GMT|
I was reading in Aho and Ullman about operator precedence parsing. The
book said that operator precedence works well for grammars in which each
operator has a fixed precedence, but breaks down (or at least becomese
more complicated) when operators have different precedence levels in
In C, minus has two different precedences, one for the unary form and one
for the binary form. Unary minus is at the same precedence level as other
unary operators such as logical negation and bitwise negation, while
binary minus is at the level of binary plus.
Ada has only one precedence for minus, at the cost of giving unary minus
lower precedence than multiplication operators. This has the unintuitive
effect of making
-5 mod 3 = -(5 mod 3)
-5 mod 3 /= (-5) mod 3
I wonder if Ada's expression grammar was designed with operator precedence
parsing in mind? Otherwise, how can the unintuitive precedence of unary
minus be explained?
Paul Graham, Compass Design Automation, Inc.
firstname.lastname@example.org OR email@example.com 410-992-5700
Return to the
Search the comp.compilers archives again.