I'm having problems getting my grammar to work with unary operations. For instance, if I enter "-5/2" I get -(5/2), not (-5)/2 which I would like to get. In this particular case the difference does not matter, however, I still think fixing this is important for the grammar.
However, it's also important that 1-5/2 get's parsed as 1-(5/2) and not (1-5)/2.
Currently I have the following operator's registered:
RegisterOperators(1, "||");
RegisterOperators(2, "&&");
RegisterOperators(3, "|");
RegisterOperators(4, "^");
RegisterOperators(5, "&");
RegisterOperators(6, "==", "!=");
RegisterOperators(7, "<", ">", "<=", ">=", "is");
RegisterOperators(8, "<<", ">>");
RegisterOperators(9, "+", "-");
RegisterOperators(10, "*", "/", "%");
RegisterOperators(11, "!");
RegisterOperators(-1, "?");
RegisterOperators(-2, "=", "+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>=");
The not operator already works as I want it to, however, the "+" and "-" kind of needs to be where they are in order to make sure that the "*", "/" and "%" is interpreted correctly. How should I solve this? Btw, if you need more of the grammar just let me know, I just figured I didn't need to drop more code here than necessarily.
After some trying I figured out a solution:
UnaryExpr.Rule = ImplyPrecedenceHere(30) + LUnOp + Expr;