static void Main(string[] args)
        {
            string    expression       = "one + three - two";
            Evaluator evaluator        = new Evaluator(expression);
            int       expressionResult = evaluator.Interpret(new Context());

            Console.WriteLine($"The result of expression '{expression}' is {expressionResult}");
            Console.ReadKey();
        }
Beispiel #2
0
		static void Main(string[] args) {
			const string expression = "w x z - +";
			var evaluator = new Evaluator(expression);
			var sentence = new Dictionary<string, IExpression>();
			sentence["w"] = new Number(5);
			sentence["x"] = new Number(10);
			sentence["z"] = new Number(42);
			var result = evaluator.Interpret(sentence);
			Console.WriteLine(result);

			Console.ReadKey();
		}
        private static void Main(string[] args)
        {
            const string expression = "w x z - +";
            var          evaluator  = new Evaluator(expression);
            var          sentence   = new Dictionary <string, IExpression>();

            sentence["w"] = new Number(5);
            sentence["x"] = new Number(10);
            sentence["z"] = new Number(42);
            var result = evaluator.Interpret(sentence);

            Console.WriteLine(result);

            Console.ReadKey();
        }