コード例 #1
0
        /// <summary>
        /// Enter the given symbol information into the symbol table.  If the given
        ///    symbol is already present at the current nest level, do whatever is most
        ///    efficient, but do NOT throw any exceptions from this method.
        /// </summary>

        public virtual void enter(string s, SymInfo info)
        {
            if (SymTblList.Peek().ContainsKey(s))
            {
                Console.WriteLine("Already exists at this level; try another var name");
            }
            else
            {
                SymTblList.Peek().Add(s, info);
            }
        }
コード例 #2
0
 public void PrintTop()
 {
     foreach (string key in this.SymTblList.Peek().Keys)
     {
         for (int i = 0; i < nestLevel; i++)
         {
             Console.Write("  ");
         }
         SymInfo s = (SymInfo)this.SymTblList.Peek()[key];
         Console.WriteLine(String.Format("{0}: {1}", key, s.ToFriendlyString()));// {1}", key, SymTblList.Peek()[key]));
     }
 }