コード例 #1
0
        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));
        }
コード例 #2
0
ファイル: UnaryExpression.cs プロジェクト: solarplexus6/Oop
        public override bool Interpret(Context context)
        {
            if (!string.IsNullOrEmpty(_varName))
            {
                return(!context.GetValue(_varName));
            }

            return(!_exp.Interpret(context));
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: karolkecinski/University
        public override bool Interpret(Context context)
        {
            switch (this.Operator)
            {
            case "Neg":
                return(!expression.Interpret(context));

            default:
                throw new ArgumentException();
            }
        }
コード例 #4
0
 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);
         }
     }
 }
コード例 #5
0
        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);
                }
            }
        }
コード例 #6
0
 public override void Interpret(Context context)
 {
     directionExpression.Interpret(context);
     stepsExpression.Interpret(context);
 }
コード例 #7
0
 public override int Interpret(Context context)
 {
     return(leftExpression.Interpret(context) * rightExpression.Interpret(context));
 }