Post Reply 
order of logical operations in CAS
10-14-2022, 03:40 AM (This post was last modified: 10-14-2022 03:41 AM by Wes Loewer.)
Post: #1
order of logical operations in CAS
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?
Find all posts by this user
Quote this message in a reply
10-14-2022, 06:18 AM
Post: #2
RE: order of logical operations in CAS
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 &
Find all posts by this user
Quote this message in a reply
10-14-2022, 01:36 PM
Post: #3
RE: order of logical operations in CAS
(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.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)