Exemplo n.º 1
0
 public PrgState(IDictionaryy <string, int> d, IExeStack <Statement> exes, IListt <int> ol, Statement s, FileTable <int, FileData> ft)
 {
     dict       = d;
     stack      = exes;
     outputList = ol;
     stmt       = s;
     fileTable  = ft;
 }
Exemplo n.º 2
0
        public int Eval(IDictionaryy <string, int> dict)
        {
            try
            {
                int l = left.Eval(dict);
                int r = right.Eval(dict);

                if (op == '+')
                {
                    return(l + r);
                }
                if (op == '-')
                {
                    return(l - r);
                }
                if (op == '*')
                {
                    return(l * r);
                }
                else
                {
                    if (r == 0)
                    {
                        throw new DivByZeroException("Division by zero !");
                    }
                    else
                    {
                        return(l / r);
                    }
                }
                throw new InexistentSymbolException("Inexistent symbol error !");
            }
            catch (DivByZeroException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (EvaluationException e2)
            {
                Console.WriteLine(e2.Message);
            }
            catch (InexistentSymbolException e3)
            {
                Console.WriteLine(e3.Message);
            }
            return(-1);
        }
Exemplo n.º 3
0
 public int Eval(IDictionaryy <string, int> dict)
 {
     return(cnst);
 }
Exemplo n.º 4
0
 public int Eval(IDictionaryy <string, int> dict)
 {
     return(dict.Get(var));
 }