public static NeuOperation Execute( this NeuInterpreter interpreter, NeuExpression expr) { switch (expr) { case NeuLiteralExpression litExpr: return(interpreter.Execute(litExpr)); /// case NeuIdentifierExpression idExpr: return(interpreter.Execute(idExpr)); /// case NeuCallExpression callExpr: return(interpreter.Execute(callExpr)); /// case NeuUnaryExpression unaryExpr when !unaryExpr.IsFixExpression(): return(interpreter.Execute(unaryExpr)); /// case NeuPrefixExpression prefixExpr: return(interpreter.Execute(prefixExpr)); /// case NeuInfixExpression infixExpr: return(interpreter.Execute(infixExpr)); /// case NeuPostfixExpression postfixExpr: return(interpreter.Execute(postfixExpr)); /// default: throw new Exception(); } }
public static NeuIdentifier?GetIdentifier( this NeuExpression expr) { switch (expr) { case NeuIdentifierExpression idExpr: return(idExpr.GetIdentifier()); /// default: return(null); } }
public static NeuOperation PrefixIncrement( this NeuInterpreter interpreter, NeuExpression operand) { var id = operand.GetIdentifier(); if (id == null) { throw new Exception(); } /// var name = id.Source; /// var operandResult = interpreter.Execute(operand); /// switch (true) { case var _ when operandResult is NeuInteger intResult: return(interpreter.PrefixIncrement(name, intResult)); /// default: throw new Exception(); } }
public static NeuOperation Execute( this NeuInterpreter interpreter, NeuPrefixOperator op, NeuExpression operand) { switch (op.OperatorType) { case NeuUnaryOperatorType.Increment: return(interpreter.PrefixIncrement(operand)); /// case NeuUnaryOperatorType.Decrement: return(interpreter.PrefixDecrement(operand)); /// default: throw new Exception(); } }