Exemple #1
0
        static void Main(string[] args)
        {
            Context ctx = new Context();
            ctx.SetValue( "x", true );
            ctx.SetValue( "y", false );

            AbstractExpression left = new UnaryExpression(new ConstExpression(new ConstToken(false)), new Negation());
            AbstractExpression right_x = new ConstExpression(new VariableToken("x"));
            AbstractExpression right_y = new ConstExpression(new VariableToken("y"));
            AbstractExpression expr = new BinaryExpression( left, right_x, new Conjunction() );
            AbstractExpression expr2 = new BinaryExpression( left, right_y, new Conjunction() );
            AbstractExpression expr3 = new BinaryExpression( left, right_y, new Alternative() );

            Console.WriteLine(expr.Interpret(ctx));
            Console.WriteLine(expr2.Interpret(ctx));
            Console.WriteLine(expr3.Interpret(ctx));
            Console.ReadKey();
        }
Exemple #2
0
 public abstract bool Interpret(Context context);
Exemple #3
0
 public override bool Interpret(Context context)
 {
     return token.Interpret(context);
 }
Exemple #4
0
 public override bool Interpret(Context context, AbstractExpression left, AbstractExpression right)
 {
     return left.Interpret(context) && right.Interpret(context);
 }
Exemple #5
0
 public override bool Interpret(Context context)
 {
     return binaryOperator.Interpret( context, leftExpression, rightExpression );
 }
Exemple #6
0
 public override bool Interpret(Context context)
 {
     return unaryOperator.Interpret( context, expression );
 }
 public abstract bool Interpret(Context context, AbstractExpression expression);
 public abstract bool Interpret(Context context, AbstractExpression left, AbstractExpression right);
Exemple #9
0
 public override bool Interpret(Context context)
 {
     return value;
 }
Exemple #10
0
 public override bool Interpret(Context context, AbstractExpression expression)
 {
     return !expression.Interpret( context );
 }
Exemple #11
0
 public override bool Interpret(Context context)
 {
     return context.GetValue( variableName );
 }