public static IExpression CreateFromExpression(string expression)
        {
            IExpression result = null;

            if (ConstantExpression.IsMatch(expression))
            {
                result = new ConstantExpression();
            }
            else if (AddExpression.IsMatch(expression))
            {
                result = new AddExpression();
            }
            else if (SubExpression.IsMatch(expression))
            {
                result = new SubExpression();
            }
            else if (MulExpression.IsMatch(expression))
            {
                result = new MulExpression();
            }
            else if (DivExpression.IsMatch(expression))
            {
                result = new DivExpression();
            }
            else if (LetExpression.IsMatch(expression))
            {
                result = new LetExpression();
            }
            else if (VariableExpression.IsMatch(expression))
            {
                result = new VariableExpression();
            }

            return(result);
        }
예제 #2
0
        public void IsMatchTests(string expression, bool expectedResult)
        {
            bool result = SubExpression.IsMatch(expression);

            Assert.That(result, Is.EqualTo(expectedResult));
        }