コード例 #1
0
        public PrgState execute(PrgState state)
        {
            MyIStack <IStmt> stk = state.getStk();

            stk.push(snd);
            stk.push(first);
            return(state);
        }
コード例 #2
0
        private PrgState oneStep(PrgState state)
        {
            MyIStack <IStmt> stk = state.getStk();

            if (stk.isEmpty())
            {
                throw new MyStmtExecException("The stack is empty");
            }
            IStmt crtStmt = stk.pop();

            try {
                return(crtStmt.execute(state));
            }
            catch (MyException ex)
            {
                throw new MyStmtExecException("" + ex);
            }
        }
コード例 #3
0
        public void allStep()
        {
            PrgState prg = repo.getCtrPrg();

            repo.clearData();
            while (!prg.getStk().isEmpty())
            {
                try
                {
                    oneStep(prg);
                    repo.logPrgStateExec();
                }
                catch (MyStmtExecException e)
                {
                    Console.WriteLine("Exception is : " + e);
                }
                Console.WriteLine(prg.ToString());
            }
        }
コード例 #4
0
        public PrgState execute(PrgState state)
        {
            MyIDictionary <string, int> dict = state.getSymTable();
            MyIStack <IStmt>            stk  = state.getStk();

            try
            {
                if (exp.eval(dict) != 0)
                {
                    stk.push(thenS);
                }
                else
                {
                    stk.push(elseS);
                }
            }
            catch (MyException ex)
            {
                throw new MyException("" + ex);
            }
            return(state);
        }