Unary Operator with Function Call

Jan 3 at 2:02 PM
Edited Jan 3 at 2:08 PM
Hello erverybody,

i have a problem with the standard Irony.Interpreter.Evaluator.ExpressionEvaluatorGrammar and therefore with my custom implemented grammar. Everythings works well, instead of one thing:

I extended the LanguageRuntime_OpDispatch_Init.cs with an Not UnaryOperatorImplementation for double:

AddUnary(op, typeof(double), x => (double)x > 0 ? 0.0 : 1.0);

When i start the grammar explorer i can use "sin(1)", i also can use !(sin(1)). But when i try to use "!sin(1)" an exception occurs:
Operator 'NOT' is not defined for types Irony.Interpreter.ClrMethodBindingTargetInfo.

The same problem occurs when i'm using NOT or - (negate) without any modifications on the grammar in case of negate. The operator exists but i think, the parser parses the text not correct (comparing ParseTree of !(sin(1)) and !sin(1)).

Can anybody help me with this tricky error, so that i can use "!Function" (in general <UnaryOperator> <Function>)? Any recommandation?
Jan 4 at 7:22 AM

i found the solution by myself:

The Standard Rule for UnaryOperator und UnaryExpression is:

UnExpr.Rule = UnOp + Term + ReduceHere();
UnOp.Rule = ToTerm("+") | "-" | "!";

I extended it and changed it to:

UnExpr.Rule = UnOp + Expr;// + ReduceHere();
UnOp.Rule = ToTerm("+") | "-" | "!" | "NOT";

Now everything is fine. :)