public void InterpretCorrectly() { var context1 = new Context("big scary pink"); var context2 = new Context("alaskan bull worm"); // "big scary pink" should be true Assert.IsTrue(_testExpression.Interpret(context1.Input)); // "alaskan bull worm" should be false Assert.IsFalse(_testExpression.Interpret(context2.Input)); }
public override bool Interpret(Context context) { if (!string.IsNullOrEmpty(_varName)) { return(!context.GetValue(_varName)); } return(!_exp.Interpret(context)); }
public override bool Interpret(Context context) { switch (this.Operator) { case "Neg": return(!expression.Interpret(context)); default: throw new ArgumentException(); } }
public override void Interpret(Context context) { if (context.Position < context.Source.Length) { _terminalExpression = new TerminalExpression(); _terminalExpression.Interpret(context); context.Position++; if (context.Result) { _nonTerminalExpression = new NonTerminalExpression(); _nonTerminalExpression.Interpret(context); } } }
public override void Interpret(Context context) { if (context.Position < context.Source.Length) { terminalExpresion = new TerminalExpresion(); terminalExpresion.Interpret(context); context.Position++; if (context.Result) { nonterminalExpression = new NonterminalExpression(); // идем рекурсивно nonterminalExpression.Interpret(context); } } }
public override void Interpret(Context context) { directionExpression.Interpret(context); stepsExpression.Interpret(context); }
public override int Interpret(Context context) { return(leftExpression.Interpret(context) * rightExpression.Interpret(context)); }