using System.Collections.Generic;
using CodingSeb.ExpressionEvaluator;
public class XExpressionOperator : ExpressionOperator
public static readonly ExpressionOperator Sharp = new XExpressionOperator();
public static readonly ExpressionOperator Love = new XExpressionOperator();
public class XExpressionEvaluator : ExpressionEvaluator
protected new static readonly IList<ExpressionOperator> leftOperandOnlyOperatorsEvaluationDictionary =
ExpressionEvaluator.leftOperandOnlyOperatorsEvaluationDictionary
.FluidAdd(XExpressionOperator.Sharp);
protected new static readonly IList<IDictionary<ExpressionOperator, Func<dynamic, dynamic, object>>> operatorsEvaluations =
ExpressionEvaluator.operatorsEvaluations
.AddOperatorEvaluationAtNewLevelAfter(XExpressionOperator.Sharp, (left, _) => Math.Pow(left, -left), ExpressionOperator.UnaryPlus)
.AddOperatorEvaluationAtLevelOf(XExpressionOperator.Love, (left, right) => (left | right) << 1, ExpressionOperator.ShiftBitsLeft);
protected override IList<ExpressionOperator> LeftOperandOnlyOperatorsEvaluationDictionary
return leftOperandOnlyOperatorsEvaluationDictionary;
protected override IList<IDictionary<ExpressionOperator, Func<dynamic, dynamic, object>>> OperatorsEvaluations
return operatorsEvaluations;
protected override void Init()
operatorsDictionary.Add("#", XExpressionOperator.Sharp);
operatorsDictionary.Add("love", XExpressionOperator.Love);
public static void Main()
ExpressionEvaluator evaluator = new XExpressionEvaluator();
List<string> expressions = new List<string>()
expressions.ForEach(expression =>
Console.WriteLine(expression);
Console.WriteLine(evaluator.Evaluate(expression));
catch(Exception exception)
Console.WriteLine(exception.Message);
Console.WriteLine(string.Empty);