Exemple #1
0
        public ProgramState execute(ProgramState state)
        {
            int val = expr.evaluate(state.SymbolTable);

            state.SymbolTable.setValue(id, val);
            return(state);
        }
Exemple #2
0
        public ProgramState execute(ProgramState state)
        {
            int val = expr.evaluate(state.SymbolTable);

            state.Output.add(val);
            return(state);
        }
Exemple #3
0
        public int evaluate()
        {
            int l = left.evaluate();

            if (op != null)
            {
                int r = right.evaluate();
                return(op is Plus ? l + r : l - r);
            }
            return(l);
        }
Exemple #4
0
        public ProgramState execute(ProgramState state)
        {
            int val = expr.evaluate(state.SymbolTable);

            if (val != 0)
            {
                state.Stack.add(thenStmt);
            }
            else
            {
                state.Stack.add(elseStmt);
            }
            return(state);
        }
Exemple #5
0
        public ProgramState execute(ProgramState state)
        {
            int val = id.evaluate(state.SymbolTable);

            if (state.FileTab.exists(val))
            {
                StreamReader b = state.FileTab.getValue(val);
                b.Close();
                state.FileTab.delete(val);
            }
            else
            {
                throw new FileNotFoundException("File not found!");
            }
            return(state);
        }
Exemple #6
0
 public int evaluate()
 {
     return(e.evaluate());
 }