12-11-2022, 08:21 PM
(12-11-2022, 05:39 PM)TempodiBasic Wrote: wow I googled and found the order of execution of the logical operator in QB
from first to last: NOT AND OR XOR EQV IMP
is this the same order of execution made by QB64pe? I think so, but I wait for developers response.
If you want our order of operations, check inside the code for my math evaluation routine. Math Evaluator (qb64phoenix.com)
For our logical operators, they're last in the list and in this order:
Code: (Select All)
'Logical Operations PL 80+
i = i + 1: ReDim _Preserve OName(i): OName(i) = "NOT"
ReDim _Preserve PL(i): PL(i) = 80
i = i + 1: ReDim _Preserve OName(i): OName(i) = "AND"
ReDim _Preserve PL(i): PL(i) = 90
i = i + 1: ReDim _Preserve OName(i): OName(i) = "OR"
ReDim _Preserve PL(i): PL(i) = 100
i = i + 1: ReDim _Preserve OName(i): OName(i) = "XOR"
ReDim _Preserve PL(i): PL(i) = 110
i = i + 1: ReDim _Preserve OName(i): OName(i) = "EQV"
ReDim _Preserve PL(i): PL(i) = 120
i = i + 1: ReDim _Preserve OName(i): OName(i) = "IMP"
ReDim _Preserve PL(i): PL(i) = 130
So all AND statements will be resolved before OR statements, much like how multiplication is resolved before addition or subtraction. (PL is Priority Level. Lower goes first over higher.)
One note though: NOT is an awfully strange beast. It's of the highest priority and yet also of the lowest priority. Unique handling is required when parsing it, as it doesn't truly fit into our order of operations like you'd expect. It's rather confusing to understand fully, and not worth derailing this topic here with it, but if you're truly interested in how it's parsed, start another topic on NOT somewhere, and I'll refresh my memory and try to explain the PITA that it is for you. If you're just mildly interested, and don't want a headache from it, just keep in mind, "NOT is a special beast when parsing and order of operations. Ask more about it if it ever comes up that I need to implement proper evaluation order myself with it."