Exemple #1
0
        public PrgState Execute(PrgState p)
        {
            try
            {
                this.Containsp(p);
                StreamReader fs = new StreamReader("read.txt");
                FileData     f  = new FileData(fileName, fs);
                int          id = IDGenerator.GenerateId();
                p.FileTable.Add(id, f);
                IMyDictionary <String, int> st = p.SymTable;
                if (st.ContainsKey(var_file_id))
                {
                    st.Update(var_file_id, id);
                }
                else
                {
                    st.Add(var_file_id, id);
                }
            }

            catch (NullReferenceException e)
            {
                Console.WriteLine(e.StackTrace);
            }
            return(p);
        }
Exemple #2
0
 public override int Eval(IMyDictionary <String, int> sym)
 {
     if (sym.ContainsKey(id))
     {
         int v;
         sym.TryGetValue(id, out v);
         return(v);
     }
     else
     {
         throw new Exception("The element does not exist in the symbol table");
     }
 }