HP Forums

Full Version: order of logical operations in CAS
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I noticed that in Home A OR B AND C is treated as A OR (B AND C) as expected with AND having a higher precedence than OR.

However, in CAS a OR b AND c is treated as (a OR b) AND c, evaluating left to right with AND and OR having the same precedence.

For example:
Home:
true OR false AND false --> 1

CAS (and XCAS)
true OR false AND false --> false

Is this a bug, or is this the intended behavior?
Indeed, and and or have the same precedence in CAS because they are parsed with the same parser token in input_parser.yy (%left T_AND_OP), cf. input_lexer.ll
Code:

"&&"                    index_status(yyextra)=0; (*yylval)=gen(at_and,2); return T_AND_OP;
...
"||"                    index_status(yyextra)=0; (*yylval)=gen(at_ou,2); return T_AND_OP;
The same applies for xor and &
(10-14-2022 06:18 AM)parisse Wrote: [ -> ]Indeed, and and or have the same precedence in CAS ...

Okay, that's good to know. Thank you for clarifying.
Reference URL's