Beispiel #1
0
        public int Main(int x, int y, int z)
        {
            ContextGrammar context = new ContextGrammar();

            context.SetVariable("x", x);
            context.SetVariable("y", y);
            context.SetVariable("z", z);

            IExpression expression = new SubtractExpression(new AddExpression(new NumberExpression("x"),
                                                                              new NumberExpression("y")),
                                                            new NumberExpression("z"));

            return(expression.Interpret(context));
        }
Beispiel #2
0
 public int Interpret(ContextGrammar context)
 {
     return(context.GetVariable(_name));
 }
Beispiel #3
0
 public int Interpret(ContextGrammar context)
 {
     return(_leftExpression.Interpret(context) - _rightExpression.Interpret(context));
 }