Пример #1
0
 public override void execute(GlobalParameters globalParameters)
 {
     while (Test.evaluate(globalParameters) != 0)
     {
         Body.execute(globalParameters);
     }
 }
Пример #2
0
 public override void execute(GlobalParameters globalParameters)
 {
     foreach (Command item in items)
     {
         item.execute(globalParameters);
     }
 }
Пример #3
0
        public override void execute(GlobalParameters globalParameters)
        {
            double repetitionNumber = repetition.evaluate(globalParameters);

            for (int i = 0; i < repetitionNumber; i++)
            {
                commands.execute(globalParameters);
            }
        }
Пример #4
0
 public SyntaxAnalyser(Turtle turtle, Form1 form, TextBox textBox)
 {
     lexi             = new LexicalAnalyser();
     this.turtle      = turtle;
     this.form        = form;
     this.textBox     = textBox;
     globalParameters = new GlobalParameters(turtle, textBox);
     globalNamespace  = new Dictionary <string, int>();
     localNamespace   = new Dictionary <string, int>();
     variables        = new Dictionary <string, double>();
 }
Пример #5
0
 public override double evaluate(GlobalParameters globalParameters)
 {
     if (left.evaluate(globalParameters) > right.evaluate(globalParameters))
     {
         return(1);
     }
     else
     {
         return(0);
     }
     //TODO return true/false, not 0/1
 }
Пример #6
0
 public override double evaluate(GlobalParameters globalParameters)
 {
     if (left.evaluate(globalParameters) == 1 ||
         right.evaluate(globalParameters) == 1)
     {
         return(1);
     }
     else
     {
         return(0);
     }
 }
Пример #7
0
        public override void execute(GlobalParameters globalParameters)
        {
            List <double> mem = new List <double>();
            List <double> old;

            for (int i = 0; i < sub.subroutineNamespace.Count; i++)
            {
                mem.Add(args[i].evaluate(globalParameters));
            }
            old = globalParameters.localMemory;
            globalParameters.localMemory = mem;
            sub.body.execute(globalParameters);
            globalParameters.localMemory = old;
        }
 public override void set(double value, GlobalParameters globalParameters)
 {
     globalParameters.localMemory[address] = value;
 }
Пример #9
0
 public abstract void set(double value, GlobalParameters globalParameters);
 public override double get(GlobalParameters globalParameters)
 {
     return(globalParameters.localMemory[address]);
 }
Пример #11
0
 public abstract double evaluate(GlobalParameters globalParameters);
Пример #12
0
 public override double evaluate(GlobalParameters globalParameters)
 {
     return(variable.get(globalParameters));
 }
Пример #13
0
 public override double evaluate(GlobalParameters globalParameters)
 {
     return(Math.Pow(left.evaluate(globalParameters), right.evaluate(globalParameters)));
 }
Пример #14
0
 public override double evaluate(GlobalParameters globalParameters)
 {
     return(left.evaluate(globalParameters) / right.evaluate(globalParameters));
 }
Пример #15
0
 public override void execute(GlobalParameters globalParameters)
 {
     globalParameters.turtle.forward(param.evaluate(globalParameters));
 }
Пример #16
0
 public abstract double get(GlobalParameters globalParameters);
Пример #17
0
 public override void execute(GlobalParameters globalParameters)
 {
     variable.set(expr.evaluate(globalParameters), globalParameters);
 }
Пример #18
0
 public override double evaluate(GlobalParameters globalParameters)
 {
     return(subExpression.evaluate(globalParameters));
 }
Пример #19
0
 public override double evaluate(GlobalParameters globalParameters)
 {
     return(value);
 }
Пример #20
0
 public abstract void execute(GlobalParameters globalParameters);
Пример #21
0
 public override void execute(GlobalParameters globalParameters)
 {
     globalParameters.textBox.AppendText(Expr.evaluate(globalParameters).ToString() + Environment.NewLine);
 }