Re: VHDL Operator associativity (Quartus II parser bug?)



On Thu, 19 Jun 2008 09:23:18 -0700 (PDT), Fons wrote:

This is confusing, I'm not following the book but the LRM, and it
states that or and and have the same precedence.

Yes, but LRM 7.1 (Expressions) gives the BNF for expressions,
and there you can clearly see that it is not possible to
combine more than one kind of logic operator in the same
expression unless you use parentheses, which can turn an
"expression" into a "primary". The same BNF also ingeniously
prohibits the use of more than one "nand" or "nor" operator
in an expression without parentheses, while allowing such
things as
a and b and c

So the folk who told you that "and" and "or" have different
precedence are indeed wrong, but it doesn't matter a scrap
because you can never use them together in an un-parenthesised
expression.

Why, by the way, are you so keen to strip unwanted parentheses?
Parentheses are good, especially in machine-generated code,
and are completely free after the compiler has done its work.
They do a good job of sparing us from our own idiocy.
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan.bromley@xxxxxxxxxxxxx
http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
.



Relevant Pages

  • Re: operator precedence in Fortran 2008 draft
    ... to take operands of type BITS. ... to overload the relational operators as well, ... the operator precedence chosen by standard ... forces the use of parentheses in the common cases. ...
    (comp.lang.fortran)
  • Re: syntax query: ($var++ && next) if /match/
    ... non-alphanumeric characters to it. ... natural language text I would respectfully disagree and I suspect you ... that I'd rather put in some unnecessary parentheses from time to ... meaning only to someone who knows the relative precedence of all ...
    (comp.lang.perl.misc)
  • Re: Article about Herb Schildt accepted at comp.risks
    ... entitled to change the order of evaluation if the precedence is ... implementation is entitled to use any order of evaluation in likes. ... better way to say it is that parentheses themselves have very high ... that most American programmers simply do not code much. ...
    (comp.lang.c)
  • Re: What is the output of the following code?
    ... In an expression with nested parentheses, ... highest precedence. ... Your rule is not enough to define the semantics of a macro processor, ...
    (comp.lang.c)
  • Re: Overloading of operator names - opinions sought
    ... standard functions supplied with your favourite C/Java/Ada/... ... bad ones will get it wrong no matter what the language permits/requires. ... associativity to user-defined words or require parentheses in all ... make code vulnerable to precedence changes ...
    (comp.lang.misc)