Open
Description
Add support for -
as a prefix operator (e.g. -(1+2)
). There is currently support for it but only as a part of a literal.
So currently this is allowed:
-1 + 2
2--1
4*-2*(-1/-2)
And this is not:
-(1+1)
--2*2
And this is interpreted incorrectly:
-1**2 # Gives 1.0 ((-1)**2), should give -1.0 (-(1**2))
So we need to:
- Add code for the prefix operator
-
(**
< precedence <*/
) - TODO: need to add some special cases to ensure that
2**-1
and2**-3**-2
. Python does this using:prefixop = '-' power | '+' power | ... power = primary '**' prefixop primary = ... | '(' ... ')' | ...