Closed jgersti closed 2 years ago
Yep, this one's been painful.
Right now "-" is only a binary operator, unless it's in front of a number (in which case it's parsed as a negative number).
I think the way to fix this is to create a new CommandParameter for "Minus".
Then, in the parsing tree, we need a branching processor to convert it to "Unary Minus" or "Binary Minus". The branching logic will then identify whether it was indented to be unary or binary based on the surrounding context.
Shouldn't be too bad to implement. we'll have to figure out exactly where to put the branch in the parsing tree to be most effective / least effective.
We might change the "negative" parsing logic too, and have "-" always be separated out and treated as a unary operator.
The unary operator we can use should be "Reverse", I believe? Whichever one currently does the ".Not()" on the value. Can't remember exactly which one atm.
The negation operator (unary -) is missing. While the workaround is simple, the bahaviour is nonetheless unexpected.