public PrgState execute(PrgState prgState)
        {
            int val = this.exp.evaluate(prgState.getSymTable());

            prgState.getSymTable().put(id, val);
            return(prgState);
        }
示例#2
0
        public PrgState execute(PrgState state)

        {
            int fd = this.exp.evaluate(state.getSymTable());
            Tuple <String, TextReader> br = state.getFileTable().get(fd);

            if (br == null)
            {
                throw new Exception("FileNotOpenedException at: " + this.ToString() + "\nNo such file descriptor: " + fd.ToString());
            }
            String line = br.Item2.ReadLine();
            int    val  = 0;

            if (line != null)
            {
                val = int.Parse(line);
            }
            state.getSymTable().put(this.var, val);
            return(state);
        }
示例#3
0
        public PrgState execute(PrgState state)
        {
            int fd = this.exp.evaluate(state.getSymTable());
            Tuple <String, TextReader> act = state.getFileTable().get(fd);

            if (act == null)
            {
                throw new Exception("FileNotOpened Exception at: " + this.ToString() + "\nThere is no opened file with fd = " + fd);
            }
            act.Item2.Close();
            state.getFileTable().remove(fd);
            return(state);
        }
        public PrgState execute(PrgState prgState)
        {
            MyIStack <IStmt> stk = prgState.getExeStack();
            int val = this.exp.evaluate(prgState.getSymTable());

            if (val != 0)
            {
                stk.push(this.thenStmt);
            }
            else
            {
                stk.push(this.elseStmt);
            }
            return(prgState);
        }
        public PrgState execute(PrgState prgState)
        {
            var fileTable = prgState.getFileTable();

            foreach (Tuple <string, TextReader> act in fileTable.values())
            {
                if (act.Item1 == this.fileName)
                {
                    throw new Exception("already opened wtf?");
                }
            }
            TextReader t     = File.OpenText(this.fileName);
            int        actFd = ++OpenRFileStmt.fd; /// static variable

            prgState.getFileTable().put(actFd, new Tuple <String, TextReader>(this.fileName, t));
            prgState.getSymTable().put(this.varId, actFd);
            return(prgState);
        }
示例#6
0
 public PrgState execute(PrgState prgState)
 {
     prgState.getOut().add(exp.evaluate(prgState.getSymTable()));
     return(prgState);
 }