I am struggling a bit on deciding on the precedence of operators and would appreciate feedback. Currently I have it organised as follows:
- Three operator groups: Arithmetic, Comparative, and Bitwise (Logical)
With expressions containing mixed operators, precedence is (A) Arithmetic (B) Bitwise (C) Comparitive
Within groups, precedence is as shown below.
Anything inside () will be completely resolved before being applied to any expression on either side.
Final level of precedence is first come, first served, reading Left to Right.
Comparitives will return 0 or 1 if required as a result (eg, part of a larger operation or stored, etc), but where possible this extra step will be avoided and a simple false (0) or true (not false , not zero) will be used.
Arithmetic operators:
1 Unary plus
1 Unary minus
2 Exponentiation
3 Shift left
3 Shift right
4 Multiply
4 Divide
5 Integer divide (Truncate/Ignore remainder)
6 Modulus
7 Rotate left
7 Rotate right
8 Add
8 Subtract
Comparisons:
1 Equal to
2 Unequal
3 Less than
3 Greater than
4 Less than or Equal To
4 Greater than or Equal To
BitWise
1 Not
2 And
3 Or
4 Xor
(Note: Other things like Eqv, NotEqv, Imp, Nand, Nor can either be derived from, or are the same as, the above, so I don't intend to support them)
Any thoughts or ideas? Any comments that would be useful regarding precedence?
Thanks!


