예제 #1
0
 public void Set(string name, VarInfo v)
 {
     if (table.ContainsKey(name))
     {
         throw new Exception("Redeclaration of " + name);
     }
     table[name] = v;
 }
예제 #2
0
        public override void ExitVardecl(ssuplParser.VardeclContext context)
        {
            // vardecl : TYPE ID
            string  vname   = context.ID().GetText();
            string  typestr = context.TYPE().GetText();
            VarType vtype   = stringToType(typestr);
            VarInfo vinfo   = new VarInfo(vtype, label(),
                                          context.Start.Line);

            symtable.Set(vname, vinfo);
        }