/// public static Node?GetOperand( this NeuPrefixExpression prefixExpression) { var done = false; /// for (var i = prefixExpression.Children.Count(); i > 0 && !done; --i) { var child = prefixExpression.Children.ElementAt(i - 1); /// switch (child) { case NeuPrefixOperator op: done = true; break; /// case NeuExpression _: case NeuIdentifier _: // maybe can remove this? case NeuLiteral _: // maybe can remove this? return(child); /// default: continue; } } /// return(null); }
public static NeuOperation Execute( this NeuInterpreter interpreter, NeuPrefixExpression prefixExpr) { var op = prefixExpr.GetOperator(); if (op == null) { throw new Exception(); } /// var operand = prefixExpr.GetOperand() as NeuExpression; if (operand == null) { throw new Exception(); } /// return(interpreter.Execute(op, operand)); }
public static NeuPrefixOperator?GetOperator( this NeuPrefixExpression prefixExpression) { return(prefixExpression.GetFirstOrDefault <NeuPrefixOperator>()); }