コード例 #1
0
        public void Visit(RepeatStatement repeatStmt)
        {
            Console.Write("repeat");

            Console.Write("(");
            repeatStmt.NumOfTimes.Accept(this);
            Console.Write(")");

            repeatStmt.Body.Accept(this);
        }
コード例 #2
0
        public void Visit(RepeatStatement repeatStmt)
        {
            repeatStmt.NumOfTimes.Accept(this);

            dynamic numOfTimes = Environment.PopFromTheStack();

            if (numOfTimes is double)
            {
                for (int loopCntr = 0; loopCntr < (int)numOfTimes; loopCntr++)
                {
                    repeatStmt.Body.Accept(this);
                }
            }
            else
            {
                throw new ExecutorException($"Number of times: {numOfTimes} in repeat statement should be a digit");
            }
        }